public class KeyStoreSecretStore extends Object implements SecretStore<CryptoKey>
KeyStore
. Typically this will either be a
file-based PKCS#12 keystore or a PKCS#11 Hardware Security Module (HSM). Legacy proprietary key store formats such
as JKS and JCEKS are also supported, but should not be used for any new functionality as they implement weak
encryption and integrity protection mechanisms.
The password for the keystore and for all entries within the keystore can be provided as a GenericSecret
allowing it to come from another secrets backend, such as an environment variable, encrypted file, KMS, etc.
Modifier and Type | Class and Description |
---|---|
static class |
KeyStoreSecretStore.AliasSpec
Specifies an alias with its validity for use in the store.
|
class |
KeyStoreSecretStore.KeyDetails
Details of a key that comes from the keystore.
|
static interface |
KeyStoreSecretStore.StableIdProvider
An interface to allow the consuming application to provide the stable ID for the secret.
|
CLOCK, LEASE_EXPIRY_DURATION
Constructor and Description |
---|
KeyStoreSecretStore(Function<char[],KeyStore,KeyStoreException> keyStoreLoader,
SecretReference<GenericSecret> keyStorePassword)
Initialises the keystore using the same password for the keystore and all keys and default configuration options.
|
KeyStoreSecretStore(Function<char[],KeyStore,KeyStoreException> keyStoreLoader,
SecretReference<GenericSecret> keyStorePassword,
Options options)
Initialises the keystore using the same password for the keystore and all keys.
|
KeyStoreSecretStore(Function<char[],KeyStore,KeyStoreException> keyStoreLoader,
SecretReference<GenericSecret> keyStorePassword,
SecretReference<GenericSecret> keyEntryPassword,
Options options,
KeyStoreSecretStore.StableIdProvider stableIdProvider)
Initialises the key store.
|
Modifier and Type | Method and Description |
---|---|
<S extends CryptoKey> |
getActive(Purpose<S> purpose)
Returns the active secret for the given purpose.
|
<S extends CryptoKey> |
getNamed(Purpose<S> purpose,
String id)
Returns the named secret from this store.
|
Class<CryptoKey> |
getStoredType()
The top-level class that this store is capable of storing.
|
<S extends CryptoKey> |
getValid(Purpose<S> purpose)
Returns all valid secrets for the given purpose from this store.
|
void |
refresh()
Indicates that the store should refresh its secrets from the backing storage mechanism.
|
void |
retire(Purpose<? extends CryptoKey> purpose,
String oldAlias)
Retires a key previously used for a given purpose.
|
void |
revoke(String alias)
Revokes a key from all purposes.
|
void |
rotate(Purpose<? extends CryptoKey> purpose,
String newAlias)
Rotates the key associated with a given purpose.
|
void |
setKeysForPurposes(Map<String,List<KeyStoreSecretStore.AliasSpec>> keysForPurposes)
Set the keys that are used for different purposes.
|
String |
toString() |
public KeyStoreSecretStore(Function<char[],KeyStore,KeyStoreException> keyStoreLoader, SecretReference<GenericSecret> keyStorePassword, SecretReference<GenericSecret> keyEntryPassword, Options options, KeyStoreSecretStore.StableIdProvider stableIdProvider)
keyStoreLoader
- the loader for the keystore. A function that takes the keystore password and returns the
loaded keystore.keyStorePassword
- the keystore password.keyEntryPassword
- the key entry password. The same password will be used for all key entries.options
- the configuration options.stableIdProvider
- The implementation that will provide stable IDs for a given key.public KeyStoreSecretStore(Function<char[],KeyStore,KeyStoreException> keyStoreLoader, SecretReference<GenericSecret> keyStorePassword, Options options)
KeyStoreSecretStore.StableIdProvider
that just returns KeyStoreSecretStore.KeyDetails.getAlias()
.keyStoreLoader
- the keystore loader.keyStorePassword
- the keystore password.options
- the configuration options.public KeyStoreSecretStore(Function<char[],KeyStore,KeyStoreException> keyStoreLoader, SecretReference<GenericSecret> keyStorePassword)
KeyStoreSecretStore.StableIdProvider
that just returns KeyStoreSecretStore.KeyDetails.getAlias()
.keyStoreLoader
- the keystore loader.keyStorePassword
- the keystore password.public void setKeysForPurposes(Map<String,List<KeyStoreSecretStore.AliasSpec>> keysForPurposes)
keysForPurposes
- a map from purpose label to a list of key aliases.public void rotate(Purpose<? extends CryptoKey> purpose, String newAlias)
rotate
in interface SecretStore<CryptoKey>
purpose
- the purpose to install a new key for.newAlias
- the new key alias.public void retire(Purpose<? extends CryptoKey> purpose, String oldAlias)
retire
in interface SecretStore<CryptoKey>
purpose
- the key purpose.oldAlias
- the key alias.public void revoke(String alias)
revoke
in interface SecretStore<CryptoKey>
alias
- the alias to remove.public Class<CryptoKey> getStoredType()
SecretStore
getStoredType
in interface SecretStore<CryptoKey>
CryptoKey
for key-stores, GenericSecret
for password stores, or
Secret
if the store is capable of storing any type of secret.public void refresh()
SecretStore
refresh
in interface SecretStore<CryptoKey>
public <S extends CryptoKey> Promise<S,NoSuchSecretException> getActive(Purpose<S> purpose)
SecretStore
getActive
in interface SecretStore<CryptoKey>
S
- the type of secret.purpose
- the purpose for which a secret is required.public <S extends CryptoKey> Promise<S,NoSuchSecretException> getNamed(Purpose<S> purpose, String id)
SecretStore
getNamed
in interface SecretStore<CryptoKey>
S
- the type of secret.purpose
- the secret purpose.id
- the name (stable id) of the secret.Optional.empty()
if no such secret exists.public <S extends CryptoKey> Promise<Stream<S>,NeverThrowsException> getValid(Purpose<S> purpose)
SecretStore
getValid
in interface SecretStore<CryptoKey>
S
- the type of secret.purpose
- the purpose.Copyright © 2010-2018, ForgeRock All Rights Reserved.