Class: OneLogin::RubySaml::Logoutresponse
- Inherits:
-
SamlMessage
- Object
- SamlMessage
- OneLogin::RubySaml::Logoutresponse
- Includes:
- ErrorHandling
- Defined in:
- lib/onelogin/ruby-saml/logoutresponse.rb
Overview
SAML2 Logout Response (SLO IdP initiated, Parser)
Constant Summary
Constants inherited from SamlMessage
SamlMessage::ASSERTION, SamlMessage::BASE64_FORMAT, SamlMessage::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
OneLogin::RubySaml::Settings Toolkit settings.
-
#soft ⇒ Object
Returns the value of attribute soft.
Attributes included from ErrorHandling
Instance Method Summary collapse
-
#in_response_to ⇒ String|nil
Gets the InResponseTo attribute from the Logout Response if exists.
-
#initialize(response, settings = nil, options = {}) ⇒ Logoutresponse
constructor
Constructs the Logout Response.
-
#issuer ⇒ String
Gets the Issuer from the Logout Response.
- #response_id ⇒ Object
-
#status_code ⇒ String
Gets the StatusCode from a Logout Response.
- #status_message ⇒ Object
-
#success? ⇒ Boolean
Checks if the Status has the “Success” code.
-
#validate(collect_errors = false) ⇒ Boolean
Aux function to validate the Logout Response.
Methods included from ErrorHandling
Methods inherited from SamlMessage
#id, schema, #valid_saml?, #version
Constructor Details
#initialize(response, settings = nil, options = {}) ⇒ Logoutresponse
Constructs the Logout Response. A Logout Response Object that is an extension of the SamlMessage class.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 34 def initialize(response, settings = nil, = {}) @errors = [] raise ArgumentError.new("Logoutresponse cannot be nil") if response.nil? @settings = settings if settings.nil? || settings.soft.nil? @soft = true else @soft = settings.soft end @options = @response = decode_raw_saml(response, settings) @document = XMLSecurity::SignedDocument.new(@response) end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
18 19 20 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 18 def document @document end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
20 21 22 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 20 def @options end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
19 20 21 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 19 def response @response end |
#settings ⇒ Object
OneLogin::RubySaml::Settings Toolkit settings
16 17 18 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 16 def settings @settings end |
#soft ⇒ Object
Returns the value of attribute soft.
22 23 24 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 22 def soft @soft end |
Instance Method Details
#in_response_to ⇒ String|nil
Returns Gets the InResponseTo attribute from the Logout Response if exists.
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 64 def in_response_to @in_response_to ||= begin node = REXML::XPath.first( document, "/p:LogoutResponse", { "p" => PROTOCOL } ) node.nil? ? nil : node.attributes['InResponseTo'] end end |
#issuer ⇒ String
Returns Gets the Issuer from the Logout Response.
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 77 def issuer @issuer ||= begin node = REXML::XPath.first( document, "/p:LogoutResponse/a:Issuer", { "p" => PROTOCOL, "a" => ASSERTION } ) Utils.element_text(node) end end |
#response_id ⇒ Object
50 51 52 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 50 def response_id id(document) end |
#status_code ⇒ String
Returns Gets the StatusCode from a Logout Response.
90 91 92 93 94 95 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 90 def status_code @status_code ||= begin node = REXML::XPath.first(document, "/p:LogoutResponse/p:Status/p:StatusCode", { "p" => PROTOCOL }) node.nil? ? nil : node.attributes["Value"] end end |
#status_message ⇒ Object
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 97 def @status_message ||= begin node = REXML::XPath.first( document, "/p:LogoutResponse/p:Status/p:StatusMessage", { "p" => PROTOCOL } ) Utils.element_text(node) end end |
#success? ⇒ Boolean
Checks if the Status has the “Success” code
58 59 60 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 58 def success? return status_code == "urn:oasis:names:tc:SAML:2.0:status:Success" end |
#validate(collect_errors = false) ⇒ Boolean
Aux function to validate the Logout Response
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/onelogin/ruby-saml/logoutresponse.rb', line 113 def validate(collect_errors = false) reset_errors! validations = [ :valid_state?, :validate_success_status, :validate_structure, :valid_in_response_to?, :valid_issuer?, :validate_signature ] if collect_errors validations.each { |validation| send(validation) } @errors.empty? else validations.all? { |validation| send(validation) } end end |