Class UsernamePasswordAuthenticationMechanism
java.lang.Object
org.wildfly.security.mechanism.http.UsernamePasswordAuthenticationMechanism
- All Implemented Interfaces:
HttpServerAuthenticationMechanism
public abstract class UsernamePasswordAuthenticationMechanism
extends Object
implements HttpServerAuthenticationMechanism
A base class for HTTP mechanisms that operate on validation of plain text usernames and passwords.
- Author:
- Darran Lofthouse
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedUsernamePasswordAuthenticationMechanism(CallbackHandler callbackHandler) Constructs a newUsernamePasswordAuthenticationMechanisminstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanauthenticate(String realmName, String username, char[] password) Authenticates the user for provided realm using their username and password.protected booleanChecks if the user is authorized.protected voidfail()Sends the information to the callbackHandler that the authorization failed.protected voidsucceed()Sends the information to the callbackHandler that the authorization succeeded.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.wildfly.security.http.HttpServerAuthenticationMechanism
dispose, evaluateRequest, getMechanismName, getNegotiatedProperty, getNegotiationProperty
-
Field Details
-
callbackHandler
-
-
Constructor Details
-
UsernamePasswordAuthenticationMechanism
Constructs a newUsernamePasswordAuthenticationMechanisminstance.- Parameters:
callbackHandler- the CallbackHandler used for authentication.
-
-
Method Details
-
authenticate
protected boolean authenticate(String realmName, String username, char[] password) throws HttpAuthenticationException Authenticates the user for provided realm using their username and password.- Parameters:
realmName- the realm for which the user is authenticating.username- the username of the authenticating user.password- the password of the authenticating user.- Returns:
trueif the user is authenticated for the realm,falseotherwise.- Throws:
HttpAuthenticationException- if there was an IOException caused by the CallbackHandler.
-
authorize
Checks if the user is authorized.- Parameters:
username- the username to authorize.- Returns:
trueif the user is authorized,falseotherwise.- Throws:
HttpAuthenticationException- if there was an IOException caused by the CallbackHandler.
-
succeed
Sends the information to the callbackHandler that the authorization succeeded.- Throws:
IOException- if an input or output error occurs.UnsupportedCallbackException- if the implementation of callbackHandler does not support the specified Callback type.
-
fail
Sends the information to the callbackHandler that the authorization failed.- Throws:
IOException- if an input or output error occurs.UnsupportedCallbackException- if the implementation of callbackHandler does not support the specified Callback type.
-