Package dev.enola.common.secret
Interface SecretManager
- All Known Implementing Classes:
EnvironmentSecretManager,ExecPassSecretManager,GnomeSecretManager,InMemorySecretManager,InsecureUnencryptedYamlFileSecretManager,JavaPropertySecretManager,PrefixingSecretManager,ReadOnlySecretManager,SecretManagerChain,SecretManagerTLC,TestSecretManager,UnavailableSecretManager,YamlSecretManager
public interface SecretManager
SecretManager is a "vault" of 🔑
Secrets.
You store(String, char[]), then getOptional(String) it; and maybe later
delete(String) it again. There is very intentionally no Set<String>
listKeys() sort of method here.
-
Method Summary
Modifier and TypeMethodDescriptionvoidDeletes a secret from the manager.default SecretRetrieves 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.
-
Method Details
-
store
Stores 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.- 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
Retrieves a secret by its key, with optionality.- 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
Retrieves a secret by its key; throws if not found.- 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
Deletes a secret from the manager.- Parameters:
key- The unique key (name) of the secret to delete.- Throws:
IOException- If an error occurs while deleting the secret.
-