Class: SignedXml::C14NTransform

Inherits:
Object
  • Object
show all
Includes:
Nokogiri::XML
Defined in:
lib/signed_xml/c14n_transform.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315") ⇒ C14NTransform

Returns a new instance of C14NTransform.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/signed_xml/c14n_transform.rb', line 8

def initialize(method = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315")
  method, with_comments = method.split('#')
  @method = case method
            when "http://www.w3.org/TR/2001/REC-xml-c14n-20010315" then XML_C14N_1_0
            when "http://www.w3.org/2001/10/xml-exc-c14n" then XML_C14N_EXCLUSIVE_1_0
            when "http://www.w3.org/2006/12/xml-c14n11" then XML_C14N_1_1
            else raise ArgumentError, "unknown canonicalization method #{method}"
            end

  @with_comments = !!with_comments
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



5
6
7
# File 'lib/signed_xml/c14n_transform.rb', line 5

def method
  @method
end

#with_commentsObject (readonly)

Returns the value of attribute with_comments.



6
7
8
# File 'lib/signed_xml/c14n_transform.rb', line 6

def with_comments
  @with_comments
end

Instance Method Details

#apply(input) ⇒ Object

Raises:

  • (ArgumentError)


20
21
22
23
24
# File 'lib/signed_xml/c14n_transform.rb', line 20

def apply(input)
  raise ArgumentError, "input #{input.inspect}:#{input.class} is not canonicalizable" unless input.respond_to?(:canonicalize)

  input.canonicalize(method, nil, with_comments)
end