Class: WSDL::Security::Reference
- Inherits:
-
Object
- Object
- WSDL::Security::Reference
- Defined in:
- lib/wsdl/security/reference.rb
Overview
Represents a signed reference in an XML Digital Signature.
A Reference identifies an element to be signed and contains its computed digest value. References are collected during the signing process and included in the SignedInfo element.
Instance Attribute Summary collapse
-
#digest_value ⇒ String
readonly
Returns the Base64-encoded digest value.
-
#id ⇒ String
readonly
Returns the element ID (without the # prefix).
-
#inclusive_namespaces ⇒ Array<String>?
readonly
Returns the list of namespace prefixes for inclusive canonicalization.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Compares two references for equality.
-
#hash ⇒ Integer
Returns a hash code for the reference.
-
#inclusive_namespaces? ⇒ Boolean
Returns whether this reference has inclusive namespaces specified.
-
#initialize(id:, digest_value:, inclusive_namespaces: nil) ⇒ Reference
constructor
Creates a new Reference instance.
-
#prefix_list ⇒ String?
Returns the inclusive namespaces as a space-separated string.
-
#to_h ⇒ Hash
Returns a Hash representation of the reference.
-
#uri ⇒ String
Returns the URI reference for use in the Reference element.
Constructor Details
#initialize(id:, digest_value:, inclusive_namespaces: nil) ⇒ Reference
Creates a new Reference instance.
45 46 47 48 49 |
# File 'lib/wsdl/security/reference.rb', line 45 def initialize(id:, digest_value:, inclusive_namespaces: nil) @id = id @digest_value = digest_value @inclusive_namespaces = inclusive_namespaces end |
Instance Attribute Details
#digest_value ⇒ String (readonly)
Returns the Base64-encoded digest value.
33 34 35 |
# File 'lib/wsdl/security/reference.rb', line 33 def digest_value @digest_value end |
#id ⇒ String (readonly)
Returns the element ID (without the # prefix).
29 30 31 |
# File 'lib/wsdl/security/reference.rb', line 29 def id @id end |
#inclusive_namespaces ⇒ Array<String>? (readonly)
Returns the list of namespace prefixes for inclusive canonicalization.
37 38 39 |
# File 'lib/wsdl/security/reference.rb', line 37 def inclusive_namespaces @inclusive_namespaces end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Compares two references for equality.
97 98 99 100 101 102 103 |
# File 'lib/wsdl/security/reference.rb', line 97 def ==(other) return false unless other.is_a?(Reference) @id == other.id && @digest_value == other.digest_value && @inclusive_namespaces == other.inclusive_namespaces end |
#hash ⇒ Integer
Returns a hash code for the reference.
110 111 112 |
# File 'lib/wsdl/security/reference.rb', line 110 def hash [@id, @digest_value, @inclusive_namespaces].hash end |
#inclusive_namespaces? ⇒ Boolean
Returns whether this reference has inclusive namespaces specified.
63 64 65 |
# File 'lib/wsdl/security/reference.rb', line 63 def inclusive_namespaces? @inclusive_namespaces&.any? || false end |
#prefix_list ⇒ String?
Returns the inclusive namespaces as a space-separated string.
This is the format required for the PrefixList attribute in the InclusiveNamespaces element.
74 75 76 77 78 |
# File 'lib/wsdl/security/reference.rb', line 74 def prefix_list return nil unless inclusive_namespaces? @inclusive_namespaces.join(' ') end |
#to_h ⇒ Hash
Returns a Hash representation of the reference.
84 85 86 87 88 89 90 |
# File 'lib/wsdl/security/reference.rb', line 84 def to_h { id: @id, digest_value: @digest_value, inclusive_namespaces: @inclusive_namespaces } end |
#uri ⇒ String
Returns the URI reference for use in the Reference element.
55 56 57 |
# File 'lib/wsdl/security/reference.rb', line 55 def uri "##{@id}" end |