Class: Moxml::Signature::Algorithms::EnvelopedSignatureTransform

Inherits:
TransformBase
  • Object
show all
Defined in:
lib/moxml/signature/algorithms/enveloped_signature_transform.rb

Overview

Enveloped Signature Transform (W3C §6.6.4).

Removes the containing ds:Signature element from the node-set so the signature does not include itself in its own digest calculation.

Semantics during signing: signature_element is nil (the Signature has not been attached to the document yet), so the transform is a no-op — the document contains no Signature to exclude.

Semantics during verification: signature_element is the Signature element being verified. The transform detaches it (and its descendants) from a deep copy of the input so the canonicalizer walks a tree without the Signature.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TransformBase

identifier, #initialize

Constructor Details

This class inherits a constructor from Moxml::Signature::Algorithms::TransformBase

Class Method Details

.input_typeObject



22
# File 'lib/moxml/signature/algorithms/enveloped_signature_transform.rb', line 22

def self.input_type; :nodeset; end

.output_typeObject



23
# File 'lib/moxml/signature/algorithms/enveloped_signature_transform.rb', line 23

def self.output_type; :nodeset; end

Instance Method Details

#transform(input) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/moxml/signature/algorithms/enveloped_signature_transform.rb', line 25

def transform(input)
  return input if @signature_element.nil?

  # If the signature is not within the input subtree, no-op.
  return input unless signature_within?(input)

  working_copy = deep_copy(input)
  remove_signature_within(working_copy)
  working_copy
end