Class UsernamePasswordAuthenticationMechanism
- java.lang.Object
-
- org.wildfly.security.mechanism.http.UsernamePasswordAuthenticationMechanism
-
- All Implemented Interfaces:
org.wildfly.security.http.HttpServerAuthenticationMechanism
public abstract class UsernamePasswordAuthenticationMechanism extends Object implements org.wildfly.security.http.HttpServerAuthenticationMechanism
A base class for HTTP mechanisms that operate on validation of plain text usernames and passwords.- Author:
- Darran Lofthouse
-
-
Field Summary
Fields Modifier and Type Field Description protected CallbackHandlercallbackHandler
-
Constructor Summary
Constructors Modifier Constructor Description protectedUsernamePasswordAuthenticationMechanism(CallbackHandler callbackHandler)Constructs a newUsernamePasswordAuthenticationMechanisminstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanauthenticate(String realmName, String username, char[] password)Authenticates the user for provided realm using their username and password.protected booleanauthorize(String username)Checks 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.
-
-
-
Field Detail
-
callbackHandler
protected final CallbackHandler callbackHandler
-
-
Constructor Detail
-
UsernamePasswordAuthenticationMechanism
protected UsernamePasswordAuthenticationMechanism(CallbackHandler callbackHandler)
Constructs a newUsernamePasswordAuthenticationMechanisminstance.- Parameters:
callbackHandler- the CallbackHandler used for authentication.
-
-
Method Detail
-
authenticate
protected boolean authenticate(String realmName, String username, char[] password) throws org.wildfly.security.http.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:
org.wildfly.security.http.HttpAuthenticationException- if there was an IOException caused by the CallbackHandler.
-
authorize
protected boolean authorize(String username) throws org.wildfly.security.http.HttpAuthenticationException
Checks if the user is authorized.- Parameters:
username- the username to authorize.- Returns:
trueif the user is authorized,falseotherwise.- Throws:
org.wildfly.security.http.HttpAuthenticationException- if there was an IOException caused by the CallbackHandler.
-
succeed
protected void succeed() throws IOException, UnsupportedCallbackExceptionSends 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
protected void fail() throws IOException, UnsupportedCallbackExceptionSends 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.
-
-