Class MechanismUtil
java.lang.Object
org.wildfly.security.mechanism._private.MechanismUtil
Utils to be used by authentication mechanism (SASL or HTTP) implementations.
- Author:
- David M. Lloyd
-
Method Summary
Modifier and TypeMethodDescriptionstatic <R> RcomputeIfAbsent(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).static <S extends Password>
SgetPasswordCredential(String userName, CallbackHandler callbackHandler, Class<S> passwordType, String passwordAlgorithm, AlgorithmParameterSpec matchParameters, AlgorithmParameterSpec generateParameters, Supplier<Provider[]> providers, ElytronMessages log) Get a password from a client or server callback, falling back to clear password if needed.static voidhandleCallbacks(ElytronMessages log, CallbackHandler callbackHandler, Callback... callbacks) A varargs wrapper method for callback handler invocation.
-
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 benull)callbackHandler- the callback handler (must not benull)passwordType- the password class (must not benull)passwordAlgorithm- the password algorithm name (must not benull)matchParameters- the optional parameters to match (may benull)generateParameters- the optional default parameters to use if the password must be generated (may benull)providers- the security providers to use with thePasswordFactorylog- 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 purposescallbackHandler- the callback handlercallbacks- the callbacks- Throws:
AuthenticationMechanismException- if the callback handler fails for some reasonUnsupportedCallbackException- 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 anullvalue 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 benull)key- the key to retrieve (must not benull)mappingFunction- the function to apply to acquire the value (must not benull)- Returns:
- the stored or new value (not
null)
-