Class: PkiExpress::PkiExpressOperator

Inherits:
Object
  • Object
show all
Defined in:
lib/pki_express/pki_express_operator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = PkiExpressConfig.new) ⇒ PkiExpressOperator

Returns a new instance of PkiExpressOperator.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pki_express/pki_express_operator.rb', line 13

def initialize(config = PkiExpressConfig.new)
  @temp_files = []
  @file_references = {}

  @config = config
  @version_manager = VersionManager.new
  @trusted_roots = []
  @offline = false
  @trust_lacuna_test_root = false
  @signature_policy = nil
  @timestamp_authority = nil
  @culture = nil
  @time_zone = nil

  @id = SecureRandom.uuid
  ObjectSpace.define_finalizer(@id, proc {
    self.class.finalize(@temp_files)
  })
end

Instance Attribute Details

#cultureObject

Returns the value of attribute culture.



10
11
12
# File 'lib/pki_express/pki_express_operator.rb', line 10

def culture
  @culture
end

#offlineObject

Returns the value of attribute offline.



10
11
12
# File 'lib/pki_express/pki_express_operator.rb', line 10

def offline
  @offline
end

#signature_policyObject

Returns the value of attribute signature_policy.



10
11
12
# File 'lib/pki_express/pki_express_operator.rb', line 10

def signature_policy
  @signature_policy
end

#time_zoneObject

Returns the value of attribute time_zone.



10
11
12
# File 'lib/pki_express/pki_express_operator.rb', line 10

def time_zone
  @time_zone
end

#timestamp_authorityObject

Returns the value of attribute timestamp_authority.



10
11
12
# File 'lib/pki_express/pki_express_operator.rb', line 10

def timestamp_authority
  @timestamp_authority
end

#trust_lacuna_test_rootObject

Returns the value of attribute trust_lacuna_test_root.



10
11
12
# File 'lib/pki_express/pki_express_operator.rb', line 10

def trust_lacuna_test_root
  @trust_lacuna_test_root
end

Class Method Details

.finalize(temp_files) ⇒ Object



33
34
35
36
37
# File 'lib/pki_express/pki_express_operator.rb', line 33

def self.finalize(temp_files)
  temp_files.each do |file|
    File.delete(file) if File.exist?(file)
  end
end

Instance Method Details

#add_file_reference(key, reference_path) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/pki_express/pki_express_operator.rb', line 39

def add_file_reference(key, reference_path)

  if reference_path.nil?
    raise ArgumentError.new('The provided reference path is not valid')
  end

  unless File.exists?(reference_path)
    raise ArgumentError.new('The provided reference file was not found')
  end

  @file_references[key] = reference_path
end

#add_trusted_root(root_path) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/pki_express/pki_express_operator.rb', line 52

def add_trusted_root(root_path)

  if root_path.nil?
    raise ArgumentError.new('The provided trusted root path is not valid')
  end

  unless File.exists?(root_path)
    raise ArgumentError.new("The provided trusted root path doesn't exist: #{root_path}")
  end

  @trusted_roots.append(root_path)
end