Package dev.enola.common.secret
Class PrefixingSecretManager
java.lang.Object
dev.enola.common.secret.PrefixingSecretManager
- All Implemented Interfaces:
SecretManager
PrefixingSecretManager is a
SecretManager that prefixes all keys with a given prefix.
This is useful, for example, to use a single SecretManager in a server environment for
multiple users (or any other Subject), or in a desktop environment to store application-specific
secrets on the user's desktop secret manager (like GNOME Keyring or macOS Keychain on Apple's
Secure Enclave).
-
Constructor Details
-
PrefixingSecretManager
-
-
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.
-
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.
-