Class: PkiExpress::Authentication

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

Instance Attribute Summary collapse

Attributes inherited from PkiExpressOperator

#offline, #signature_policy, #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) ⇒ Authentication

Returns a new instance of Authentication.



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

def initialize(config=PkiExpressConfig.new)
  super(config)
  @nonce_base64 = nil
  @certificate_path = nil
  @signature_base64 = nil
  @use_external_storage = false
end

Instance Attribute Details

#use_external_storageObject

Returns the value of attribute use_external_storage.



4
5
6
# File 'lib/pki_express/authentication.rb', line 4

def use_external_storage
  @use_external_storage
end

Instance Method Details

#certificateObject

region The “certificate” accessors



75
76
77
# File 'lib/pki_express/authentication.rb', line 75

def certificate
  _get_certificate
end

#certificate=(content_raw) ⇒ Object



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

def certificate=(content_raw)
  _set_certificate(content_raw)
end

#certificate_base64Object



105
106
107
# File 'lib/pki_express/authentication.rb', line 105

def certificate_base64
  _get_certificate_base64
end

#certificate_base64=(content_base64) ⇒ Object



119
120
121
# File 'lib/pki_express/authentication.rb', line 119

def certificate_base64=(content_base64)
  _set_certificate_base64(content_base64)
end

#certificate_pathObject



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

def certificate_path
  _get_certificate_path
end

#certificate_path=(path) ⇒ Object



147
148
149
# File 'lib/pki_express/authentication.rb', line 147

def certificate_path=(path)
  _set_certificate_path(path)
end

#completeObject



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/pki_express/authentication.rb', line 249

def complete
  unless @nonce_base64
    raise 'The nonce was not set.'
  end
  unless @certificate_path
    raise 'The certificate file was not set.'
  end
  unless @signature_base64
    raise 'The signature was not set.'
  end

  args = [
    @nonce_base64,
    @certificate_path,
    @signature_base64
  ]

  # The option "use external storage" is used to ignore the PKI Express's

  # nonce verification, to make a own nonce store and nonce verification.

  unless @use_external_storage
    args.append('--nonce-store')
    args.append(@config.transfer_data_folder)
  end

  # This configuration can only be used on versions greater than 1.4 of PKI

  # Express.

  @version_manager.require_version('1.4')

  # Invoke command.

  result = invoke(Commands::COMPLETE_AUTH, args)

  # Parse output and return result.

  model = parse_output(result)
  AuthCompleteResult.new(model)
end

#nonceObject

region The “nonce” accessors



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

def nonce
  _get_nonce
end

#nonce=(nonce) ⇒ Object



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

def nonce=(nonce)
  _set_nonce(nonce)
end

#nonce_base64Object



48
49
50
# File 'lib/pki_express/authentication.rb', line 48

def nonce_base64
  _get_nonce_base64
end

#nonce_base64=(nonce_base64) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/pki_express/authentication.rb', line 57

def nonce_base64=(nonce_base64)
  unless nonce_base64
    raise 'The provided "nonce_base64" is not valid'
  end

  begin
    Base64.decode64(nonce_base64)
  rescue Error
    raise 'The provided "nonce_base64" is not Base64-encoded'
  end

  @nonce_base64 = nonce_base64
end

#signatureObject

region The “signature” accessors



167
168
169
# File 'lib/pki_express/authentication.rb', line 167

def signature
  _get_signature
end

#signature=(signature) ⇒ Object



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

def signature=(signature)
  _set_signature(signature)
end

#signature_base64Object



198
199
200
# File 'lib/pki_express/authentication.rb', line 198

def signature_base64
  _get_signature_base64
end

#signature_base64=(signature_base64) ⇒ Object



207
208
209
# File 'lib/pki_express/authentication.rb', line 207

def signature_base64=(signature_base64)
  _set_signature_base64(signature_base64)
end

#startObject

endregion



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/pki_express/authentication.rb', line 227

def start
  args = []

  # The option "use external storage" is used to ignore the PKI Express's

  # nonce verification, to make a own nonce store and nonce verification.

  if @use_external_storage
    args.append('--nonce-store')
    args.append(@config.transfer_data_folder)
  end

  # This operation can only be used on versions greater then 1.4 of PKI

  # Express.

  @version_manager.require_version('1.4')

  # Invoke command.

  result = invoke(Commands::START_AUTH, args)

  # Parse output and return result.

  model = parse_output(result)
  AuthStartResult.new(model)
end