Class: SAML2::Subject

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

Defined Under Namespace

Classes: Confirmation

Instance Attribute Summary collapse

Attributes inherited from Base

#xml

Instance Method Summary collapse

Methods inherited from Base

from_xml, #inspect, load_object_array, load_string_array, lookup_qname, #to_s, #to_xml

Constructor Details

#initializeSubject

Returns a new instance of Subject.



9
10
11
# File 'lib/saml2/subject.rb', line 9

def initialize
  @confirmations = []
end

Instance Attribute Details

#confirmationsObject



33
34
35
# File 'lib/saml2/subject.rb', line 33

def confirmations
  @confirmations ||= load_object_array(xml, 'saml:SubjectConfirmation', Confirmation)
end

#name_idObject



18
19
20
21
22
23
# File 'lib/saml2/subject.rb', line 18

def name_id
  if xml && !instance_variable_defined?(:@name_id)
    @name_id = NameID.from_xml(xml.at_xpath('saml:NameID', Namespaces::ALL))
  end
  @name_id
end

Instance Method Details

#build(builder) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/saml2/subject.rb', line 37

def build(builder)
  builder['saml'].Subject do |subject|
    name_id.build(subject) if name_id
    Array(confirmations).each do |confirmation|
      confirmation.build(subject)
    end
  end
end

#confirmationObject



25
26
27
# File 'lib/saml2/subject.rb', line 25

def confirmation
  Array.wrap(confirmations).first
end

#confirmation=(value) ⇒ Object



29
30
31
# File 'lib/saml2/subject.rb', line 29

def confirmation=(value)
  @confirmations = [value]
end

#from_xml(node) ⇒ Object



13
14
15
16
# File 'lib/saml2/subject.rb', line 13

def from_xml(node)
  super
  @confirmations = nil
end