Class InMemorySecretStore
- All Implemented Interfaces:
SecretStore
SecretStore: a per-process, ConcurrentHashMap-backed key-to-secret map.
This is the zero-config store SecretStores.resolve(org.apache.juneau.commons.inject.BeanStore) falls back
to when no store has been contributed. It is honest about its limits:
Process-local only. Secrets live in this JVM's heap and are gone when the process exits — this store is not persistent. Two separate JVMs (or two instances behind a load balancer) each hold their own map and do not see each other's secrets, so it is not cross-node. It is a convenience default and a test double, not a production secret backend; deployments that need durability or sharing must contribute a store backed by an external secret manager.
Defensive copies. store(java.lang.String, char[]) copies the supplied array and find(java.lang.String) returns a fresh copy, so the
caller may zero its own arrays without disturbing the stored value and vice-versa. delete(java.lang.String) zeroes the
retained array before dropping it. The value is never toString()'d, logged, or dumped.
Thread-safety. All operations are safe for concurrent invocation.
- Since:
- 10.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeletes the secret stored under the specified key.booleanReturns whether a secret is stored under the specified key without materializing its value.Optional<char[]>Returns the secret stored under the specified key.voidStores a secret under the specified key, replacing any existing value.
-
Constructor Details
-
InMemorySecretStore
public InMemorySecretStore()
-
-
Method Details
-
store
Description copied from interface:SecretStoreStores a secret under the specified key, replacing any existing value.The caller retains ownership of
secret and may zero it after this call returns; an implementation that needs to retain the value must copy it.- Specified by:
storein interfaceSecretStore- Parameters:
key- The key under which to store the secret. Must not benull .secret- The secret value. Must not benull .
-
find
Description copied from interface:SecretStoreReturns the secret stored under the specified key.The returned array is the caller's to own and zero; it is not a live view of the store's internal state.
- Specified by:
findin interfaceSecretStore- Parameters:
key- The key to look up. Must not benull .- Returns:
- The secret value, or
Optional.empty()if no secret is stored under the key.
-
exists
Description copied from interface:SecretStoreReturns whether a secret is stored under the specified key without materializing its value.- Specified by:
existsin interfaceSecretStore- Parameters:
key- The key to check. Must not benull .- Returns:
true if a secret is stored under the key.
-
delete
Description copied from interface:SecretStoreDeletes the secret stored under the specified key.- Specified by:
deletein interfaceSecretStore- Parameters:
key- The key to delete. Must not benull .- Returns:
true if a secret was present and removed;false if the key was already absent.
-