Class: OneLogin::RubySaml::Logoutresponse
- Inherits:
-
Object
- Object
- OneLogin::RubySaml::Logoutresponse
- 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
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#settings ⇒ Object
For API compability, this is mutable.
Instance Method Summary collapse
- #in_response_to ⇒ Object
-
#initialize(response, settings = nil, options = {}) ⇒ Logoutresponse
constructor
In order to validate that the response matches a given request, append the option: :matches_request_id => REQUEST_ID.
- #issuer ⇒ Object
- #status_code ⇒ Object
- #success?(soft = true) ⇒ Boolean
- #validate(soft = true) ⇒ Object
- #validate! ⇒ Object
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.
28 29 30 31 32 33 34 35 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 28 def initialize(response, settings = nil, = {}) raise ArgumentError.new("Logoutresponse cannot be nil") if response.nil? self.settings = settings @options = @response = decode_raw_response(response) @document = XMLSecurity::SignedDocument.new(response) end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
16 17 18 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 16 def document @document end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
18 19 20 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 18 def @options end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
17 18 19 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 17 def response @response end |
#settings ⇒ Object
For API compability, this is mutable.
14 15 16 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 14 def settings @settings end |
Instance Method Details
#in_response_to ⇒ Object
54 55 56 57 58 59 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 54 def in_response_to @in_response_to ||= begin node = REXML::XPath.first(document, "/p:LogoutResponse", { "p" => PROTOCOL, "a" => ASSERTION }) node.nil? ? nil : node.attributes['InResponseTo'] end end |
#issuer ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 61 def issuer @issuer ||= begin node = REXML::XPath.first(document, "/p:LogoutResponse/a:Issuer", { "p" => PROTOCOL, "a" => ASSERTION }) node ||= REXML::XPath.first(document, "/p:LogoutResponse/a:Assertion/a:Issuer", { "p" => PROTOCOL, "a" => ASSERTION }) node.nil? ? nil : node.text end end |
#status_code ⇒ Object
69 70 71 72 73 74 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 69 def status_code @status_code ||= begin node = REXML::XPath.first(document, "/p:LogoutResponse/p:Status/p:StatusCode", { "p" => PROTOCOL, "a" => ASSERTION }) node.nil? ? nil : node.attributes["Value"] end end |
#success?(soft = true) ⇒ Boolean
47 48 49 50 51 52 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 47 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
41 42 43 44 45 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 41 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
37 38 39 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 37 def validate! validate(false) end |