Class: Net::HTTP::MessageSignatures::Signature
- Inherits:
-
Object
- Object
- Net::HTTP::MessageSignatures::Signature
- Includes:
- StructuredFieldValues
- Defined in:
- lib/net/http/message_signatures/signature.rb
Overview
An HTTP Message Signature with its covered components and parameters.
Defined Under Namespace
Classes: VerificationError
Instance Attribute Summary collapse
-
#algorithm ⇒ SignatureAlgorithm
writeonly
Signature algorithm which can be used without key material.
-
#covered_components ⇒ Hash{String, ParameterizedValue => String}
readonly
Map of covered components’ name (and optional params) and value.
-
#params ⇒ Hash{String => Object}
readonly
Map of signature parameters’ name and value.
-
#signature ⇒ String?
Signature value in binary.
Instance Method Summary collapse
-
#initialize(signature: nil, covered_components: {}, params: {}, algorithm: nil) ⇒ Signature
constructor
A new instance of Signature.
-
#verify! ⇒ Object
Verifies the signature.
Constructor Details
#initialize(signature: nil, covered_components: {}, params: {}, algorithm: nil) ⇒ Signature
Returns a new instance of Signature.
31 32 33 34 35 36 |
# File 'lib/net/http/message_signatures/signature.rb', line 31 def initialize(signature: nil, covered_components: {}, params: {}, algorithm: nil) @signature = signature @covered_components = covered_components @params = params @algorithm = algorithm end |
Instance Attribute Details
#algorithm=(value) ⇒ SignatureAlgorithm
Returns signature algorithm which can be used without key material.
24 25 26 |
# File 'lib/net/http/message_signatures/signature.rb', line 24 def algorithm=(value) @algorithm = value end |
#covered_components ⇒ Hash{String, ParameterizedValue => String} (readonly)
Returns map of covered components’ name (and optional params) and value.
20 21 22 |
# File 'lib/net/http/message_signatures/signature.rb', line 20 def covered_components @covered_components end |
#params ⇒ Hash{String => Object} (readonly)
Returns map of signature parameters’ name and value.
22 23 24 |
# File 'lib/net/http/message_signatures/signature.rb', line 22 def params @params end |
#signature ⇒ String?
Returns signature value in binary.
17 18 19 |
# File 'lib/net/http/message_signatures/signature.rb', line 17 def signature @signature end |
Instance Method Details
#verify! ⇒ Object
Verifies the signature. Will raise error if it is invalid.
42 43 44 45 46 |
# File 'lib/net/http/message_signatures/signature.rb', line 42 def verify! return if algorithm.verify(signature_base, signature) raise VerificationError, 'signature verification failed' end |