Class: Moxml::Signature::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/moxml/signature/parser.rb

Overview

Translates a Moxml::Document containing ds:Signature into a Model::Signature.

Robust against namespace prefix variations (ds:, dsig:, default ns).

Constant Summary collapse

DS =
{ "ds" => DSIG_NS }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context:) ⇒ Parser

Returns a new instance of Parser.



15
16
17
# File 'lib/moxml/signature/parser.rb', line 15

def initialize(context:)
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



13
14
15
# File 'lib/moxml/signature/parser.rb', line 13

def context
  @context
end

Instance Method Details

#parse(signature_element) ⇒ Object

signature_element: a Moxml::Element whose name is Signature in the xmldsig# namespace.



21
22
23
24
25
26
27
28
29
# File 'lib/moxml/signature/parser.rb', line 21

def parse(signature_element)
  Model::Signature.new(
    id: signature_element["Id"],
    signed_info: parse_signed_info(at_child(signature_element, "SignedInfo")),
    signature_value: parse_signature_value(at_child(signature_element, "SignatureValue")),
    key_info: parse_key_info(at_child(signature_element, "KeyInfo")),
    objects: [],
  )
end