Class: Hiera::Backend::Eyaml::Encryptor

Inherits:
Object
  • Object
show all
Defined in:
lib/hiera/backend/eyaml/encryptor.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.optionsObject

Returns the value of attribute options


11
12
13
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 11

def options
  @options
end

.tagObject

Returns the value of attribute tag


12
13
14
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 12

def tag
  @tag
end

Class Method Details

.decode(string) ⇒ Object


28
29
30
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 28

def self.decode string
  Base64.decode64(string)
end

.decrypt(*args) ⇒ Object

Raises:

  • (StandardError)

36
37
38
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 36

def self.decrypt *args
  raise StandardError, "decrypt() not defined for decryptor plugin: #{self}"
end

.encode(binary_string) ⇒ Object


24
25
26
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 24

def self.encode binary_string
  Base64.strict_encode64(binary_string)
end

.encrypt(*args) ⇒ Object

Raises:

  • (StandardError)

32
33
34
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 32

def self.encrypt *args
  raise StandardError, "encrypt() not defined for encryptor plugin: #{self}"
end

.find(encryption_scheme = nil) ⇒ Object

Raises:

  • (StandardError)

15
16
17
18
19
20
21
22
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 15

def self.find encryption_scheme = nil
  encryption_scheme = Eyaml.default_encryption_scheme if encryption_scheme.nil?
  require "hiera/backend/eyaml/encryptors/#{File.basename encryption_scheme.downcase}"
  encryptor_module = Module.const_get('Hiera').const_get('Backend').const_get('Eyaml').const_get('Encryptors')
  encryptor_class = Utils.find_closest_class :parent_class => encryptor_module, :class_name => encryption_scheme
  raise StandardError, "Could not find hiera-eyaml encryptor: #{encryption_scheme}. Try gem install hiera-eyaml-#{encryption_scheme.downcase} ?" if encryptor_class.nil?
  encryptor_class
end