44require "ruby_saml/saml_message"
55require "time"
66
7+ # Only supports SAML 2.0
78module RubySaml
9+
810 # SAML2 Logout Response (SLO IdP initiated, Parser)
11+ #
912 class Logoutresponse < SamlMessage
1013 include ErrorHandling
1114
@@ -41,7 +44,7 @@ def initialize(response, settings = nil, options = {})
4144
4245 @options = options
4346 @response = decode_raw_saml ( response , settings )
44- @document = RubySaml ::XML :: SignedDocument . new ( @response )
47+ @document = Nokogiri ::XML ( @response )
4548 super ( )
4649 end
4750
@@ -61,45 +64,41 @@ def success?
6164 #
6265 def in_response_to
6366 @in_response_to ||= begin
64- node = REXML ::XPath . first (
65- document ,
67+ node = document . at_xpath (
6668 "/p:LogoutResponse" ,
6769 { "p" => PROTOCOL }
6870 )
69- node . nil? ? nil : node . attributes [ 'InResponseTo' ]
71+ node . nil? ? nil : node [ 'InResponseTo' ]
7072 end
7173 end
7274
7375 # @return [String] Gets the Issuer from the Logout Response.
7476 #
7577 def issuer
7678 @issuer ||= begin
77- node = REXML ::XPath . first (
78- document ,
79+ document . at_xpath (
7980 "/p:LogoutResponse/a:Issuer" ,
8081 { "p" => PROTOCOL , "a" => ASSERTION }
81- )
82- Utils . element_text ( node )
82+ ) &.content
8383 end
8484 end
8585
8686 # @return [String] Gets the StatusCode from a Logout Response.
8787 #
8888 def status_code
8989 @status_code ||= begin
90- node = REXML :: XPath . first ( document , "/p:LogoutResponse/p:Status/p:StatusCode" , { "p" => PROTOCOL } )
91- node . nil? ? nil : node . attributes [ " Value" ]
90+ node = document . at_xpath ( "/p:LogoutResponse/p:Status/p:StatusCode" , { "p" => PROTOCOL } )
91+ node . nil? ? nil : node [ ' Value' ]
9292 end
9393 end
9494
9595 def status_message
9696 @status_message ||= begin
97- node = REXML ::XPath . first (
98- document ,
97+ node = document . at_xpath (
9998 "/p:LogoutResponse/p:Status/p:StatusMessage" ,
10099 { "p" => PROTOCOL }
101100 )
102- Utils . element_text ( node )
101+ node &. content
103102 end
104103 end
105104
@@ -148,8 +147,7 @@ def validate_success_status
148147 # @raise [ValidationError] if soft == false and validation fails
149148 #
150149 def validate_structure
151- check_malformed_doc = check_malformed_doc? ( settings )
152- unless valid_saml? ( document , soft , check_malformed_doc : check_malformed_doc )
150+ unless valid_saml? ( document , soft )
153151 return append_error ( "Invalid SAML Logout Response. Not match the saml-schema-protocol-2.0.xsd" )
154152 end
155153
@@ -271,4 +269,4 @@ def validate_signature
271269 true
272270 end
273271 end
274- end
272+ end
0 commit comments