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

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

Constructor Details

#initializeSubject

Returns a new instance of Subject.



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

def initialize
  super
  @confirmations = []
end

Instance Attribute Details

#confirmationsConfirmation+

Returns:



41
42
43
# File 'lib/saml2/subject.rb', line 41

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

#name_idNameID

Returns:



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

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) ⇒ void

This method returns an undefined value.

Serialize this object to XML, as part of a larger document

Parameters:

  • builder (Nokogiri::XML::Builder)

    The builder helper object to serialize to.



46
47
48
49
50
51
52
53
# File 'lib/saml2/subject.rb', line 46

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

#confirmationConfirmation?

Returns:



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

def confirmation
  Array.wrap(confirmations).first
end

#confirmation=(value) ⇒ Confirmation?

Returns:



35
36
37
38
# File 'lib/saml2/subject.rb', line 35

def confirmation=(value)
  @confirmations = value.nil? ? [] : [value]
  confirmation
end

#from_xml(node) ⇒ void

This method returns an undefined value.

Parse an XML element into this object.

Parameters:

  • node (Nokogiri::XML::Element)


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

def from_xml(node)
  super
  @confirmations = nil
end