Class PasswordDigestObtainer

java.lang.Object
org.wildfly.security.mechanism.digest.PasswordDigestObtainer

public class PasswordDigestObtainer extends Object
Utility class used to obtain username+realm+password using SASL/HTTP mechanism callbacks.
Author:
Jan Kalina
  • Constructor Details

    • PasswordDigestObtainer

      public PasswordDigestObtainer(CallbackHandler callbackHandler, String defaultUsername, String defaultRealm, ElytronMessages log, String credentialAlgorithm, MessageDigest messageDigest, Supplier<Provider[]> passwordFactoryProviders, String[] realms, boolean readOnlyRealmUsername, boolean skipRealmCallbacks)
      Constructs a new PasswordDigestObtainer instance.
      Parameters:
      callbackHandler - the callbackHandler to handle the callbacks required to obtain the username and password.
      defaultUsername - the default username to use if a callback is not provided.
      defaultRealm - the default realm to use if a callback is not provided.
      log - the logger to use.
      credentialAlgorithm - the name of the algorithm for obtaining the credential.
      messageDigest - the MessageDigest used for digesting the password.
      passwordFactoryProviders - the supplier of the providers to use when creating a PasswordFactory instance.
      realms - the realms to check for a user and password.
      readOnlyRealmUsername - true if the username passed in the callback can be modified, false otherwise.
      skipRealmCallbacks - true if realm callbacks should be skipped, false otherwise.
  • Method Details

    • getUsername

      public String getUsername()
      Returns the username obtained from callback or the default one.
      Returns:
      the username obtained from callback or the default one.
    • getRealm

      public String getRealm()
      Returns the realm obtained from callback or the default one.
      Returns:
      the realm obtained from callback or the default one.
    • handleUserRealmPasswordCallbacks

      public byte[] handleUserRealmPasswordCallbacks() throws AuthenticationMechanismException
      Handles callbacks for user and password information.
      Returns:
      the salted password, never null.
      Throws:
      AuthenticationMechanismException - if the callback handler does not support credential acquisition.