pki_express 1.3.0 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +2 -2
- data/.github/workflows/test.yml +22 -0
- data/.gitignore +27 -27
- data/.rspec +1 -0
- data/CHANGELOG.md +19 -12
- data/Gemfile +9 -4
- data/README.md +24 -24
- data/Rakefile +7 -1
- data/lib/pki_express/auth_complete_result.rb +21 -21
- data/lib/pki_express/auth_start_result.rb +76 -76
- data/lib/pki_express/authentication.rb +284 -284
- data/lib/pki_express/base_signer.rb +54 -54
- data/lib/pki_express/cades_signature.rb +89 -89
- data/lib/pki_express/cades_signature_starter.rb +242 -242
- data/lib/pki_express/check_service_result.rb +15 -15
- data/lib/pki_express/command_error.rb +13 -13
- data/lib/pki_express/commands.rb +24 -24
- data/lib/pki_express/digest_algorithm.rb +118 -118
- data/lib/pki_express/digest_algorithm_and_value.rb +30 -30
- data/lib/pki_express/discovery_service_result.rb +25 -25
- data/lib/pki_express/enum.rb +9 -9
- data/lib/pki_express/error_codes.rb +46 -46
- data/lib/pki_express/installation_not_found_error.rb +8 -8
- data/lib/pki_express/name.rb +47 -47
- data/lib/pki_express/oids.rb +30 -30
- data/lib/pki_express/pades_certification_level.rb +7 -7
- data/lib/pki_express/pades_horizontal_align.rb +9 -9
- data/lib/pki_express/pades_measurement_units.rb +8 -8
- data/lib/pki_express/pades_page_optimization.rb +50 -50
- data/lib/pki_express/pades_page_orientation.rb +9 -9
- data/lib/pki_express/pades_paper_size.rb +21 -21
- data/lib/pki_express/pades_signature.rb +16 -16
- data/lib/pki_express/pades_signature_explorer.rb +30 -30
- data/lib/pki_express/pades_signature_starter.rb +251 -251
- data/lib/pki_express/pades_signer.rb +274 -274
- data/lib/pki_express/pades_signer_info.rb +9 -9
- data/lib/pki_express/pades_size.rb +17 -17
- data/lib/pki_express/pades_text_horizontal_align.rb +8 -8
- data/lib/pki_express/pades_vertical_align.rb +9 -9
- data/lib/pki_express/pades_visual_auto_positioning.rb +21 -21
- data/lib/pki_express/pades_visual_image.rb +51 -51
- data/lib/pki_express/pades_visual_manual_positioning.rb +16 -16
- data/lib/pki_express/pades_visual_positioning.rb +27 -27
- data/lib/pki_express/pades_visual_rectangle.rb +74 -74
- data/lib/pki_express/pades_visual_representation.rb +22 -22
- data/lib/pki_express/pades_visual_text.rb +35 -35
- data/lib/pki_express/pk_algorithms.rb +157 -157
- data/lib/pki_express/pk_certificate.rb +61 -61
- data/lib/pki_express/pki_brazil_certificate_fields.rb +57 -57
- data/lib/pki_express/pki_brazil_certificate_types.rb +19 -19
- data/lib/pki_express/pki_express_config.rb +39 -26
- data/lib/pki_express/pki_express_operator.rb +240 -234
- data/lib/pki_express/pki_italy_certificate_fields.rb +15 -15
- data/lib/pki_express/pki_italy_certificate_types.rb +11 -11
- data/lib/pki_express/signature_algorithm_and_value.rb +34 -34
- data/lib/pki_express/signature_explorer.rb +74 -74
- data/lib/pki_express/signature_finisher.rb +314 -314
- data/lib/pki_express/signature_policy_identifier.rb +20 -20
- data/lib/pki_express/signature_start_result.rb +12 -12
- data/lib/pki_express/signature_starter.rb +116 -116
- data/lib/pki_express/signer.rb +151 -151
- data/lib/pki_express/standard_signature_policies.rb +58 -58
- data/lib/pki_express/timestamp_authority.rb +50 -50
- data/lib/pki_express/trust_service_auth_parameters.rb +20 -20
- data/lib/pki_express/trust_service_info.rb +37 -37
- data/lib/pki_express/trust_service_manager.rb +258 -258
- data/lib/pki_express/trust_service_session_result.rb +29 -29
- data/lib/pki_express/trust_service_session_types.rb +7 -7
- data/lib/pki_express/tsa_authentication_type.rb +14 -14
- data/lib/pki_express/validation_error.rb +8 -8
- data/lib/pki_express/validation_item.rb +43 -43
- data/lib/pki_express/validation_item_types.rb +103 -103
- data/lib/pki_express/validation_results.rb +120 -120
- data/lib/pki_express/version.rb +3 -3
- data/lib/pki_express/version_manager.rb +20 -20
- data/lib/pki_express.rb +69 -69
- data/pki_express.gemspec +26 -26
- data/spec/pki_express/pki_express_config_spec.rb +73 -0
- data/spec/pki_express/pki_express_operator_spec.rb +31 -0
- data/spec/spec_helper.rb +13 -0
- metadata +17 -9
@@ -1,315 +1,315 @@
|
|
1
|
-
module PkiExpress
|
2
|
-
class SignatureFinisher < PkiExpressOperator
|
3
|
-
attr_reader :transfer_file_id, :output_file_path
|
4
|
-
|
5
|
-
def initialize(config=PkiExpressConfig.new)
|
6
|
-
super(config)
|
7
|
-
@file_to_sign_path = nil
|
8
|
-
@transfer_file_id = nil
|
9
|
-
@data_file_path = nil
|
10
|
-
@output_file_path = nil
|
11
|
-
@signature = nil
|
12
|
-
end
|
13
|
-
|
14
|
-
# region The "file_to_sign" accessors
|
15
|
-
|
16
|
-
def file_to_sign
|
17
|
-
_get_file_to_sign
|
18
|
-
end
|
19
|
-
|
20
|
-
def _get_file_to_sign
|
21
|
-
unless @file_to_sign_path
|
22
|
-
return nil
|
23
|
-
end
|
24
|
-
|
25
|
-
File.read(@file_to_sign_path)
|
26
|
-
end
|
27
|
-
private :_get_file_to_sign
|
28
|
-
|
29
|
-
def file_to_sign=(content_raw)
|
30
|
-
_set_file_to_sign(content_raw)
|
31
|
-
end
|
32
|
-
|
33
|
-
def _set_file_to_sign(content_raw)
|
34
|
-
unless content_raw
|
35
|
-
raise 'The provided "file_to_sign" is not valid'
|
36
|
-
end
|
37
|
-
|
38
|
-
temp_file_path = self.create_temp_file
|
39
|
-
File.open(temp_file_path, 'wb') do |f|
|
40
|
-
f.write(content_raw)
|
41
|
-
end
|
42
|
-
@file_to_sign_path = temp_file_path
|
43
|
-
end
|
44
|
-
private :_set_file_to_sign
|
45
|
-
|
46
|
-
def file_to_sign_base64
|
47
|
-
_get_file_to_sign_base64
|
48
|
-
end
|
49
|
-
|
50
|
-
def _get_file_to_sign_base64
|
51
|
-
unless @file_to_sign_path
|
52
|
-
return nil
|
53
|
-
end
|
54
|
-
|
55
|
-
content = File.read(@file_to_sign_path)
|
56
|
-
Base64.encode64(content)
|
57
|
-
end
|
58
|
-
private :_get_file_to_sign_base64
|
59
|
-
|
60
|
-
def file_to_sign_base64=(content_base64)
|
61
|
-
_set_file_to_sign_base64(content_base64)
|
62
|
-
end
|
63
|
-
|
64
|
-
def _set_file_to_sign_base64(content_base64)
|
65
|
-
unless content_base64
|
66
|
-
raise 'The provided "file_to_sign_base64" is not valid'
|
67
|
-
end
|
68
|
-
|
69
|
-
begin
|
70
|
-
content_raw = Base64.decode64(content_base64)
|
71
|
-
rescue Error
|
72
|
-
raise 'The provided "file_to_sign_base64" is not Base64-encoded'
|
73
|
-
end
|
74
|
-
|
75
|
-
_set_file_to_sign(content_raw)
|
76
|
-
end
|
77
|
-
private :_set_file_to_sign_base64
|
78
|
-
|
79
|
-
def file_to_sign_path
|
80
|
-
_get_file_to_sign_path
|
81
|
-
end
|
82
|
-
|
83
|
-
def _get_file_to_sign_path
|
84
|
-
@file_to_sign_path
|
85
|
-
end
|
86
|
-
private :_get_file_to_sign_path
|
87
|
-
|
88
|
-
def file_to_sign_path=(path)
|
89
|
-
_set_file_to_sign_path(path)
|
90
|
-
end
|
91
|
-
|
92
|
-
def _set_file_to_sign_path(path)
|
93
|
-
unless path
|
94
|
-
raise 'The provided "file_to_sign_path" is not valid'
|
95
|
-
end
|
96
|
-
unless File.exists?(path)
|
97
|
-
raise 'The provided "file_to_sign_path" does not exist'
|
98
|
-
end
|
99
|
-
|
100
|
-
@file_to_sign_path = path
|
101
|
-
end
|
102
|
-
private :_set_file_to_sign_path
|
103
|
-
|
104
|
-
# endregion
|
105
|
-
|
106
|
-
# region The "data_file" accessors
|
107
|
-
|
108
|
-
def data_file
|
109
|
-
_get_data_file
|
110
|
-
end
|
111
|
-
|
112
|
-
def _get_data_file
|
113
|
-
unless @data_file_path
|
114
|
-
return nil
|
115
|
-
end
|
116
|
-
|
117
|
-
File.read(@data_file_path)
|
118
|
-
end
|
119
|
-
private :_get_data_file
|
120
|
-
|
121
|
-
def data_file=(content_raw)
|
122
|
-
_set_data_file(content_raw)
|
123
|
-
end
|
124
|
-
|
125
|
-
def _set_data_file(content_raw)
|
126
|
-
unless content_raw
|
127
|
-
raise 'The provided "data_file" is not valid'
|
128
|
-
end
|
129
|
-
|
130
|
-
temp_file_path = self.create_temp_file
|
131
|
-
File.open(temp_file_path, 'wb') do |f|
|
132
|
-
f.write(content_raw)
|
133
|
-
end
|
134
|
-
@data_file_path = temp_file_path
|
135
|
-
end
|
136
|
-
private :_set_data_file
|
137
|
-
|
138
|
-
def data_file_base64
|
139
|
-
_get_data_file_base64
|
140
|
-
end
|
141
|
-
|
142
|
-
def _get_data_file_base64
|
143
|
-
unless @data_file_path
|
144
|
-
return nil
|
145
|
-
end
|
146
|
-
|
147
|
-
content = File.read(@data_file_path)
|
148
|
-
Base64.encode64(content)
|
149
|
-
end
|
150
|
-
private :_get_data_file_base64
|
151
|
-
|
152
|
-
def data_file_base64=(content_base64)
|
153
|
-
_set_data_file_base64(content_base64)
|
154
|
-
end
|
155
|
-
|
156
|
-
def _set_data_file_base64(content_base64)
|
157
|
-
unless content_base64
|
158
|
-
raise 'The provided "data_file_base64" is not valid'
|
159
|
-
end
|
160
|
-
|
161
|
-
begin
|
162
|
-
content_raw = Base64.decode64(content_base64)
|
163
|
-
rescue Error
|
164
|
-
raise 'The provided "data_file_base64" is not Base64-encoded'
|
165
|
-
end
|
166
|
-
|
167
|
-
_set_data_file(content_raw)
|
168
|
-
end
|
169
|
-
private :_set_data_file_base64
|
170
|
-
|
171
|
-
def data_file_path
|
172
|
-
_get_data_file_path
|
173
|
-
end
|
174
|
-
|
175
|
-
def _get_data_file_path
|
176
|
-
@data_file_path
|
177
|
-
end
|
178
|
-
private :_get_data_file_path
|
179
|
-
|
180
|
-
def data_file_path=(path)
|
181
|
-
_set_data_file_path(path)
|
182
|
-
end
|
183
|
-
|
184
|
-
def _set_data_file_path(path)
|
185
|
-
unless path
|
186
|
-
raise 'The provided "data_file_path" is not valid'
|
187
|
-
end
|
188
|
-
unless File.exists?(path)
|
189
|
-
raise 'The provided "data_file_path" does not exist'
|
190
|
-
end
|
191
|
-
|
192
|
-
@data_file_path = path
|
193
|
-
end
|
194
|
-
private :_set_data_file_path
|
195
|
-
|
196
|
-
# endregion
|
197
|
-
|
198
|
-
# region The "signature" accessors
|
199
|
-
|
200
|
-
def signature
|
201
|
-
_get_signature
|
202
|
-
end
|
203
|
-
|
204
|
-
def _get_signature
|
205
|
-
@signature
|
206
|
-
end
|
207
|
-
private :_get_signature
|
208
|
-
|
209
|
-
def signature=(content_raw)
|
210
|
-
_set_signature(content_raw)
|
211
|
-
end
|
212
|
-
|
213
|
-
def _set_signature(content_raw)
|
214
|
-
unless content_raw
|
215
|
-
raise 'The provided "signature" is not valid'
|
216
|
-
end
|
217
|
-
@signature = content_raw
|
218
|
-
end
|
219
|
-
private :_set_signature
|
220
|
-
|
221
|
-
def signature_base64
|
222
|
-
_get_signature_base64
|
223
|
-
end
|
224
|
-
|
225
|
-
def _get_signature_base64
|
226
|
-
unless @signature
|
227
|
-
return nil
|
228
|
-
end
|
229
|
-
Base64.encode64(@signature)
|
230
|
-
end
|
231
|
-
private :_get_signature_base64
|
232
|
-
|
233
|
-
def signature_base64=(content_base64)
|
234
|
-
_set_signature_base64(content_base64)
|
235
|
-
end
|
236
|
-
|
237
|
-
def _set_signature_base64(content_base64)
|
238
|
-
unless content_base64
|
239
|
-
raise 'The provided "signature_base64" is not valid'
|
240
|
-
end
|
241
|
-
|
242
|
-
begin
|
243
|
-
content_raw = Base64.decode64(content_base64)
|
244
|
-
rescue Error
|
245
|
-
raise 'The provided "signature_base64" is not Base64-encoded'
|
246
|
-
end
|
247
|
-
|
248
|
-
_set_signature(content_raw)
|
249
|
-
end
|
250
|
-
private :_set_signature_base64
|
251
|
-
|
252
|
-
# endregion
|
253
|
-
|
254
|
-
def transfer_file_id=(value)
|
255
|
-
unless value
|
256
|
-
raise 'The provided "transfer_file_id" is not valid'
|
257
|
-
end
|
258
|
-
unless File.exist?(File.expand_path(value, @config.transfer_data_folder))
|
259
|
-
raise 'The provided "transfer_file_id" does not exist'
|
260
|
-
end
|
261
|
-
@transfer_file_id = value
|
262
|
-
end
|
263
|
-
|
264
|
-
def output_file_path=(value)
|
265
|
-
unless value
|
266
|
-
raise 'The provided "output_file_path" is not valid'
|
267
|
-
end
|
268
|
-
@output_file_path = value
|
269
|
-
end
|
270
|
-
|
271
|
-
def complete(get_cert=true)
|
272
|
-
unless @file_to_sign_path
|
273
|
-
raise 'The file to be signed was not set'
|
274
|
-
end
|
275
|
-
unless @transfer_file_id
|
276
|
-
raise 'The transfer data file was not set'
|
277
|
-
end
|
278
|
-
unless @signature
|
279
|
-
raise 'The signature was not set'
|
280
|
-
end
|
281
|
-
unless @output_file_path
|
282
|
-
raise 'The output destination was not set'
|
283
|
-
end
|
284
|
-
|
285
|
-
args = [
|
286
|
-
@file_to_sign_path,
|
287
|
-
File.expand_path(@transfer_file_id, @config.transfer_data_folder),
|
288
|
-
@signature,
|
289
|
-
@output_file_path,
|
290
|
-
]
|
291
|
-
|
292
|
-
if @data_file_path
|
293
|
-
args.append('--data-file')
|
294
|
-
args.append(@data_file_path)
|
295
|
-
end
|
296
|
-
|
297
|
-
if get_cert
|
298
|
-
# This operation can only be used on version greater than 1.8 of the
|
299
|
-
# PKI Express.
|
300
|
-
@version_manager.require_version('1.8')
|
301
|
-
|
302
|
-
# Invoke command.
|
303
|
-
result = invoke(Commands::COMPLETE_SIG, args)
|
304
|
-
|
305
|
-
# Parse output and return model.
|
306
|
-
model = parse_output(result)
|
307
|
-
return PKCertificate.new(model.fetch(:signer))
|
308
|
-
end
|
309
|
-
|
310
|
-
# Invoke command.
|
311
|
-
invoke(Commands::COMPLETE_SIG, args)
|
312
|
-
end
|
313
|
-
|
314
|
-
end
|
1
|
+
module PkiExpress
|
2
|
+
class SignatureFinisher < PkiExpressOperator
|
3
|
+
attr_reader :transfer_file_id, :output_file_path
|
4
|
+
|
5
|
+
def initialize(config=PkiExpressConfig.new)
|
6
|
+
super(config)
|
7
|
+
@file_to_sign_path = nil
|
8
|
+
@transfer_file_id = nil
|
9
|
+
@data_file_path = nil
|
10
|
+
@output_file_path = nil
|
11
|
+
@signature = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
# region The "file_to_sign" accessors
|
15
|
+
|
16
|
+
def file_to_sign
|
17
|
+
_get_file_to_sign
|
18
|
+
end
|
19
|
+
|
20
|
+
def _get_file_to_sign
|
21
|
+
unless @file_to_sign_path
|
22
|
+
return nil
|
23
|
+
end
|
24
|
+
|
25
|
+
File.read(@file_to_sign_path)
|
26
|
+
end
|
27
|
+
private :_get_file_to_sign
|
28
|
+
|
29
|
+
def file_to_sign=(content_raw)
|
30
|
+
_set_file_to_sign(content_raw)
|
31
|
+
end
|
32
|
+
|
33
|
+
def _set_file_to_sign(content_raw)
|
34
|
+
unless content_raw
|
35
|
+
raise 'The provided "file_to_sign" is not valid'
|
36
|
+
end
|
37
|
+
|
38
|
+
temp_file_path = self.create_temp_file
|
39
|
+
File.open(temp_file_path, 'wb') do |f|
|
40
|
+
f.write(content_raw)
|
41
|
+
end
|
42
|
+
@file_to_sign_path = temp_file_path
|
43
|
+
end
|
44
|
+
private :_set_file_to_sign
|
45
|
+
|
46
|
+
def file_to_sign_base64
|
47
|
+
_get_file_to_sign_base64
|
48
|
+
end
|
49
|
+
|
50
|
+
def _get_file_to_sign_base64
|
51
|
+
unless @file_to_sign_path
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
|
55
|
+
content = File.read(@file_to_sign_path)
|
56
|
+
Base64.encode64(content)
|
57
|
+
end
|
58
|
+
private :_get_file_to_sign_base64
|
59
|
+
|
60
|
+
def file_to_sign_base64=(content_base64)
|
61
|
+
_set_file_to_sign_base64(content_base64)
|
62
|
+
end
|
63
|
+
|
64
|
+
def _set_file_to_sign_base64(content_base64)
|
65
|
+
unless content_base64
|
66
|
+
raise 'The provided "file_to_sign_base64" is not valid'
|
67
|
+
end
|
68
|
+
|
69
|
+
begin
|
70
|
+
content_raw = Base64.decode64(content_base64)
|
71
|
+
rescue Error
|
72
|
+
raise 'The provided "file_to_sign_base64" is not Base64-encoded'
|
73
|
+
end
|
74
|
+
|
75
|
+
_set_file_to_sign(content_raw)
|
76
|
+
end
|
77
|
+
private :_set_file_to_sign_base64
|
78
|
+
|
79
|
+
def file_to_sign_path
|
80
|
+
_get_file_to_sign_path
|
81
|
+
end
|
82
|
+
|
83
|
+
def _get_file_to_sign_path
|
84
|
+
@file_to_sign_path
|
85
|
+
end
|
86
|
+
private :_get_file_to_sign_path
|
87
|
+
|
88
|
+
def file_to_sign_path=(path)
|
89
|
+
_set_file_to_sign_path(path)
|
90
|
+
end
|
91
|
+
|
92
|
+
def _set_file_to_sign_path(path)
|
93
|
+
unless path
|
94
|
+
raise 'The provided "file_to_sign_path" is not valid'
|
95
|
+
end
|
96
|
+
unless File.exists?(path)
|
97
|
+
raise 'The provided "file_to_sign_path" does not exist'
|
98
|
+
end
|
99
|
+
|
100
|
+
@file_to_sign_path = path
|
101
|
+
end
|
102
|
+
private :_set_file_to_sign_path
|
103
|
+
|
104
|
+
# endregion
|
105
|
+
|
106
|
+
# region The "data_file" accessors
|
107
|
+
|
108
|
+
def data_file
|
109
|
+
_get_data_file
|
110
|
+
end
|
111
|
+
|
112
|
+
def _get_data_file
|
113
|
+
unless @data_file_path
|
114
|
+
return nil
|
115
|
+
end
|
116
|
+
|
117
|
+
File.read(@data_file_path)
|
118
|
+
end
|
119
|
+
private :_get_data_file
|
120
|
+
|
121
|
+
def data_file=(content_raw)
|
122
|
+
_set_data_file(content_raw)
|
123
|
+
end
|
124
|
+
|
125
|
+
def _set_data_file(content_raw)
|
126
|
+
unless content_raw
|
127
|
+
raise 'The provided "data_file" is not valid'
|
128
|
+
end
|
129
|
+
|
130
|
+
temp_file_path = self.create_temp_file
|
131
|
+
File.open(temp_file_path, 'wb') do |f|
|
132
|
+
f.write(content_raw)
|
133
|
+
end
|
134
|
+
@data_file_path = temp_file_path
|
135
|
+
end
|
136
|
+
private :_set_data_file
|
137
|
+
|
138
|
+
def data_file_base64
|
139
|
+
_get_data_file_base64
|
140
|
+
end
|
141
|
+
|
142
|
+
def _get_data_file_base64
|
143
|
+
unless @data_file_path
|
144
|
+
return nil
|
145
|
+
end
|
146
|
+
|
147
|
+
content = File.read(@data_file_path)
|
148
|
+
Base64.encode64(content)
|
149
|
+
end
|
150
|
+
private :_get_data_file_base64
|
151
|
+
|
152
|
+
def data_file_base64=(content_base64)
|
153
|
+
_set_data_file_base64(content_base64)
|
154
|
+
end
|
155
|
+
|
156
|
+
def _set_data_file_base64(content_base64)
|
157
|
+
unless content_base64
|
158
|
+
raise 'The provided "data_file_base64" is not valid'
|
159
|
+
end
|
160
|
+
|
161
|
+
begin
|
162
|
+
content_raw = Base64.decode64(content_base64)
|
163
|
+
rescue Error
|
164
|
+
raise 'The provided "data_file_base64" is not Base64-encoded'
|
165
|
+
end
|
166
|
+
|
167
|
+
_set_data_file(content_raw)
|
168
|
+
end
|
169
|
+
private :_set_data_file_base64
|
170
|
+
|
171
|
+
def data_file_path
|
172
|
+
_get_data_file_path
|
173
|
+
end
|
174
|
+
|
175
|
+
def _get_data_file_path
|
176
|
+
@data_file_path
|
177
|
+
end
|
178
|
+
private :_get_data_file_path
|
179
|
+
|
180
|
+
def data_file_path=(path)
|
181
|
+
_set_data_file_path(path)
|
182
|
+
end
|
183
|
+
|
184
|
+
def _set_data_file_path(path)
|
185
|
+
unless path
|
186
|
+
raise 'The provided "data_file_path" is not valid'
|
187
|
+
end
|
188
|
+
unless File.exists?(path)
|
189
|
+
raise 'The provided "data_file_path" does not exist'
|
190
|
+
end
|
191
|
+
|
192
|
+
@data_file_path = path
|
193
|
+
end
|
194
|
+
private :_set_data_file_path
|
195
|
+
|
196
|
+
# endregion
|
197
|
+
|
198
|
+
# region The "signature" accessors
|
199
|
+
|
200
|
+
def signature
|
201
|
+
_get_signature
|
202
|
+
end
|
203
|
+
|
204
|
+
def _get_signature
|
205
|
+
@signature
|
206
|
+
end
|
207
|
+
private :_get_signature
|
208
|
+
|
209
|
+
def signature=(content_raw)
|
210
|
+
_set_signature(content_raw)
|
211
|
+
end
|
212
|
+
|
213
|
+
def _set_signature(content_raw)
|
214
|
+
unless content_raw
|
215
|
+
raise 'The provided "signature" is not valid'
|
216
|
+
end
|
217
|
+
@signature = content_raw
|
218
|
+
end
|
219
|
+
private :_set_signature
|
220
|
+
|
221
|
+
def signature_base64
|
222
|
+
_get_signature_base64
|
223
|
+
end
|
224
|
+
|
225
|
+
def _get_signature_base64
|
226
|
+
unless @signature
|
227
|
+
return nil
|
228
|
+
end
|
229
|
+
Base64.encode64(@signature)
|
230
|
+
end
|
231
|
+
private :_get_signature_base64
|
232
|
+
|
233
|
+
def signature_base64=(content_base64)
|
234
|
+
_set_signature_base64(content_base64)
|
235
|
+
end
|
236
|
+
|
237
|
+
def _set_signature_base64(content_base64)
|
238
|
+
unless content_base64
|
239
|
+
raise 'The provided "signature_base64" is not valid'
|
240
|
+
end
|
241
|
+
|
242
|
+
begin
|
243
|
+
content_raw = Base64.decode64(content_base64)
|
244
|
+
rescue Error
|
245
|
+
raise 'The provided "signature_base64" is not Base64-encoded'
|
246
|
+
end
|
247
|
+
|
248
|
+
_set_signature(content_raw)
|
249
|
+
end
|
250
|
+
private :_set_signature_base64
|
251
|
+
|
252
|
+
# endregion
|
253
|
+
|
254
|
+
def transfer_file_id=(value)
|
255
|
+
unless value
|
256
|
+
raise 'The provided "transfer_file_id" is not valid'
|
257
|
+
end
|
258
|
+
unless File.exist?(File.expand_path(value, @config.transfer_data_folder))
|
259
|
+
raise 'The provided "transfer_file_id" does not exist'
|
260
|
+
end
|
261
|
+
@transfer_file_id = value
|
262
|
+
end
|
263
|
+
|
264
|
+
def output_file_path=(value)
|
265
|
+
unless value
|
266
|
+
raise 'The provided "output_file_path" is not valid'
|
267
|
+
end
|
268
|
+
@output_file_path = value
|
269
|
+
end
|
270
|
+
|
271
|
+
def complete(get_cert=true)
|
272
|
+
unless @file_to_sign_path
|
273
|
+
raise 'The file to be signed was not set'
|
274
|
+
end
|
275
|
+
unless @transfer_file_id
|
276
|
+
raise 'The transfer data file was not set'
|
277
|
+
end
|
278
|
+
unless @signature
|
279
|
+
raise 'The signature was not set'
|
280
|
+
end
|
281
|
+
unless @output_file_path
|
282
|
+
raise 'The output destination was not set'
|
283
|
+
end
|
284
|
+
|
285
|
+
args = [
|
286
|
+
@file_to_sign_path,
|
287
|
+
File.expand_path(@transfer_file_id, @config.transfer_data_folder),
|
288
|
+
@signature,
|
289
|
+
@output_file_path,
|
290
|
+
]
|
291
|
+
|
292
|
+
if @data_file_path
|
293
|
+
args.append('--data-file')
|
294
|
+
args.append(@data_file_path)
|
295
|
+
end
|
296
|
+
|
297
|
+
if get_cert
|
298
|
+
# This operation can only be used on version greater than 1.8 of the
|
299
|
+
# PKI Express.
|
300
|
+
@version_manager.require_version('1.8')
|
301
|
+
|
302
|
+
# Invoke command.
|
303
|
+
result = invoke(Commands::COMPLETE_SIG, args)
|
304
|
+
|
305
|
+
# Parse output and return model.
|
306
|
+
model = parse_output(result)
|
307
|
+
return PKCertificate.new(model.fetch(:signer))
|
308
|
+
end
|
309
|
+
|
310
|
+
# Invoke command.
|
311
|
+
invoke(Commands::COMPLETE_SIG, args)
|
312
|
+
end
|
313
|
+
|
314
|
+
end
|
315
315
|
end
|
@@ -1,21 +1,21 @@
|
|
1
|
-
module PkiExpress
|
2
|
-
class SignaturePolicyIdentifier
|
3
|
-
attr_accessor :digest, :oid, :uri
|
4
|
-
|
5
|
-
def initialize(model)
|
6
|
-
@digest = nil
|
7
|
-
@oid = nil
|
8
|
-
@uri = nil
|
9
|
-
|
10
|
-
unless model.nil?
|
11
|
-
digest = model.fetch(:digest)
|
12
|
-
unless digest.nil?
|
13
|
-
DigestAlgorithmAndValue.new(digest)
|
14
|
-
end
|
15
|
-
oid = model.fetch(:oid)
|
16
|
-
uri = model.fetch(:uri)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
1
|
+
module PkiExpress
|
2
|
+
class SignaturePolicyIdentifier
|
3
|
+
attr_accessor :digest, :oid, :uri
|
4
|
+
|
5
|
+
def initialize(model)
|
6
|
+
@digest = nil
|
7
|
+
@oid = nil
|
8
|
+
@uri = nil
|
9
|
+
|
10
|
+
unless model.nil?
|
11
|
+
digest = model.fetch(:digest)
|
12
|
+
unless digest.nil?
|
13
|
+
DigestAlgorithmAndValue.new(digest)
|
14
|
+
end
|
15
|
+
oid = model.fetch(:oid)
|
16
|
+
uri = model.fetch(:uri)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
21
|
end
|