Class: PkiExpress::SignatureFinisher

Inherits:
PkiExpressOperator show all
Defined in:
lib/pki_express/signature_finisher.rb

Instance Attribute Summary collapse

Attributes inherited from PkiExpressOperator

#culture, #offline, #signature_policy, #time_zone, #timestamp_authority, #trust_lacuna_test_root

Instance Method Summary collapse

Methods inherited from PkiExpressOperator

#add_file_reference, #add_trusted_root, finalize

Constructor Details

#initialize(config = PkiExpressConfig.new) ⇒ SignatureFinisher

Returns a new instance of SignatureFinisher.



5
6
7
8
9
10
11
12
# File 'lib/pki_express/signature_finisher.rb', line 5

def initialize(config=PkiExpressConfig.new)
  super(config)
  @file_to_sign_path = nil
  @transfer_file_id = nil
  @data_file_path = nil
  @output_file_path = nil
  @signature = nil
end

Instance Attribute Details

#output_file_pathObject

Returns the value of attribute output_file_path.



3
4
5
# File 'lib/pki_express/signature_finisher.rb', line 3

def output_file_path
  @output_file_path
end

#transfer_file_idObject

Returns the value of attribute transfer_file_id.



3
4
5
# File 'lib/pki_express/signature_finisher.rb', line 3

def transfer_file_id
  @transfer_file_id
end

Instance Method Details

#complete(get_cert = true) ⇒ Object



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/pki_express/signature_finisher.rb', line 271

def complete(get_cert=true)
  unless @file_to_sign_path
    raise 'The file to be signed was not set'
  end
  unless @transfer_file_id
    raise 'The transfer data file was not set'
  end
  unless @signature
    raise 'The signature was not set'
  end
  unless @output_file_path
    raise 'The output destination was not set'
  end

  args = [
      @file_to_sign_path,
      File.expand_path(@transfer_file_id, @config.transfer_data_folder),
      @signature,
      @output_file_path,
  ]

  if @data_file_path
    args.append('--data-file')
    args.append(@data_file_path)
  end

  if get_cert
    # This operation can only be used on version greater than 1.8 of the
    # PKI Express.
    @version_manager.require_version('1.8')

    # Invoke command.
    result = invoke(Commands::COMPLETE_SIG, args)

    # Parse output and return model.
    model = parse_output(result)
    return PKCertificate.new(model.fetch(:signer))
  end

  # Invoke command.
  invoke(Commands::COMPLETE_SIG, args)
end

#data_fileObject

region The “data_file” accessors



108
109
110
# File 'lib/pki_express/signature_finisher.rb', line 108

def data_file
  _get_data_file
end

#data_file=(content_raw) ⇒ Object



121
122
123
# File 'lib/pki_express/signature_finisher.rb', line 121

def data_file=(content_raw)
  _set_data_file(content_raw)
end

#data_file_base64Object



138
139
140
# File 'lib/pki_express/signature_finisher.rb', line 138

def data_file_base64
  _get_data_file_base64
end

#data_file_base64=(content_base64) ⇒ Object



152
153
154
# File 'lib/pki_express/signature_finisher.rb', line 152

def data_file_base64=(content_base64)
  _set_data_file_base64(content_base64)
end

#data_file_pathObject



171
172
173
# File 'lib/pki_express/signature_finisher.rb', line 171

def data_file_path
  _get_data_file_path
end

#data_file_path=(path) ⇒ Object



180
181
182
# File 'lib/pki_express/signature_finisher.rb', line 180

def data_file_path=(path)
  _set_data_file_path(path)
end

#file_to_signObject

region The “file_to_sign” accessors



16
17
18
# File 'lib/pki_express/signature_finisher.rb', line 16

def file_to_sign
  _get_file_to_sign
end

#file_to_sign=(content_raw) ⇒ Object



29
30
31
# File 'lib/pki_express/signature_finisher.rb', line 29

def file_to_sign=(content_raw)
  _set_file_to_sign(content_raw)
end

#file_to_sign_base64Object



46
47
48
# File 'lib/pki_express/signature_finisher.rb', line 46

def file_to_sign_base64
  _get_file_to_sign_base64
end

#file_to_sign_base64=(content_base64) ⇒ Object



60
61
62
# File 'lib/pki_express/signature_finisher.rb', line 60

def file_to_sign_base64=(content_base64)
  _set_file_to_sign_base64(content_base64)
end

#file_to_sign_pathObject



79
80
81
# File 'lib/pki_express/signature_finisher.rb', line 79

def file_to_sign_path
  _get_file_to_sign_path
end

#file_to_sign_path=(path) ⇒ Object



88
89
90
# File 'lib/pki_express/signature_finisher.rb', line 88

def file_to_sign_path=(path)
  _set_file_to_sign_path(path)
end

#signatureObject

region The “signature” accessors



200
201
202
# File 'lib/pki_express/signature_finisher.rb', line 200

def signature
  _get_signature
end

#signature=(content_raw) ⇒ Object



209
210
211
# File 'lib/pki_express/signature_finisher.rb', line 209

def signature=(content_raw)
  _set_signature(content_raw)
end

#signature_base64Object



221
222
223
# File 'lib/pki_express/signature_finisher.rb', line 221

def signature_base64
  _get_signature_base64
end

#signature_base64=(content_base64) ⇒ Object



233
234
235
# File 'lib/pki_express/signature_finisher.rb', line 233

def signature_base64=(content_base64)
  _set_signature_base64(content_base64)
end