Class: DaffyLib::KeyManagementService
- Inherits:
-
Object
- Object
- DaffyLib::KeyManagementService
show all
- Defined in:
- lib/daffy_lib/services/key_management_service.rb
Defined Under Namespace
Classes: InvalidParameterException, KeyCreateException, KeyGenerationException, KeyManagementServiceException, KeyRetrieveException
Constant Summary
collapse
- KEY_MANAGEMENT_SERVICE_CACHE_NAMESPACE =
:key_management_service
- KEY_VERSION =
'KeyManagementService::V1'
- RECORD_NOT_UNIQUE_REGEX =
/has already been taken/.freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(partition_guid, expires_in, cmk_key_id) ⇒ KeyManagementService
Returns a new instance of KeyManagementService.
17
18
19
20
21
22
23
|
# File 'lib/daffy_lib/services/key_management_service.rb', line 17
def initialize(partition_guid, expires_in, cmk_key_id)
raise InvalidParameterException unless partition_guid.present? && expires_in.present? && cmk_key_id.present?
@partition_guid = partition_guid
@expires_in = expires_in
@cmk_key_id = cmk_key_id
end
|
Class Method Details
.encryption_key_epoch(datetime) ⇒ Object
25
26
27
|
# File 'lib/daffy_lib/services/key_management_service.rb', line 25
def self.encryption_key_epoch(datetime)
datetime.utc.beginning_of_year
end
|
Instance Method Details
#find_or_create_encryption_key(encryption_epoch) ⇒ Object
29
30
31
|
# File 'lib/daffy_lib/services/key_management_service.rb', line 29
def find_or_create_encryption_key(encryption_epoch)
find(encryption_epoch) || create(encryption_epoch)
end
|
#retrieve_plaintext_key(encryption_key) ⇒ Object
33
34
35
36
37
|
# File 'lib/daffy_lib/services/key_management_service.rb', line 33
def retrieve_plaintext_key(encryption_key)
raise InvalidParameterException unless encryption_key.present?
read_plaintext_key(encryption_key) || decrypt_encryption_key(encryption_key)
end
|