@@ -38,7 +38,7 @@ class Response < SamlMessage
3838 AVAILABLE_OPTIONS = [
3939 :allowed_clock_drift , :check_duplicated_attributes , :matches_request_id , :settings , :skip_audience , :skip_authnstatement , :skip_conditions ,
4040 :skip_destination , :skip_recipient_check , :skip_subject_confirmation
41- ]
41+ ] . freeze
4242 # TODO: Update the comment on initialize to describe every option
4343
4444 # Constructs the SAML Response. A Response Object that is an extension of the SamlMessage class.
@@ -71,6 +71,8 @@ def initialize(response, options = {})
7171 if assertion_encrypted?
7272 @decrypted_document = generate_decrypted_document
7373 end
74+
75+ super ( )
7476 end
7577
7678 # Validates the SAML Response with the default values (soft = true)
@@ -93,7 +95,7 @@ def name_id
9395 #
9496 def name_id_format
9597 @name_id_format ||=
96- if name_id_node && name_id_node . attribute ( "Format" )
98+ if name_id_node & .attribute ( "Format" )
9799 name_id_node . attribute ( "Format" ) . value
98100 end
99101 end
@@ -104,7 +106,7 @@ def name_id_format
104106 #
105107 def name_id_spnamequalifier
106108 @name_id_spnamequalifier ||=
107- if name_id_node && name_id_node . attribute ( "SPNameQualifier" )
109+ if name_id_node & .attribute ( "SPNameQualifier" )
108110 name_id_node . attribute ( "SPNameQualifier" ) . value
109111 end
110112 end
@@ -113,7 +115,7 @@ def name_id_spnamequalifier
113115 #
114116 def name_id_namequalifier
115117 @name_id_namequalifier ||=
116- if name_id_node && name_id_node . attribute ( "NameQualifier" )
118+ if name_id_node & .attribute ( "NameQualifier" )
117119 name_id_node . attribute ( "NameQualifier" ) . value
118120 end
119121 end
@@ -165,11 +167,11 @@ def attributes
165167 raise ValidationError . new ( "Found an Attribute element with duplicated Name" )
166168 end
167169
168- values = node . elements . collect { |e |
169- if ( e . elements . nil? || e . elements . size == 0 )
170+ values = node . elements . collect do |e |
171+ if e . elements . nil? || e . elements . size == 0
170172 # SAMLCore requires that nil AttributeValues MUST contain xsi:nil XML attribute set to "true" or "1"
171173 # otherwise the value is to be regarded as empty.
172- [ " true" , "1" ] . include? ( e . attributes [ 'xsi:nil' ] ) ? nil : Utils . element_text ( e )
174+ %w[ true 1 ] . include? ( e . attributes [ 'xsi:nil' ] ) ? nil : Utils . element_text ( e )
173175 # explicitly support saml2:NameID with saml2:NameQualifier if supplied in attributes
174176 # this is useful for allowing eduPersonTargetedId to be passed as an opaque identifier to use to
175177 # identify the subject in an SP rather than email or other less opaque attributes
@@ -180,7 +182,7 @@ def attributes
180182 "#{ base_path } #{ Utils . element_text ( n ) } "
181183 end
182184 end
183- }
185+ end
184186
185187 attributes . add ( name , values . flatten )
186188 end
@@ -218,7 +220,7 @@ def status_code
218220 )
219221 if nodes . size == 1
220222 node = nodes [ 0 ]
221- code = node . attributes [ "Value" ] if node && node . attributes
223+ code = node . attributes [ "Value" ] if node & .attributes
222224
223225 unless code == "urn:oasis:names:tc:SAML:2.0:status:Success"
224226 nodes = REXML ::XPath . match (
@@ -348,7 +350,7 @@ def allowed_clock_drift
348350 # @return [Boolean] True if the SAML Response contains an EncryptedAssertion element
349351 #
350352 def assertion_encrypted?
351- ! REXML ::XPath . first (
353+ !REXML ::XPath . first (
352354 document ,
353355 "(/p:Response/EncryptedAssertion/)|(/p:Response/a:EncryptedAssertion/)" ,
354356 { "p" => PROTOCOL , "a" => ASSERTION }
@@ -622,7 +624,7 @@ def validate_audience
622624 end
623625
624626 unless audiences . include? settings . sp_entity_id
625- s = audiences . count > 1 ? 's' : '' ;
627+ s = audiences . count > 1 ? 's' : ''
626628 error_msg = "Invalid Audience#{ s } . The audience#{ s } #{ audiences . join ( ',' ) } , did not match the expected audience #{ settings . sp_entity_id } "
627629 return append_error ( error_msg )
628630 end
@@ -792,7 +794,7 @@ def validate_subject_confirmation
792794 break
793795 end
794796
795- if ! valid_subject_confirmation
797+ unless valid_subject_confirmation
796798 error_msg = "A valid SubjectConfirmation was not found on this Response"
797799 return append_error ( error_msg )
798800 end
@@ -895,7 +897,6 @@ def validate_signature
895897 @errors = old_errors
896898 break
897899 end
898-
899900 end
900901 if expired
901902 error_msg = "IdP x509 certificate expired"
@@ -935,13 +936,13 @@ def xpath_first_from_signed_assertion(subelt=nil)
935936 "/p:Response/a:Assertion[@ID=$id]#{ subelt } " ,
936937 { "p" => PROTOCOL , "a" => ASSERTION } ,
937938 { 'id' => doc . signed_element_id }
938- )
939+ )
939940 node ||= REXML ::XPath . first (
940941 doc ,
941942 "/p:Response[@ID=$id]/a:Assertion#{ subelt } " ,
942943 { "p" => PROTOCOL , "a" => ASSERTION } ,
943944 { 'id' => doc . signed_element_id }
944- )
945+ )
945946 node
946947 end
947948
@@ -957,13 +958,13 @@ def xpath_from_signed_assertion(subelt=nil)
957958 "/p:Response/a:Assertion[@ID=$id]#{ subelt } " ,
958959 { "p" => PROTOCOL , "a" => ASSERTION } ,
959960 { 'id' => doc . signed_element_id }
960- )
961- node . concat ( REXML ::XPath . match (
961+ )
962+ node . concat ( REXML ::XPath . match (
962963 doc ,
963964 "/p:Response[@ID=$id]/a:Assertion#{ subelt } " ,
964965 { "p" => PROTOCOL , "a" => ASSERTION } ,
965966 { 'id' => doc . signed_element_id }
966- ) )
967+ ) )
967968 end
968969
969970 # Generates the decrypted_document
0 commit comments