Class: RSAML::Subject

Inherits:
Object
  • Object
show all
Defined in:
lib/rsaml/subject.rb

Overview

Specifies the principal that is the subject of all of the (zero or more) statements in an assertion.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier = nil) ⇒ Subject

Initialize the subject with the given identifier

[View source]

10
11
12
# File 'lib/rsaml/subject.rb', line 10

def initialize(identifier=nil)
  @identifier = identifier
end

Instance Attribute Details

#identifierObject

The subject identifier


7
8
9
# File 'lib/rsaml/subject.rb', line 7

def identifier
  @identifier
end

Class Method Details

.from_xml(element) ⇒ Object

Construct a Subject from an XML Element.

[View source]

30
31
32
33
34
35
# File 'lib/rsaml/subject.rb', line 30

def self.from_xml(element)
  element = REXML::Document.new(element).root if element.is_a?(String)      
  element.get_elements('saml:NameID').each do |identifier|
    return Subject.new(Identifier::Name.from_xml(identifier))
  end
end

Instance Method Details

#subject_confirmationsObject

Information that allows the subject to be confirmed. If more than one subject confirmation is provided, then satisfying any one of them is sufficient to confirm the subject for the purpose of applying the assertion.

[View source]

17
18
19
# File 'lib/rsaml/subject.rb', line 17

def subject_confirmations
  @subject_confirmations ||= []
end

#to_xml(xml = Builder::XmlMarkup.new) ⇒ Object

Construct an XML fragment representing the subject

[View source]

22
23
24
25
26
27
# File 'lib/rsaml/subject.rb', line 22

def to_xml(xml=Builder::XmlMarkup.new)
  xml.tag!('saml:Subject') {
    xml << identifier.to_xml unless identifier.nil?
    xml << subject_confirmations.map { |sc| sc.to_xml }.join
  }
end