Class: PkiExpress::CadesSignatureStarter

Inherits:
SignatureStarter show all
Defined in:
lib/pki_express/cades_signature_starter.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 SignatureStarter

#certificate, #certificate=, #certificate_base64, #certificate_base64=, #certificate_path, #certificate_path=, get_result

Methods inherited from PkiExpressOperator

#add_file_reference, #add_trusted_root, finalize

Constructor Details

#initialize(config = PkiExpressConfig.new) ⇒ CadesSignatureStarter

Returns a new instance of CadesSignatureStarter.



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

def initialize(config=PkiExpressConfig.new)
  super(config)
  @file_to_sign_path = nil
  @data_file_path = nil
  @encapsulated_content = true
end

Instance Attribute Details

#encapsulated_contentObject

Returns the value of attribute encapsulated_content.



5
6
7
# File 'lib/pki_express/cades_signature_starter.rb', line 5

def encapsulated_content
  @encapsulated_content
end

Instance Method Details

#data_fileObject

region The “data_file” accessors



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

def data_file
  _get_data_file
end

#data_file=(content_raw) ⇒ Object



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

def data_file=(content_raw)
  _set_data_file(content_raw)
end

#data_file_base64Object



138
139
140
# File 'lib/pki_express/cades_signature_starter.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/cades_signature_starter.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/cades_signature_starter.rb', line 171

def data_file_path
  _get_data_file_path
end

#data_file_path=(path) ⇒ Object



180
181
182
# File 'lib/pki_express/cades_signature_starter.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/cades_signature_starter.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/cades_signature_starter.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/cades_signature_starter.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/cades_signature_starter.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/cades_signature_starter.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/cades_signature_starter.rb', line 88

def file_to_sign_path=(path)
  _set_file_to_sign_path(path)
end

#startObject

endregion



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/pki_express/cades_signature_starter.rb', line 198

def start

  unless @file_to_sign_path
    raise 'The file to be signed was not set'
  end

  unless @certificate_path
    raise 'The certificate was not set'
  end

  # Generate transfer file.
  transfer_file_id = get_transfer_filename

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

  # Verify and add common options between signers.
  verify_and_add_common_options(args)

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

  unless @encapsulated_content
    args.append('--detached')
  end

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

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

  # Parse output and return model.
  model = parse_output(result)
  SignatureStartResult.new(model, transfer_file_id)
end