Class: Xml::Kit::Signature

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

Constant Summary collapse

SIGNATURE_METHODS =
{
  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 =
{
  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.



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

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)

Returns the value of attribute certificate.



21
22
23
# File 'lib/xml/kit/signature.rb', line 21

def certificate
  @certificate
end

#digest_methodObject (readonly)

Returns the value of attribute digest_method.



22
23
24
# File 'lib/xml/kit/signature.rb', line 22

def digest_method
  @digest_method
end

#reference_idObject (readonly)

Returns the value of attribute reference_id.



23
24
25
# File 'lib/xml/kit/signature.rb', line 23

def reference_id
  @reference_id
end

#signature_methodObject (readonly)

Returns the value of attribute signature_method.



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

def signature_method
  @signature_method
end

Instance Method Details

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



33
34
35
# File 'lib/xml/kit/signature.rb', line 33

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