in src/dynamodb_encryption_sdk/material_providers/most_recent.py [0:0]
def decryption_materials(self, encryption_context):
# type: (EncryptionContext) -> CryptographicMaterials
"""Return decryption materials.
:param EncryptionContext encryption_context: Encryption context for request
:raises AttributeError: if no decryption materials are available
"""
provider = None
version = self._provider_store.version_from_material_description(encryption_context.material_description)
ttl_action = self._ttl_action(version, _DECRYPT_ACTION)
if ttl_action is TtlActions.EXPIRED:
self._cache.evict(self._version)
_LOGGER.debug('TTL Action "%s" when getting decryption materials', ttl_action.name)
if ttl_action is TtlActions.LIVE:
try:
_LOGGER.debug("Looking in cache for encryption materials provider version %d", version)
_, provider = self._cache.get(version)
except KeyError:
_LOGGER.debug("Decryption materials provider not found in cache")
if provider is None:
try:
provider = self._get_provider_with_grace_period(version, ttl_action)
except InvalidVersionError:
_LOGGER.exception("Unable to get decryption materials from provider store.")
raise AttributeError("No decryption materials available")
return provider.decryption_materials(encryption_context)