Class: Samlr::Assertion
Constant Summary collapse
- DEFAULT_LOCATION =
"/samlp:Response/saml:Assertion"
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #attributes ⇒ Object
- #conditions ⇒ Object
-
#initialize(document, options) ⇒ Assertion
constructor
A new instance of Assertion.
- #location ⇒ Object
- #name_id ⇒ Object
- #name_id_options ⇒ Object
- #signature ⇒ Object
- #verify! ⇒ Object
Constructor Details
#initialize(document, options) ⇒ Assertion
Returns a new instance of Assertion.
6 7 8 9 |
# File 'lib/samlr/assertion.rb', line 6 def initialize(document, ) @document = document @options = end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
4 5 6 |
# File 'lib/samlr/assertion.rb', line 4 def document @document end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/samlr/assertion.rb', line 4 def @options end |
Instance Method Details
#attributes ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/samlr/assertion.rb', line 31 def attributes @attributes ||= {}.tap do |attrs| assertion.xpath("./saml:AttributeStatement/saml:Attribute", NS_MAP).each do |statement| name = statement["Name"] values = statement.xpath("./saml:AttributeValue", NS_MAP) if values.size == 0 next elsif values.size == 1 value = values.first.text else value = values.map { |value| value.text } end attrs[name] = attrs[name.to_sym] = value end end end |
#conditions ⇒ Object
62 63 64 |
# File 'lib/samlr/assertion.rb', line 62 def conditions @conditions ||= Condition.new(assertion.at("./saml:Conditions", NS_MAP), ) end |
#location ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/samlr/assertion.rb', line 18 def location @location ||= if !signature.missing? verify_signature! "//saml:Assertion[@ID='#{signature.references.first.uri}']" else DEFAULT_LOCATION end end |
#name_id ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/samlr/assertion.rb', line 50 def name_id if !name_id_node raise Samlr::FormatError.new("Invalid SAML response: name_id missing") else @name_id ||= name_id_node.text end end |
#name_id_options ⇒ Object
58 59 60 |
# File 'lib/samlr/assertion.rb', line 58 def @name_id_options ||= Hash[name_id_node.attributes.map{|k,v| [k, v.value]}] end |
#signature ⇒ Object
27 28 29 |
# File 'lib/samlr/assertion.rb', line 27 def signature @signature ||= Samlr::Signature.new(document, DEFAULT_LOCATION, ) end |
#verify! ⇒ Object
11 12 13 14 15 16 |
# File 'lib/samlr/assertion.rb', line 11 def verify! verify_signature! verify_conditions! unless skip_conditions? true end |