class RestPki::XmlSignatureFinisher
Public Class Methods
new(restpki_client)
click to toggle source
Calls superclass method
RestPki::SignatureFinisher::new
# File lib/rest_pki/xml_signature_finisher.rb, line 6 def initialize(restpki_client) super(restpki_client) @signed_xml_content = nil end
Public Instance Methods
finish()
click to toggle source
# File lib/rest_pki/xml_signature_finisher.rb, line 11 def finish if @token.to_s.blank? raise 'The token was not set' end if @signature.to_s.blank? response = @restpki_client.post("Api/XmlSignatures/#{@token}/Finalize", nil, 'xml_model') else request = { signature: @signature } response = @restpki_client.post("Api/XmlSignatures/#{@token}/SignedBytes", request, 'xml_model') end @signed_xml_content = Base64.decode64(response['signedXml']) @callback_argument = response['callbackArgument'] @certificate_info = response['certificate'] @done = true @signed_xml_content end
signed_xml_content()
click to toggle source
# File lib/rest_pki/xml_signature_finisher.rb, line 31 def signed_xml_content unless @done raise 'The field "signed_xml_content" can only be accessed after calling the finish method' end @signed_xml_content end
write_signed_xml(xml_path)
click to toggle source
# File lib/rest_pki/xml_signature_finisher.rb, line 39 def write_signed_xml(xml_path) unless @done raise 'The method write_signed_xml can only be called after calling the finish method' end file = File.open(xml_path, 'wb') file.write(@signed_xml_content) file.close nil # No value is returned. end