class Nfe::Models::Signature

Attributes

id[RW]
value[W]

Public Class Methods

namespace() click to toggle source
# File lib/nfe/models/signature.rb, line 17
def self.namespace
  "http://www.w3.org/2000/09/xmldsig#"
end
new(id = nil) click to toggle source
# File lib/nfe/models/signature.rb, line 13
def initialize(id = nil)
  @id = id
end

Public Instance Methods

parse!(xml) click to toggle source
# File lib/nfe/models/signature.rb, line 25
def parse!(xml)
  doc = Nokogiri::XML(xml)
  @value = doc.children.present? ? doc.root.children.to_xml : nil
end
value() click to toggle source
# File lib/nfe/models/signature.rb, line 21
def value
  @value || unsigned
end

Private Instance Methods

unsigned() click to toggle source
# File lib/nfe/models/signature.rb, line 31
def unsigned
  xml  = "<SignedInfo>"
  xml +=   "<CanonicalizationMethod Algorithm='http://www.w3.org/TR/2001/REC-xml-c14n-20010315'/>"
  xml +=   "<SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/>"
  xml +=   "<Reference URI='##{@id}'>"
  xml +=     "<Transforms>"
  xml +=       "<Transform Algorithm='http://www.w3.org/2000/09/xmldsig#enveloped-signature'/>"
  xml +=       "<Transform Algorithm='http://www.w3.org/TR/2001/REC-xml-c14n-20010315'/>"
  xml +=     "</Transforms>"
  xml +=     "<DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/>"
  xml +=     "<DigestValue></DigestValue>"
  xml +=   "</Reference>"
  xml += "</SignedInfo>"
  xml += "<SignatureValue></SignatureValue>"
  xml += "<KeyInfo>"
  xml +=   "<X509Data>"
  xml +=     "<X509Certificate></X509Certificate>"
  xml +=   "</X509Data>"
  xml += "</KeyInfo>"
end