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.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pki_express/pki_express_operator.rb', line 10

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

  ObjectSpace.define_finalizer(self, self.class.method(:finalize))
end

Instance Attribute Details

#offlineObject

Returns the value of attribute offline.



7
8
9
# File 'lib/pki_express/pki_express_operator.rb', line 7

def offline
  @offline
end

#signature_policyObject

Returns the value of attribute signature_policy.



7
8
9
# File 'lib/pki_express/pki_express_operator.rb', line 7

def signature_policy
  @signature_policy
end

#timestamp_authorityObject

Returns the value of attribute timestamp_authority.



7
8
9
# File 'lib/pki_express/pki_express_operator.rb', line 7

def timestamp_authority
  @timestamp_authority
end

#trust_lacuna_test_rootObject

Returns the value of attribute trust_lacuna_test_root.



7
8
9
# File 'lib/pki_express/pki_express_operator.rb', line 7

def trust_lacuna_test_root
  @trust_lacuna_test_root
end

Class Method Details

.finalizeObject



25
26
27
28
29
# File 'lib/pki_express/pki_express_operator.rb', line 25

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

Instance Method Details

#add_file_reference(key, reference_path) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pki_express/pki_express_operator.rb', line 31

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



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/pki_express/pki_express_operator.rb', line 44

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