Class: RestPki::XmlSignatureFinisher
Instance Attribute Summary
#signature, #token
Instance Method Summary
collapse
#certificate_info, #get_callback_argument
Constructor Details
Returns a new instance of XmlSignatureFinisher.
6
7
8
9
|
# File 'lib/rest_pki/xml_signature_finisher.rb', line 6
def initialize(restpki_client)
super(restpki_client)
@signed_xml_content = nil
end
|
Instance Method Details
#finish ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# 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 ⇒ Object
31
32
33
34
35
36
37
|
# 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) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
|
# 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 end
|