Package org.wildfly.security.http.basic
Class BasicAuthenticationMechanism
- java.lang.Object
-
- org.wildfly.security.mechanism.http.UsernamePasswordAuthenticationMechanism
-
- org.wildfly.security.http.basic.BasicAuthenticationMechanism
-
- All Implemented Interfaces:
HttpServerAuthenticationMechanism
final class BasicAuthenticationMechanism extends UsernamePasswordAuthenticationMechanism
Implementation of the HTTP BASIC authentication mechanism- Author:
- Darran Lofthouse
-
-
Field Summary
Fields Modifier and Type Field Description private static String
CHALLENGE_PREFIX
private String
configuredRealm
private boolean
includeCharset
private static int
PREFIX_LENGTH
private boolean
silent
If silent is true then this mechanism will only take effect if there is an Authorization header.(package private) static String
SILENT
-
Fields inherited from class org.wildfly.security.mechanism.http.UsernamePasswordAuthenticationMechanism
callbackHandler
-
-
Constructor Summary
Constructors Constructor Description BasicAuthenticationMechanism(CallbackHandler callbackHandler, String configuredRealm, boolean silent, boolean includeCharset)
Construct a new instance ofBasicAuthenticationMechanism
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
evaluateRequest(HttpServerRequest request)
Evaluate the current request and attempt to authenticate if appropriate.String
getMechanismName()
Get the name of this mechanism, where appropriate this should be the IANA registered name.private void
prepareResponse(HttpServerRequest request, String realmName, HttpServerResponse response)
-
Methods inherited from class org.wildfly.security.mechanism.http.UsernamePasswordAuthenticationMechanism
authenticate, authorize, fail, succeed
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.wildfly.security.http.HttpServerAuthenticationMechanism
dispose, getNegotiatedProperty, getNegotiationProperty
-
-
-
-
Field Detail
-
SILENT
static final String SILENT
- See Also:
- Constant Field Values
-
CHALLENGE_PREFIX
private static final String CHALLENGE_PREFIX
- See Also:
- Constant Field Values
-
PREFIX_LENGTH
private static final int PREFIX_LENGTH
-
includeCharset
private final boolean includeCharset
-
configuredRealm
private final String configuredRealm
-
silent
private final boolean silent
If silent is true then this mechanism will only take effect if there is an Authorization header. This allows you to combine basic auth with form auth, so human users will use form based auth, but allows programmatic clients to login using basic auth.
-
-
Constructor Detail
-
BasicAuthenticationMechanism
BasicAuthenticationMechanism(CallbackHandler callbackHandler, String configuredRealm, boolean silent, boolean includeCharset)
Construct a new instance ofBasicAuthenticationMechanism
.- Parameters:
callbackHandler
- theCallbackHandler
to use to verify the supplied credentials and to notify to establish the current identity.configuredRealm
- a configured realm name from the configuration.includeCharset
- should the charset be included in the challenge.
-
-
Method Detail
-
getMechanismName
public String getMechanismName()
Description copied from interface:HttpServerAuthenticationMechanism
Get the name of this mechanism, where appropriate this should be the IANA registered name.- Returns:
- the name of the mechanism.
- See Also:
HttpServerAuthenticationMechanism.getMechanismName()
-
evaluateRequest
public void evaluateRequest(HttpServerRequest request) throws HttpAuthenticationException
Description copied from interface:HttpServerAuthenticationMechanism
Evaluate the current request and attempt to authenticate if appropriate. The mechanism should call the appropriate callback methods on the {link HttpServerResponse} to both indicate the outcome of the evaluation and to register anyHttpServerMechanismsResponder
as required.- Parameters:
request
- representation of the HTTP request.- Throws:
HttpAuthenticationException
- See Also:
HttpServerAuthenticationMechanism.evaluateRequest(HttpServerRequest)
-
prepareResponse
private void prepareResponse(HttpServerRequest request, String realmName, HttpServerResponse response)
-
-