Class: Xml::Kit::Signature

Inherits:
Object
  • Object
show all
Defined in:
lib/xml/kit/signature.rb

Overview

An implementation of the Signature element. www.w3.org/TR/xmldsig-core1/#sec-Signature

Since:

  • 0.1.0

Constant Summary collapse

SIGNATURE_METHODS =

Since:

  • 0.1.0

{
  SHA1: 'http://www.w3.org/2000/09/xmldsig#rsa-sha1',
  SHA224: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha224',
  SHA256: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',
  SHA384: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha384',
  SHA512: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512',
}.freeze
DIGEST_METHODS =

Since:

  • 0.1.0

{
  SHA1: 'http://www.w3.org/2000/09/xmldsig#SHA1',
  SHA224: 'http://www.w3.org/2001/04/xmldsig-more#sha224',
  SHA256: 'http://www.w3.org/2001/04/xmlenc#sha256',
  SHA384: 'http://www.w3.org/2001/04/xmldsig-more#sha384',
  SHA512: 'http://www.w3.org/2001/04/xmlenc#sha512',
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reference_id, signature_method: :SH256, digest_method: :SHA256, certificate:) ⇒ Signature

Returns a new instance of Signature.

Since:

  • 0.1.0



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/xml/kit/signature.rb', line 30

def initialize(
  reference_id,
  signature_method: :SH256,
  digest_method: :SHA256,
  certificate:
)
  @certificate = certificate
  @digest_method = DIGEST_METHODS[digest_method]
  @reference_id = reference_id
  @signature_method = SIGNATURE_METHODS[signature_method]
end

Instance Attribute Details

#certificateObject (readonly)

Since:

  • 0.1.0



25
26
27
# File 'lib/xml/kit/signature.rb', line 25

def certificate
  @certificate
end

#digest_methodObject (readonly)

Since:

  • 0.1.0



26
27
28
# File 'lib/xml/kit/signature.rb', line 26

def digest_method
  @digest_method
end

#reference_idObject (readonly)

Since:

  • 0.1.0



27
28
29
# File 'lib/xml/kit/signature.rb', line 27

def reference_id
  @reference_id
end

#signature_methodObject (readonly)

Since:

  • 0.1.0



28
29
30
# File 'lib/xml/kit/signature.rb', line 28

def signature_method
  @signature_method
end

Instance Method Details

#to_xml(xml: ::Builder::XmlMarkup.new) ⇒ Object

Since:

  • 0.1.0



42
43
44
# File 'lib/xml/kit/signature.rb', line 42

def to_xml(xml: ::Builder::XmlMarkup.new)
  ::Xml::Kit::Template.new(self).to_xml(xml: xml)
end