Package dev.enola.common.secret.context
Class SecretManagerTLC
java.lang.Object
dev.enola.common.secret.context.SecretManagerTLC
- All Implemented Interfaces:
SecretManager
SecretManagerTLC is a
SecretManager implementation that looks up the current SecretManager from the TLC. If it's not found there, then it falls back to one passed to
the constructor, which defaults to an UnavailableSecretManager.-
Constructor Summary
ConstructorsConstructorDescriptionSecretManagerTLC(SecretManager fallback) Creates a new instance which falls back to the SecretManager passed to this constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidDeletes a secret from the manager.Retrieves a secret by its key; throws if not found.getOptional(String key) Retrieves a secret by its key, with optionality.voidStores a secret value associated with a unique key.
-
Constructor Details
-
SecretManagerTLC
Creates a new instance which falls back to the SecretManager passed to this constructor. -
SecretManagerTLC
public SecretManagerTLC()
-
-
Method Details
-
store
Description copied from interface:SecretManagerStores a secret value associated with a unique key. The sensitive value is provided as a char array. Implementations will zero out the inputvaluearray immediately after calling this method for security. If a secret with the same key already exists, its value is overwritten.- Specified by:
storein interfaceSecretManager- Parameters:
key- The unique key (name) for the secret.value- The sensitive secret value as a character array.- Throws:
IOException- If an error occurs while storing the secret.
-
getOptional
Description copied from interface:SecretManagerRetrieves a secret by its key, with optionality.- Specified by:
getOptionalin interfaceSecretManager- Parameters:
key- The unique key (name) of the secret to retrieve.- Returns:
- An
Optionalcontaining theSecret, if found. - Throws:
IOException- If an error occurs while retrieving the secret.
-
get
Description copied from interface:SecretManagerRetrieves a secret by its key; throws if not found.- Specified by:
getin interfaceSecretManager- Parameters:
key- The unique key (name) of the secret to retrieve.- Returns:
- An
Optionalcontaining theSecret, if found. - Throws:
IllegalStateException- if the secret is not found.IOException- If an error occurs while retrieving the secret.
-
delete
Description copied from interface:SecretManagerDeletes a secret from the manager.- Specified by:
deletein interfaceSecretManager- Parameters:
key- The unique key (name) of the secret to delete.- Throws:
IOException- If an error occurs while deleting the secret.
-