Class CredentialPair<T extends Secret>
java.lang.Object
org.forgerock.secrets.credentials.CredentialPair<T>
- Type Parameters:
T- the type of secret for the credential pair
Credential pair implementation.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Secret>
CredentialPair<T>credentialPair(SecretReference<T> secretReference, Function<T, PrincipalAndSecret<T>, NoSuchSecretException> mapper) Factory method to create a new instance ofCredentialPairfrom a reference to a secret containing both the principal and secret.static <T extends Secret>
CredentialPair<T>fixedPrincipalCredentialPair(String principal, SecretReference<T> secretReference) Factory method to create a new instance ofCredentialPairwith a static principal and a dynamic principal secret.get()Get thePrincipalAndSecret.getAsync()Gets thePrincipalAndSecretasynchronously.
-
Method Details
-
fixedPrincipalCredentialPair
public static <T extends Secret> CredentialPair<T> fixedPrincipalCredentialPair(String principal, SecretReference<T> secretReference) Factory method to create a new instance ofCredentialPairwith a static principal and a dynamic principal secret.- Type Parameters:
T- the type of secret for the credential pair- Parameters:
principal- a principal credential, e.g. username or client_idsecretReference- the secret reference- Returns:
- a credential pair reference for the given credentials
-
credentialPair
public static <T extends Secret> CredentialPair<T> credentialPair(SecretReference<T> secretReference, Function<T, PrincipalAndSecret<T>, NoSuchSecretException> mapper) Factory method to create a new instance of
CredentialPairfrom a reference to a secret containing both the principal and secret.An example of use would be to have the secret reference pointing to a JSON string such as
{"principal": "...", "secret": "..."}and the mapper capable of reconstructing thePrincipalAndSecretfrom this JSON input.- Type Parameters:
T- the type of secret for the credential pair- Parameters:
secretReference- the secret reference pointing to a secret containing both the principal and its secret in a format the mapper will understandmapper- the mapper used to transform the secretReference content into a credential pair- Returns:
- credentials using custom mappings for principal and principal secret credentials inside the secret
-
getAsync
Gets thePrincipalAndSecretasynchronously.- Returns:
- a promise of the principal and secret.
-
get
Get thePrincipalAndSecret.- Returns:
- the
PrincipalAndSecretfor this credential pair - Throws:
NoSuchSecretException- if the secret does not exist
-