Class: Saml::Kit::Assertion
- Inherits:
-
Object
- Object
- Saml::Kit::Assertion
- Includes:
- ActiveModel::Validations, Translatable
- Defined in:
- lib/saml/kit/assertion.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #active?(now = Time.current) ⇒ Boolean
- #attributes ⇒ Object
- #audiences ⇒ Object
- #encrypted? ⇒ Boolean
- #expired?(now = Time.current) ⇒ Boolean
- #expired_at ⇒ Object
-
#initialize(xml_hash, configuration:) ⇒ Assertion
constructor
A new instance of Assertion.
- #issuer ⇒ Object
- #name_id ⇒ Object
- #signature ⇒ Object
- #signed? ⇒ Boolean
- #started_at ⇒ Object
Constructor Details
#initialize(xml_hash, configuration:) ⇒ Assertion
Returns a new instance of Assertion.
11 12 13 14 15 |
# File 'lib/saml/kit/assertion.rb', line 11 def initialize(xml_hash, configuration:) @name = "Assertion" @xml_hash = xml_hash @configuration = configuration end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/saml/kit/assertion.rb', line 9 def name @name end |
Instance Method Details
#active?(now = Time.current) ⇒ Boolean
38 39 40 |
# File 'lib/saml/kit/assertion.rb', line 38 def active?(now = Time.current) now > configuration.clock_drift.before(started_at) && !expired? end |
#attributes ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/saml/kit/assertion.rb', line 42 def attributes @attributes ||= begin attrs = assertion.fetch('AttributeStatement', {}).fetch('Attribute', []) items = if attrs.is_a? Hash [[attrs["Name"], attrs["AttributeValue"]]] else attrs.map { |item| [item['Name'], item['AttributeValue']] } end Hash[items].with_indifferent_access end end |
#audiences ⇒ Object
63 64 65 66 67 68 |
# File 'lib/saml/kit/assertion.rb', line 63 def audiences Array(assertion['Conditions']['AudienceRestriction']['Audience']) rescue => error Saml::Kit.logger.error(error) [] end |
#encrypted? ⇒ Boolean
70 71 72 |
# File 'lib/saml/kit/assertion.rb', line 70 def encrypted? @xml_hash.fetch('Response', {}).fetch('EncryptedAssertion', nil).present? end |
#expired?(now = Time.current) ⇒ Boolean
34 35 36 |
# File 'lib/saml/kit/assertion.rb', line 34 def expired?(now = Time.current) now > expired_at end |
#expired_at ⇒ Object
59 60 61 |
# File 'lib/saml/kit/assertion.rb', line 59 def expired_at parse_date(assertion.fetch('Conditions', {}).fetch('NotOnOrAfter', nil)) end |
#issuer ⇒ Object
17 18 19 |
# File 'lib/saml/kit/assertion.rb', line 17 def issuer assertion.fetch('Issuer') end |
#name_id ⇒ Object
21 22 23 |
# File 'lib/saml/kit/assertion.rb', line 21 def name_id assertion.fetch('Subject', {}).fetch('NameID', nil) end |
#signature ⇒ Object
29 30 31 32 |
# File 'lib/saml/kit/assertion.rb', line 29 def signature xml_hash = assertion.fetch('Signature', nil) xml_hash ? Signature.new(xml_hash) : nil end |
#signed? ⇒ Boolean
25 26 27 |
# File 'lib/saml/kit/assertion.rb', line 25 def signed? signature.present? end |
#started_at ⇒ Object
55 56 57 |
# File 'lib/saml/kit/assertion.rb', line 55 def started_at parse_date(assertion.fetch('Conditions', {}).fetch('NotBefore', nil)) end |