Sha256: 0929da32edd06329842fd10d43b1e160a4f3bf17cee17ac9c39309876eb4de04

Contents?: true

Size: 1.3 KB

Versions: 11

Compression:

Stored size: 1.3 KB

Contents

module Xml
  module Kit
    class Signature
      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

      attr_reader :certificate
      attr_reader :digest_method
      attr_reader :reference_id
      attr_reader :signature_method

      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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
xml-kit-0.1.11 lib/xml/kit/signature.rb
xml-kit-0.1.10 lib/xml/kit/signature.rb
xml-kit-0.1.9 lib/xml/kit/signature.rb
xml-kit-0.1.8 lib/xml/kit/signature.rb
xml-kit-0.1.7 lib/xml/kit/signature.rb
xml-kit-0.1.6 lib/xml/kit/signature.rb
xml-kit-0.1.5 lib/xml/kit/signature.rb
xml-kit-0.1.4 lib/xml/kit/signature.rb
xml-kit-0.1.3 lib/xml/kit/signature.rb
xml-kit-0.1.2 lib/xml/kit/signature.rb
xml-kit-0.1.1 lib/xml/kit/signature.rb