Class: SAML2::Assertion

Inherits:
Message show all
Defined in:
lib/saml2/assertion.rb

Instance Attribute Summary collapse

Attributes inherited from Message

#destination, #errors, #issuer

Attributes inherited from Base

#xml

Instance Method Summary collapse

Methods inherited from Message

from_xml, #id, #issue_instant, parse, #sign, #valid_schema?, #validate

Methods included from Signable

#sign, #signature, #signed?, #signing_key, #valid_signature?, #validate_signature

Methods inherited from Base

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

Constructor Details

#initializeAssertion

Returns a new instance of Assertion.



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

def initialize
  super
  @statements = []
  @conditions = Conditions.new
end

Instance Attribute Details

#statementsArray<AuthnStatement, AttributeStatement>

Returns:



48
49
50
# File 'lib/saml2/assertion.rb', line 48

def statements
  @statements ||= load_object_array(xml, "saml:AuthnStatement|saml:AttributeStatement")
end

#subjectSubject?

Returns:



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

def subject
  if xml && !instance_variable_defined?(:@subject)
    @subject = Subject.from_xml(xml.at_xpath("saml:Subject", Namespaces::ALL))
  end
  @subject
end

Instance Method Details

#attribute_statementsArray<AttributeStatement>

Returns:



43
44
45
# File 'lib/saml2/assertion.rb', line 43

def attribute_statements
  statements.select { |s| s.is_a?(AttributeStatement) }
end

#authn_statementsArray<AuthnStatement]

Returns Array<AuthnStatement].

Returns:



38
39
40
# File 'lib/saml2/assertion.rb', line 38

def authn_statements
  statements.select { |s| s.is_a?(AuthnStatement) }
end

#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.



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/saml2/assertion.rb', line 53

def build(builder)
  builder["saml"].Assertion(
    "xmlns:saml" => Namespaces::SAML
  ) do |assertion|
    super(assertion)

    subject.build(assertion)

    conditions&.build(assertion)

    statements.each { |stmt| stmt.build(assertion) }
  end
end

#conditionsConditions

Returns:



30
31
32
33
34
35
# File 'lib/saml2/assertion.rb', line 30

def conditions
  if !instance_variable_defined?(:@conditions) && xml
    @conditions = Conditions.from_xml(xml.at_xpath("saml:Conditions", Namespaces::ALL))
  end
  @conditions
end

#from_xml(node) ⇒ Object



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

def from_xml(node)
  super
  @statements = nil
  remove_instance_variable(:@conditions)
end