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

public final class CredentialPair<T extends Secret> extends Object
Credential pair implementation.
  • Method Details

    • fixedPrincipalCredentialPair

      public static <T extends Secret> CredentialPair<T> fixedPrincipalCredentialPair(String principal, SecretReference<T> secretReference)
      Factory method to create a new instance of CredentialPair with 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_id
      secretReference - 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 CredentialPair from 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 the PrincipalAndSecret from 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 understand
      mapper - 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 the PrincipalAndSecret asynchronously.
      Returns:
      a promise of the principal and secret.
    • get

      Returns:
      the PrincipalAndSecret for this credential pair
      Throws:
      NoSuchSecretException - if the secret does not exist