Module: Jerakia::Response::Filter::Encryption
- Defined in:
- lib/jerakia/response/filter/encryption.rb
Instance Method Summary collapse
Instance Method Details
#decrypt(data) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jerakia/response/filter/encryption.rb', line 27 def decrypt(data) if encrypted?(data) public_key = config['eyaml']['public_key'] private_key = config['eyaml']['private_key'] Hiera::Backend::Eyaml::Options[:pkcs7_private_key] = private_key Hiera::Backend::Eyaml::Options[:pkcs7_public_key] = public_key parser = Hiera::Backend::Eyaml::Parser::ParserFactory.hiera_backend_parser tokens = parser.parse(data) decrypted = tokens.map(&:to_plain_text) plaintext = decrypted.join Jerakia.log.debug(plaintext) plaintext.chomp! data.clear.insert(0, plaintext) else data end end |
#encrypted?(data) ⇒ Boolean
46 47 48 |
# File 'lib/jerakia/response/filter/encryption.rb', line 46 def encrypted?(data) /.*ENC\[.*?\]/ =~ data ? true : false end |
#filter_encryption(_opts = {}) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/jerakia/response/filter/encryption.rb', line 20 def filter_encryption(_opts = {}) parse_values do |val| decrypt val if val.is_a?(String) val end end |