Class: Onelogin::Saml::Logoutresponse
- Inherits:
-
Object
- Object
- Onelogin::Saml::Logoutresponse
- Defined in:
- lib/onelogin/ruby-samlnechotech/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.
29 30 31 32 33 34 35 36 |
# File 'lib/onelogin/ruby-samlnechotech/logoutresponse.rb', line 29 def initialize(response, settings = nil, = {}) raise ArgumentError.new("Logoutresponse cannot be nil") if response.nil? self.settings = settings = @response = decode_raw_response(response) @document = XMLSecurity::SignedDocument.new(response) end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
17 18 19 |
# File 'lib/onelogin/ruby-samlnechotech/logoutresponse.rb', line 17 def document @document end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
19 20 21 |
# File 'lib/onelogin/ruby-samlnechotech/logoutresponse.rb', line 19 def end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
18 19 20 |
# File 'lib/onelogin/ruby-samlnechotech/logoutresponse.rb', line 18 def response @response end |
#settings ⇒ Object
For API compability, this is mutable.
15 16 17 |
# File 'lib/onelogin/ruby-samlnechotech/logoutresponse.rb', line 15 def settings @settings end |
Instance Method Details
#in_response_to ⇒ Object
55 56 57 58 59 60 |
# File 'lib/onelogin/ruby-samlnechotech/logoutresponse.rb', line 55 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
62 63 64 65 66 67 68 |
# File 'lib/onelogin/ruby-samlnechotech/logoutresponse.rb', line 62 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
70 71 72 73 74 75 |
# File 'lib/onelogin/ruby-samlnechotech/logoutresponse.rb', line 70 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
48 49 50 51 52 53 |
# File 'lib/onelogin/ruby-samlnechotech/logoutresponse.rb', line 48 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
42 43 44 45 46 |
# File 'lib/onelogin/ruby-samlnechotech/logoutresponse.rb', line 42 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
38 39 40 |
# File 'lib/onelogin/ruby-samlnechotech/logoutresponse.rb', line 38 def validate! validate(false) end |