class Nfe::Helpers::Signer
Public Class Methods
new(certificate, private_key)
click to toggle source
# File lib/nfe/helpers/signer.rb, line 4 def initialize(certificate, private_key) @certificate = certificate @private_key = private_key end
Public Instance Methods
execute(objeto, id)
click to toggle source
# File lib/nfe/helpers/signer.rb, line 9 def execute(objeto, id) objeto.signature = Nfe::Models::Signature.new(id) document = Xmldsig::SignedDocument.new(objeto.to_xml) document.sign(@private_key, @certificate) objeto.signature.value = sign_value(document) objeto end
Private Instance Methods
sign_value(document)
click to toggle source
# File lib/nfe/helpers/signer.rb, line 18 def sign_value(document) signature = document.signatures.first.signature value = signature.children value.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML) end