Package nva.commons.secrets
Class SecretsReader
java.lang.Object
nva.commons.secrets.SecretsReader
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSecretsReader(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient awsSecretsManager) -
Method Summary
Modifier and TypeMethodDescriptionstatic software.amazon.awssdk.services.secretsmanager.SecretsManagerClienterrorReadingSecretMessage(String secretName) <T> TfetchClassSecret(String secretName, Class<T> tclass) Fetches a json secret from AWS Secrets Manager as a class.fetchPlainTextSecret(String secretName) Fetches a plain-text secret from AWS Secrets Manager.fetchSecret(String secretName, String secretKey) Fetches a secret String from AWS Secrets Manager.
-
Field Details
-
COULD_NOT_READ_SECRET_ERROR
- See Also:
-
-
Constructor Details
-
SecretsReader
public SecretsReader() -
SecretsReader
public SecretsReader(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient awsSecretsManager)
-
-
Method Details
-
fetchSecret
Fetches a secret String from AWS Secrets Manager.- Parameters:
secretName- the user-friendly id of the secret or the secret ARNsecretKey- the key in the encrypted key-value map.- Returns:
- the value for the specified key
- Throws:
ErrorReadingSecretException- when any error occurs.
-
fetchPlainTextSecret
Fetches a plain-text secret from AWS Secrets Manager.- Parameters:
secretName- the user-friendly id of the secret or the secret ARN- Returns:
- the plain text value for the specified secret name
- Throws:
ErrorReadingSecretException- when any error occurs.
-
fetchClassSecret
Fetches a json secret from AWS Secrets Manager as a class.- Type Parameters:
T- the type of the class or interface of the class to be returned- Parameters:
secretName- the user-friendly id of the secret or the secret ARNtclass- the class or interface of the class to be returned- Returns:
- Class of the object we want to extract the secret to
- Throws:
ErrorReadingSecretException- when any error occurs.
-
errorReadingSecretMessage
-
defaultSecretsManagerClient
public static software.amazon.awssdk.services.secretsmanager.SecretsManagerClient defaultSecretsManagerClient()
-