Class Secret<T extends SecretConfig>
- Type Parameters:
T
- the type ofSecretConfig
associated with this Secret
Helper class which aids in retrieving the current Plaintext
value of a secret without having to be
concerned with the implementation details of embedded vs referenced secrets.
To create a new instance of Secret, call create(GatewayContext, SecretConfig)
and pass in a
GatewayContext
and a SecretConfig
.
To get the current Plaintext
value from the Secret, call getPlaintext()
.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Secret<?>
create
(GatewayContext context, SecretConfig config) Factory method to create a new instance of a Secretabstract Plaintext
Get the currentPlaintext
value of the configured secret.
-
Method Details
-
getContext
- Returns:
- the
GatewayContext
. never null.
-
getConfig
- Returns:
- the
SecretConfig
. never null.
-
getPlaintext
Get the current
Plaintext
value of the configured secret.If the configured secret is embedded, the Plaintext value is retrieved by passing the embedded ciphertext to the
SystemEncryptionService
retrieved from theGatewayContext
.If the configured secret is referenced, the Plaintext value is retrieved by getting the
SecretProviderManager
from theGatewayContext
, then getting theSecretProvider
with the configured name from the SecretProviderManager, and finallyreading
the Plaintext value of the secret with the configured name from the SecretProvider.- Returns:
- the current
Plaintext
value of the configured secret. never null. - Throws:
SecretException
- if there is a problem getting the current Plaintext value of the configured secret
-
create
Factory method to create a new instance of a Secret- Parameters:
context
- the currentGatewayContext
. cannot be null.config
- theSecretConfig
of the secret. cannot be null.- Returns:
- a new instance of Secret
- Throws:
IllegalArgumentException
- if the provided config is not an embedded or referenced secretNullPointerException
- if either context or config arguments are null
-