Class: WSDL::Security::SignatureOptions
- Inherits:
-
Object
- Object
- WSDL::Security::SignatureOptions
- Defined in:
- lib/wsdl/security/signature_options.rb
Overview
Value object encapsulating signature configuration options.
This class extracts and validates the various options that can be passed to Config#signature, providing a clean interface for accessing signature-related settings.
Constant Summary collapse
- DEFAULTS =
Default values for signature options
{ sign_timestamp: true, sign_addressing: false, explicit_namespace_prefixes: false, key_reference: Constants::KeyReference::BINARY_SECURITY_TOKEN, digest_algorithm: :sha256 }.freeze
Instance Attribute Summary collapse
-
#digest_algorithm ⇒ Symbol
readonly
The digest algorithm (:sha1, :sha256, :sha512).
-
#key_reference ⇒ Symbol
readonly
The key reference method.
Class Method Summary collapse
-
.from_hash(options) ⇒ SignatureOptions
Creates a SignatureOptions instance from a hash of options.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Compares two SignatureOptions for equality.
-
#explicit_namespace_prefixes? ⇒ Boolean
Returns whether explicit namespace prefixes should be used.
-
#hash ⇒ Integer
Returns a hash code for the options.
-
#initialize(**options) ⇒ SignatureOptions
constructor
Creates a new SignatureOptions instance.
-
#sign_addressing? ⇒ Boolean
Returns whether WS-Addressing headers should be signed.
-
#sign_timestamp? ⇒ Boolean
Returns whether the timestamp should be signed.
-
#to_h ⇒ Hash
Returns a Hash representation of the options.
Constructor Details
#initialize(**options) ⇒ SignatureOptions
Creates a new SignatureOptions instance.
47 48 49 50 51 52 53 |
# File 'lib/wsdl/security/signature_options.rb', line 47 def initialize(**) = [:sign_timestamp] @sign_addressing = [:sign_addressing] @explicit_namespace_prefixes = [:explicit_namespace_prefixes] @key_reference = [:key_reference] @digest_algorithm = [:digest_algorithm] end |
Instance Attribute Details
#digest_algorithm ⇒ Symbol (readonly)
Returns the digest algorithm (:sha1, :sha256, :sha512).
33 34 35 |
# File 'lib/wsdl/security/signature_options.rb', line 33 def digest_algorithm @digest_algorithm end |
#key_reference ⇒ Symbol (readonly)
Returns the key reference method.
36 37 38 |
# File 'lib/wsdl/security/signature_options.rb', line 36 def key_reference @key_reference end |
Class Method Details
.from_hash(options) ⇒ SignatureOptions
Creates a SignatureOptions instance from a hash of options.
This method applies default values for any missing options.
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/wsdl/security/signature_options.rb', line 62 def self.from_hash() new( sign_timestamp: .fetch(:sign_timestamp, DEFAULTS[:sign_timestamp]), sign_addressing: .fetch(:sign_addressing, DEFAULTS[:sign_addressing]), explicit_namespace_prefixes: .fetch(:explicit_namespace_prefixes, DEFAULTS[:explicit_namespace_prefixes]), key_reference: .fetch(:key_reference, DEFAULTS[:key_reference]), digest_algorithm: .fetch(:digest_algorithm, DEFAULTS[:digest_algorithm]) ) end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Compares two SignatureOptions for equality.
116 117 118 119 120 |
# File 'lib/wsdl/security/signature_options.rb', line 116 def ==(other) return false unless other.is_a?(SignatureOptions) to_h == other.to_h end |
#explicit_namespace_prefixes? ⇒ Boolean
Returns whether explicit namespace prefixes should be used.
93 94 95 |
# File 'lib/wsdl/security/signature_options.rb', line 93 def explicit_namespace_prefixes? @explicit_namespace_prefixes == true end |
#hash ⇒ Integer
Returns a hash code for the options.
127 128 129 |
# File 'lib/wsdl/security/signature_options.rb', line 127 def hash to_h.hash end |
#sign_addressing? ⇒ Boolean
Returns whether WS-Addressing headers should be signed.
85 86 87 |
# File 'lib/wsdl/security/signature_options.rb', line 85 def sign_addressing? @sign_addressing == true end |
#sign_timestamp? ⇒ Boolean
Returns whether the timestamp should be signed.
77 78 79 |
# File 'lib/wsdl/security/signature_options.rb', line 77 def == true end |
#to_h ⇒ Hash
Returns a Hash representation of the options.
101 102 103 104 105 106 107 108 109 |
# File 'lib/wsdl/security/signature_options.rb', line 101 def to_h { sign_timestamp: , sign_addressing: @sign_addressing, explicit_namespace_prefixes: @explicit_namespace_prefixes, key_reference: @key_reference, digest_algorithm: @digest_algorithm } end |