Class: OmniAuth::Strategies::Pfas::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/omniauth/strategies/pfas/response.rb

Constant Summary collapse

ASSERTION =
"urn:oasis:names:tc:SAML:1.0:assertion"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, options = {}) ⇒ Response

Returns a new instance of Response.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
# File 'lib/omniauth/strategies/pfas/response.rb', line 9

def initialize(response, options = {})
  raise ArgumentError.new("Response cannot be nil") if response.nil?
  self.options  = options
  self.response = response
  self.document = OmniAuth::Strategies::Pfas::SignedDocument.new(response)
end

Instance Attribute Details

#documentObject

Returns the value of attribute document.



7
8
9
# File 'lib/omniauth/strategies/pfas/response.rb', line 7

def document
  @document
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/omniauth/strategies/pfas/response.rb', line 7

def options
  @options
end

#responseObject

Returns the value of attribute response.



7
8
9
# File 'lib/omniauth/strategies/pfas/response.rb', line 7

def response
  @response
end

Instance Method Details

#attributesObject

A hash of alle the attributes with the response. Assuming there is only one value for each key



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/omniauth/strategies/pfas/response.rb', line 21

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.map {|e|e.text}
      if value.length == 1
        value = value[0]
      end

      result[name] = value
    end

    result
  end
end

#expires_onObject



42
43
44
# File 'lib/omniauth/strategies/pfas/response.rb', line 42

def expires_on
  document.expires_on
end

#validate!Object



16
17
18
# File 'lib/omniauth/strategies/pfas/response.rb', line 16

def validate!
  document.validate!(fingerprint)
end