Sha256: 3ab6783d5ff5f1d488abac82464ef072d45c0c98a2dcdcc0353e09abd6c6ec03

Contents?: true

Size: 936 Bytes

Versions: 6

Compression:

Stored size: 936 Bytes

Contents

module Xmldsig
  class Canonicalizer
    attr_accessor :node, :method, :inclusive_namespaces, :with_comments

    def initialize(node, method = nil, inclusive_namespaces = [], with_comments = false)
      @node = node
      @method = method
      @inclusive_namespaces = inclusive_namespaces
      @with_comments = with_comments
    end

    def canonicalize
      node.canonicalize(mode(method), inclusive_namespaces, with_comments)
    end

    private

    def mode(method)
      case method
        when "http://www.w3.org/2001/10/xml-exc-c14n#",
             "http://www.w3.org/2001/10/xml-exc-c14n#WithComments"
          Nokogiri::XML::XML_C14N_EXCLUSIVE_1_0
        when "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
          Nokogiri::XML::XML_C14N_1_0
        when "http://www.w3.org/2006/12/xml-c14n11"
          Nokogiri::XML::XML_C14N_1_1
        else
          Nokogiri::XML::XML_C14N_1_0
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
xmldsig-0.4.1 lib/xmldsig/canonicalizer.rb
xmldsig-0.4.0 lib/xmldsig/canonicalizer.rb
xmldsig-0.3.2 lib/xmldsig/canonicalizer.rb
xmldsig-0.3.1 lib/xmldsig/canonicalizer.rb
xmldsig-0.3.0 lib/xmldsig/canonicalizer.rb
xmldsig-0.2.10 lib/xmldsig/canonicalizer.rb