Package org.forgerock.secrets
Interface SecretStore<T extends Secret>
- 
- Type Parameters:
- T- the type of secrets that this backend can store.
 - All Known Implementing Classes:
- AppRoleTokenStore,- GoogleKmsSecretStore,- GoogleSecretManagerSecretStore,- JwkSetSecretStore,- JwtAuthenticationTokenStore,- KeyStoreSecretStore,- PropertyResolverSecretStore,- ThreadPoolSecretStore,- VaultDatabaseCredentialsSecretStore,- VaultKeyValueSecretStore,- VaultPkiSecretStore,- VaultTransitSecretStore
 
 public interface SecretStore<T extends Secret>A backend storage mechanism for certain kinds of secrets. Unlike aSecretsProvidera store may only be capable of storing certain types of secrets.Implementors should override the toString()method to return sensible information for debugging purposes (do not include secret material in this output).
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <S extends T>
 Promise<S,NoSuchSecretException>getActive(Purpose<S> purpose)Returns the active secret for the given purpose.default <S extends T>
 Promise<S,NoSuchSecretException>getNamed(Purpose<S> purpose, String name)Returns the named secret from this store.Class<T>getStoredType()The top-level class that this store is capable of storing.<S extends T>
 Promise<Stream<S>,NeverThrowsException>getValid(Purpose<S> purpose)Returns all valid secrets for the given purpose from this store.voidrefresh()Indicates that the store should refresh its secrets from the backing storage mechanism.default voidretire(Purpose<? extends T> purpose, String secretIdToRetire)Retires the given secret for the given purpose.default voidrevoke(String secretId)Revokes the given secret for all purposes in this store.default voidrotate(Purpose<? extends T> purpose, String newActiveSecretId)Rotates the active secret for the given purpose.
 
- 
- 
- 
Field Detail- 
LEASE_EXPIRY_DURATIONstatic final Option<Duration> LEASE_EXPIRY_DURATION Option used to specify how long secrets from a store should be used before being refreshed. Defaults to 5 minutes.
 - 
CLOCKstatic final Option<Clock> CLOCK Specifies the clock to use when making time comparisons. Defaults toClock.systemUTC().
 
- 
 - 
Method Detail- 
getStoredTypeClass<T> getStoredType() The top-level class that this store is capable of storing. This is a reification of the type parameter and can be used to lookup stores for a given type.- Returns:
- the top-most type that this store is capable of storing, typically either
 CryptoKeyfor key-stores,GenericSecretfor password stores, orSecretif the store is capable of storing any type of secret.
 
 - 
getActivedefault <S extends T> Promise<S,NoSuchSecretException> getActive(Purpose<S> purpose) Returns the active secret for the given purpose.- Type Parameters:
- S- the type of secret.
- Parameters:
- purpose- the purpose for which a secret is required.
- Returns:
- the active secret from this store.
 
 - 
getNameddefault <S extends T> Promise<S,NoSuchSecretException> getNamed(Purpose<S> purpose, String name) Returns the named secret from this store. The default implementation callsgetValid(Purpose)and then returns the first valid key with a matching stable ID.- Type Parameters:
- S- the type of secret.
- Parameters:
- purpose- the secret purpose.
- name- the name (stable id) of the secret.
- Returns:
- a promise for the named secret, or a NoSuchSecretExceptionpromise if no such secret exists.
 
 - 
getValid<S extends T> Promise<Stream<S>,NeverThrowsException> getValid(Purpose<S> purpose) Returns all valid secrets for the given purpose from this store.- Type Parameters:
- S- the type of secret.
- Parameters:
- purpose- the purpose.
- Returns:
- a stream of all valid secrets of the given type from this store, or an empty stream if none exist.
 
 - 
refreshvoid refresh() Indicates that the store should refresh its secrets from the backing storage mechanism. This can be used to cause reload of a store after a secret rotation if the backend does not automatically detect such changes. Refresh may be an asynchronous operation and no guarantees are made about when clients of this secret store may see updated secrets after a call to refresh.
 - 
rotatedefault void rotate(Purpose<? extends T> purpose, String newActiveSecretId) Rotates the active secret for the given purpose. The secret with the given stable id will be used as the active secret after this method completes, while the previous active secret will still be available as a named or valid secret until it is retired. This is an optional operation and will throwUnsupportedOperationExceptionif the store does not implement rotation directly. Some stores natively support rotation, in which case this should be done using store-specific interfaces.- Parameters:
- purpose- the purpose for which to rotate the active secret.
- newActiveSecretId- the stable id of the new active secret.
- Throws:
- IllegalArgumentException- if there is no such secret in this store, or if it is inappropriate for this purpose.
- UnsupportedOperationException- if this store does not support direct secret rotation.
 
 - 
retiredefault void retire(Purpose<? extends T> purpose, String secretIdToRetire) Retires the given secret for the given purpose. The named secret will no longer be considered valid for this purpose. This is an optional operation and will throwUnsupportedOperationExceptionif the store does not implement rotation directly. Some stores natively support rotation, in which case this should be done using store-specific interfaces. If the given secret is the current active secret for the purpose then the previous active secret will become active. If there are no still-valid previous secrets then there will be no active secret for that purpose and any attempts to use it will generateNoSuchSecretExceptions.- Parameters:
- purpose- the purpose for which to retire the secret.
- secretIdToRetire- the stable id of the secret to retire.
- Throws:
- UnsupportedOperationException- if this store does not support direct secret rotation.
 
 - 
revokedefault void revoke(String secretId) Revokes the given secret for all purposes in this store. The named secret will no longer be available as an active, named or valid secret for any purpose. If the given secret is currently the active secret for any purpose, then the store will revert to using the previous active secret for that purpose. If no previous secret is still valid then there will be no active secret for that purpose and any attempts to use it will generate aNoSuchSecretException. It is therefore advised to rotate a new secret into use for all such purposes before revoking the active secret.Note that if the store does not contain the named secret then it will silently ignore this request. - Parameters:
- secretId- the stable id of the secret to revoke.
- Throws:
- UnsupportedOperationException- if the store does not support directly revoking secrets.
 
 
- 
 
-