Class: Saml2::Assertion
- Inherits:
-
Object
- Object
- Saml2::Assertion
- Extended by:
- Parsing
- Defined in:
- lib/saml2/assertion.rb
Defined Under Namespace
Modules: Parsing
Instance Attribute Summary collapse
-
#issuer ⇒ Object
readonly
Returns the value of attribute issuer.
-
#subject_name_id ⇒ Object
readonly
Returns the value of attribute subject_name_id.
Class Method Summary collapse
- .logger ⇒ Object
-
.new_from_artifact(artifact) ⇒ Saml2::Assertion
Resolves an artifact into the Assertion it represents.
- .new_from_xml(xml_assertion) ⇒ Object
- .verify(doc) ⇒ Object
Instance Method Summary collapse
- #[](attr_name) ⇒ Object
-
#initialize(issuer, subject_name_id, attributes) ⇒ Assertion
constructor
A new instance of Assertion.
Methods included from Parsing
each_attribute_node_from, item
Constructor Details
#initialize(issuer, subject_name_id, attributes) ⇒ Assertion
Returns a new instance of Assertion.
85 86 87 88 89 |
# File 'lib/saml2/assertion.rb', line 85 def initialize(issuer, subject_name_id, attributes) @issuer = issuer @subject_name_id = subject_name_id @attributes = attributes end |
Instance Attribute Details
#issuer ⇒ Object (readonly)
Returns the value of attribute issuer.
83 84 85 |
# File 'lib/saml2/assertion.rb', line 83 def issuer @issuer end |
#subject_name_id ⇒ Object (readonly)
Returns the value of attribute subject_name_id.
83 84 85 |
# File 'lib/saml2/assertion.rb', line 83 def subject_name_id @subject_name_id end |
Class Method Details
.logger ⇒ Object
53 54 55 |
# File 'lib/saml2/assertion.rb', line 53 def self.logger SamlSp.logger end |
.new_from_artifact(artifact) ⇒ Saml2::Assertion
Resolves an artifact into the Assertion it represents
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/saml2/assertion.rb', line 42 def self.new_from_artifact(artifact) artifact = if artifact.respond_to? :resolve artifact else Type4Artifact.new_from_string(artifact) end artifact.resolve end |
.new_from_xml(xml_assertion) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/saml2/assertion.rb', line 57 def self.new_from_xml(xml_assertion) doc = case xml_assertion when Nokogiri::XML::Node xml_assertion else Nokogiri::XML.parse(xml_assertion) end logger.info {"Parsing assertion: \n" + doc.to_xml(:indent => 2).gsub(/^/, "\t")} # We can't use the helpful #issuer_from until the 'asrt' namespace is defined, # but we can't add that definition without breaking signature verification. # This is sad. issuer = doc.at_xpath('//saml2:Assertion/saml2:Issuer', saml2: "urn:oasis:names:tc:SAML:2.0:assertion").text.strip verify(doc) if Saml2::Issuer(issuer).verify_signatures? doc.root.add_namespace_definition('asrt', 'urn:oasis:names:tc:SAML:2.0:assertion') attrs = Hash.new each_attribute_node_from(doc) do |node| attrs[attribute_name_from(node)] = attribute_value_from(node) end new(issuer_from(doc), subject_name_id_from(doc), attrs) end |
.verify(doc) ⇒ Object
95 96 97 98 |
# File 'lib/saml2/assertion.rb', line 95 def self.verify(doc) signed_doc = SignedXml::Document(doc) raise "SAML assertion failed verification" unless signed_doc.is_verified?(SamlSp::CertificateStore) end |
Instance Method Details
#[](attr_name) ⇒ Object
91 92 93 |
# File 'lib/saml2/assertion.rb', line 91 def [](attr_name) attributes[attr_name.to_s] end |