Class: OmniAuth::Strategies::Latvija::Response
- Inherits:
-
Object
- Object
- OmniAuth::Strategies::Latvija::Response
- Defined in:
- lib/omniauth/strategies/latvija/response.rb
Constant Summary collapse
- ASSERTION =
"urn:oasis:names:tc:SAML:1.0:assertion"
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
-
#options ⇒ Object
Returns the value of attribute options.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#attributes ⇒ Object
A hash of alle the attributes with the response.
- #authentication_method ⇒ Object
-
#initialize(response, options = {}) ⇒ Response
constructor
A new instance of Response.
- #validate! ⇒ Object
Constructor Details
#initialize(response, options = {}) ⇒ Response
Returns a new instance of Response.
9 10 11 12 13 14 |
# File 'lib/omniauth/strategies/latvija/response.rb', line 9 def initialize(response, = {}) raise ArgumentError.new("Response cannot be nil") if response.nil? self. = self.response = response self.document = OmniAuth::Strategies::Latvija::SignedDocument.new(response) end |
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
7 8 9 |
# File 'lib/omniauth/strategies/latvija/response.rb', line 7 def document @document end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/omniauth/strategies/latvija/response.rb', line 7 def @options end |
#response ⇒ Object
Returns the value of attribute response.
7 8 9 |
# File 'lib/omniauth/strategies/latvija/response.rb', line 7 def response @response end |
Instance Method Details
#attributes ⇒ Object
A hash of alle the attributes with the response. Assuming there is only one value for each key
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/omniauth/strategies/latvija/response.rb', line 27 def attributes @attributes ||= begin result = {} stmt_element = REXML::XPath.first(document, "//a:Assertion/a:AttributeStatement", { "a" => ASSERTION }) return {} if stmt_element.nil? stmt_element.elements.each do |attr_element| name = attr_element.attributes["AttributeName"] value = attr_element.elements.first.text result[name] = value end result end end |
#authentication_method ⇒ Object
20 21 22 23 24 |
# File 'lib/omniauth/strategies/latvija/response.rb', line 20 def authentication_method @authentication_method ||= begin REXML::XPath.first(document, "//saml:AuthenticationStatement").attributes['AuthenticationMethod'] end end |
#validate! ⇒ Object
16 17 18 |
# File 'lib/omniauth/strategies/latvija/response.rb', line 16 def validate! document.validate!(fingerprint) end |