Module: Chef::EncryptedDataBagItem::Decryptor
- Defined in:
- lib/chef/encrypted_data_bag_item.rb
Overview
Decryptor
For backwards compatibility, Chef implements decryption/deserialization for older encrypted data bag item formats in addition to the current version. Each decryption/deserialization strategy is implemented as a class in this namespace. For convenience the factory method Decryptor.for() can be used to create an instance of the appropriate strategy for the given encrypted data bag value.
Defined Under Namespace
Classes: Version0Decryptor, Version1Decryptor
Class Method Summary collapse
-
.for(encrypted_value, key) ⇒ Object
Detects the encrypted data bag item format version and instantiates a decryptor object for that version.
- .format_version_of(encrypted_value) ⇒ Object
Class Method Details
.for(encrypted_value, key) ⇒ Object
Detects the encrypted data bag item format version and instantiates a decryptor object for that version. Call #for_decrypted_item on the resulting object to decrypt and deserialize it.
147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/chef/encrypted_data_bag_item.rb', line 147 def self.for(encrypted_value, key) case format_version_of(encrypted_value) when 1 Version1Decryptor.new(encrypted_value, key) when 0 Version0Decryptor.new(encrypted_value, key) else raise UnsupportedEncryptedDataBagItemFormat, "This version of chef does not support encrypted data bag item format version '#{format_version}'" end end |
.format_version_of(encrypted_value) ⇒ Object
159 160 161 162 163 164 165 |
# File 'lib/chef/encrypted_data_bag_item.rb', line 159 def self.format_version_of(encrypted_value) if encrypted_value.respond_to?(:key?) encrypted_value["version"] else 0 end end |