Class: Spid::Saml2::Utils::QueryParamsSigner
- Inherits:
-
Object
- Object
- Spid::Saml2::Utils::QueryParamsSigner
- Includes:
- Spid::Saml2::Utils
- Defined in:
- lib/spid/saml2/utils/query_params_signer.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#private_key ⇒ Object
readonly
Returns the value of attribute private_key.
-
#relay_state ⇒ Object
readonly
Returns the value of attribute relay_state.
-
#saml_message ⇒ Object
readonly
Returns the value of attribute saml_message.
-
#signature_method ⇒ Object
readonly
Returns the value of attribute signature_method.
Instance Method Summary collapse
- #escaped_signed_query_string ⇒ Object
-
#initialize(saml_message:, private_key:, signature_method:, relay_state: nil) ⇒ QueryParamsSigner
constructor
A new instance of QueryParamsSigner.
- #params_for_signature ⇒ Object
- #raw_signature ⇒ Object
- #signature ⇒ Object
- #signature_algorithm ⇒ Object
- #signed_query_params ⇒ Object
Methods included from Spid::Saml2::Utils
#certificate_from_encoded_der, #decode, #decode_and_inflate, #deflate, #deflate_and_encode, #encode, #escaped_params, #escaped_query_string, #inflate, #query_param, #query_params, #query_string
Constructor Details
#initialize(saml_message:, private_key:, signature_method:, relay_state: nil) ⇒ QueryParamsSigner
Returns a new instance of QueryParamsSigner.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/spid/saml2/utils/query_params_signer.rb', line 16 def initialize( saml_message:, private_key:, signature_method:, relay_state: nil ) @saml_message = .delete("\n") @private_key = private_key @signature_method = signature_method @relay_state = relay_state end |
Instance Attribute Details
#private_key ⇒ Object (readonly)
Returns the value of attribute private_key.
12 13 14 |
# File 'lib/spid/saml2/utils/query_params_signer.rb', line 12 def private_key @private_key end |
#relay_state ⇒ Object (readonly)
Returns the value of attribute relay_state.
14 15 16 |
# File 'lib/spid/saml2/utils/query_params_signer.rb', line 14 def relay_state @relay_state end |
#saml_message ⇒ Object (readonly)
Returns the value of attribute saml_message.
11 12 13 |
# File 'lib/spid/saml2/utils/query_params_signer.rb', line 11 def @saml_message end |
#signature_method ⇒ Object (readonly)
Returns the value of attribute signature_method.
13 14 15 |
# File 'lib/spid/saml2/utils/query_params_signer.rb', line 13 def signature_method @signature_method end |
Instance Method Details
#escaped_signed_query_string ⇒ Object
45 46 47 48 |
# File 'lib/spid/saml2/utils/query_params_signer.rb', line 45 def escaped_signed_query_string @escaped_signed_query_string ||= escaped_query_string(signed_query_params) end |
#params_for_signature ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/spid/saml2/utils/query_params_signer.rb', line 60 def params_for_signature @params_for_signature ||= begin params = { "SAMLRequest" => deflate_and_encode(), "RelayState" => relay_state, "SigAlg" => signature_method } params.delete("RelayState") if params["RelayState"].nil? params end end |
#raw_signature ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/spid/saml2/utils/query_params_signer.rb', line 50 def raw_signature @raw_signature ||= begin private_key.sign( signature_algorithm, escaped_query_string(params_for_signature) ) end end |
#signature ⇒ Object
32 33 34 35 36 37 |
# File 'lib/spid/saml2/utils/query_params_signer.rb', line 32 def signature @signature ||= begin encode(raw_signature) end end |
#signature_algorithm ⇒ Object
28 29 30 |
# File 'lib/spid/saml2/utils/query_params_signer.rb', line 28 def signature_algorithm @signature_algorithm ||= Spid::SIGNATURE_ALGORITHMS[signature_method] end |
#signed_query_params ⇒ Object
39 40 41 42 43 |
# File 'lib/spid/saml2/utils/query_params_signer.rb', line 39 def signed_query_params params_for_signature.merge( "Signature" => signature ) end |