Class: SatMx::Signer Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sat_mx/signer.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document:, private_key:) ⇒ Signer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Signer.



11
12
13
14
# File 'lib/sat_mx/signer.rb', line 11

def initialize(document:, private_key:)
  @unsigned_document = Xmldsig::SignedDocument.new(document)
  @private_key = private_key
end

Class Method Details

.sign(document:, private_key:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
# File 'lib/sat_mx/signer.rb', line 7

def self.sign(document:, private_key:)
  new(document:, private_key:).sign
end

Instance Method Details

#signObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
19
20
# File 'lib/sat_mx/signer.rb', line 16

def sign
  unsigned_document.sign do |data|
    private_key.sign(OpenSSL::Digest.new("SHA1"), data)
  end
end