Class: Onelogin::Saml::Logoutresponse

Inherits:
Object
  • Object
show all
Defined in:
lib/onelogin/ruby-saml/logoutresponse.rb

Constant Summary collapse

ASSERTION =
"urn:oasis:names:tc:SAML:2.0:assertion"
PROTOCOL =
"urn:oasis:names:tc:SAML:2.0:protocol"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, settings = nil, options = {}) ⇒ Logoutresponse

In order to validate that the response matches a given request, append the option:

:matches_request_id => REQUEST_ID

It will validate that the logout response matches the ID of the request. You can also do this yourself through the in_response_to accessor.

Raises:

  • (ArgumentError)


31
32
33
34
35
36
37
38
39
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 31

def initialize(response, settings = nil, options = {})
  raise ArgumentError.new("Logoutresponse cannot be nil") if response.nil?
  self.settings = settings

  @options = options
  @raw_response = response

  parse_logoutresponse
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



17
18
19
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 17

def document
  @document
end

#in_response_toObject (readonly)

Returns the value of attribute in_response_to.



21
22
23
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 21

def in_response_to
  @in_response_to
end

#issuerObject (readonly)

Returns the value of attribute issuer.



21
22
23
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 21

def issuer
  @issuer
end

#optionsObject (readonly)

Returns the value of attribute options.



18
19
20
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 18

def options
  @options
end

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



20
21
22
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 20

def raw_response
  @raw_response
end

#responseObject (readonly)

Returns the value of attribute response.



19
20
21
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 19

def response
  @response
end

#settingsObject

For API compability, this is mutable.



15
16
17
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 15

def settings
  @settings
end

Instance Method Details

#success?(soft = true) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 51

def success?(soft = true)
  unless @status_code == "urn:oasis:names:tc:SAML:2.0:status:Success"
    return soft ? false : validation_error("Bad status code. Expected <urn:oasis:names:tc:SAML:2.0:status:Success>, but was: <#@status_code> ")
  end
  true
end

#validate(soft = true) ⇒ Object



45
46
47
48
49
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 45

def validate(soft = true)
  return false unless valid_saml?(soft) && valid_state?(soft)

  valid_in_response_to?(soft) && valid_issuer?(soft) && success?(soft)
end

#validate!Object



41
42
43
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 41

def validate!
  validate(false)
end