class RestPki::PadesSignatureFinisher
Public Class Methods
new(restpki_client)
click to toggle source
Calls superclass method
# File lib/rest_pki/pades_signature_finisher.rb, line 5 def initialize(restpki_client) super(restpki_client) @signed_pdf_content = nil end
Public Instance Methods
finish()
click to toggle source
# File lib/rest_pki/pades_signature_finisher.rb, line 10 def finish if @token.to_s.blank? raise 'The token was not set' end if @signature.to_s.blank? response = @restpki_client.post("Api/PadesSignatures/#{@token}/Finalize", nil, 'pades_model') else request = { signature: @signature } response = @restpki_client.post("Api/PadesSignatures/#{@token}/SignedBytes", request, 'pades_model') end @signed_pdf_content = Base64.decode64(response['signedPdf']) @callback_argument = response['callbackArgument'] @certificate_info = response['certificate'] @done = true @signed_pdf_content end
signed_pdf_content()
click to toggle source
# File lib/rest_pki/pades_signature_finisher.rb, line 30 def signed_pdf_content unless @done raise 'The field "signed_pdf_content" can only be accessed after calling the finish method' end @signed_pdf_content end
write_signed_pdf(pdf_path)
click to toggle source
# File lib/rest_pki/pades_signature_finisher.rb, line 38 def write_signed_pdf(pdf_path) unless @done raise 'The method write_signed_pdf can only be called after calling the finish method' end file = File.open(pdf_path, 'wb') file.write(@signed_pdf_content) file.close nil # No value is returned. end