Class: Onelogin::Saml::Response
- Inherits:
-
Object
- Object
- Onelogin::Saml::Response
- Defined in:
- lib/onelogin/saml/response.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#response ⇒ Object
Returns the value of attribute response.
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
-
#attributes ⇒ Object
A hash of attributes and values.
- #decode ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #is_valid? ⇒ Boolean
-
#name_id ⇒ Object
The value of the user identifier as designated by the initialization request response.
- #session_index ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 |
# File 'lib/onelogin/saml/response.rb', line 8 def initialize(response) raise ArgumentError.new("Response cannot be nil") if response.nil? self.response = response self.document = XMLSecurity::SignedDocument.new(Base64.decode64(response)) end |
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
6 7 8 |
# File 'lib/onelogin/saml/response.rb', line 6 def document @document end |
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/onelogin/saml/response.rb', line 6 def logger @logger end |
#response ⇒ Object
Returns the value of attribute response.
6 7 8 |
# File 'lib/onelogin/saml/response.rb', line 6 def response @response end |
#settings ⇒ Object
Returns the value of attribute settings.
6 7 8 |
# File 'lib/onelogin/saml/response.rb', line 6 def settings @settings end |
Instance Method Details
#attributes ⇒ Object
A hash of attributes and values
36 37 38 39 40 41 42 43 44 |
# File 'lib/onelogin/saml/response.rb', line 36 def attributes result = {} document.elements.each("saml2:Assertion/saml2:AttributeStatement/saml2:Attribute") do |element| result.merge!(element.attributes["FriendlyName"] => element.elements.first.text) end result.merge!("name_id" => name_id) result.merge!("session_index" => session_index) result end |
#decode ⇒ Object
21 22 23 24 |
# File 'lib/onelogin/saml/response.rb', line 21 def decode body = document.decode(settings.private_key) self.document = body end |
#is_valid? ⇒ Boolean
14 15 16 17 18 19 |
# File 'lib/onelogin/saml/response.rb', line 14 def is_valid? return false if response.empty? return false if settings.nil? return true if document.validate_doc(settings.idp_public_cert, nil) return false end |
#name_id ⇒ Object
The value of the user identifier as designated by the initialization request response
27 28 29 |
# File 'lib/onelogin/saml/response.rb', line 27 def name_id @name_id ||= document.elements["saml2:Assertion/saml2:Subject/saml2:NameID"].text end |
#session_index ⇒ Object
31 32 33 |
# File 'lib/onelogin/saml/response.rb', line 31 def session_index @session_index ||= document.elements["saml2:Assertion/saml2:AuthnStatement"].attributes["SessionIndex"] end |