Class MechanismUtil

java.lang.Object
org.wildfly.security.mechanism._private.MechanismUtil

public final class MechanismUtil extends Object
Utils to be used by authentication mechanism (SASL or HTTP) implementations.
Author:
David M. Lloyd
  • Method Details

    • getPasswordCredential

      public static <S extends Password> S getPasswordCredential(String userName, CallbackHandler callbackHandler, Class<S> passwordType, String passwordAlgorithm, AlgorithmParameterSpec matchParameters, AlgorithmParameterSpec generateParameters, Supplier<Provider[]> providers, ElytronMessages log) throws AuthenticationMechanismException
      Get a password from a client or server callback, falling back to clear password if needed. Note that the parameters, while optional, may be required on the client side of some mechanisms in order to ensure that the encoded password is compatible with the server challenge.
      Type Parameters:
      S - the password type
      Parameters:
      userName - the user name to report for error reporting purposes (must not be null)
      callbackHandler - the callback handler (must not be null)
      passwordType - the password class (must not be null)
      passwordAlgorithm - the password algorithm name (must not be null)
      matchParameters - the optional parameters to match (may be null)
      generateParameters - the optional default parameters to use if the password must be generated (may be null)
      providers - the security providers to use with the PasswordFactory
      log - mechanism specific logger
      Returns:
      the password
      Throws:
      AuthenticationMechanismException - if there is an error retrieving the password
    • handleCallbacks

      public static void handleCallbacks(ElytronMessages log, CallbackHandler callbackHandler, Callback... callbacks) throws AuthenticationMechanismException, UnsupportedCallbackException
      A varargs wrapper method for callback handler invocation.
      Parameters:
      log - the logger for error purposes
      callbackHandler - the callback handler
      callbacks - the callbacks
      Throws:
      AuthenticationMechanismException - if the callback handler fails for some reason
      UnsupportedCallbackException - if the callback handler throws this exception
    • computeIfAbsent

      public static <R> R computeIfAbsent(HttpScope scope, String key, Function<String,R> mappingFunction)
      Get or compute the value for the given key in HttpScope, storing the computed value (if one is generated). The function must not generate a null value or an unspecified exception will result.
      Type Parameters:
      R - the type of returned value
      Parameters:
      scope - the HTTP scope to store computed value (must not be null)
      key - the key to retrieve (must not be null)
      mappingFunction - the function to apply to acquire the value (must not be null)
      Returns:
      the stored or new value (not null)