public class Authenticator extends Object
| Modifier and Type | Field and Description |
|---|---|
private AuthenticationHandler |
authenticationHandler
Handler to handle authentication.
|
private AuthenticationRequestHandler[] |
authenticationRequestHandlers
Handlers to handle authentication requests.
|
private AuthenticationResponseHandler[] |
authenticationResponseHandlers
Handlers to handle authentication responses.
|
private DnResolver |
dnResolver
For finding user DNs.
|
private EntryResolver |
entryResolver
For finding user entries.
|
protected Logger |
logger
Logger for this class.
|
private static EntryResolver |
NOOP_RESOLVER
NoOp entry resolver.
|
private boolean |
resolveEntryOnFailure
Whether to execute the entry resolver on authentication failure.
|
private String[] |
returnAttributes
User attributes to return.
|
| Constructor and Description |
|---|
Authenticator()
Default constructor.
|
Authenticator(DnResolver resolver,
AuthenticationHandler handler)
Creates a new authenticator.
|
| Modifier and Type | Method and Description |
|---|---|
AuthenticationResponse |
authenticate(AuthenticationRequest request)
Authenticate the user in the supplied request.
|
protected AuthenticationResponse |
authenticate(String dn,
AuthenticationRequest request)
Validates input and performs authentication using an
AuthenticationHandler. |
AuthenticationHandler |
getAuthenticationHandler()
Returns the authentication handler.
|
AuthenticationRequestHandler[] |
getAuthenticationRequestHandlers()
Returns the authentication request handlers.
|
AuthenticationResponseHandler[] |
getAuthenticationResponseHandlers()
Returns the authentication response handlers.
|
DnResolver |
getDnResolver()
Returns the DN resolver.
|
EntryResolver |
getEntryResolver()
Returns the entry resolver.
|
boolean |
getResolveEntryOnFailure()
Returns whether to execute the entry resolver on authentication failure.
|
String[] |
getReturnAttributes()
Returns the return attributes.
|
protected AuthenticationRequest |
processRequest(String dn,
AuthenticationRequest request)
Creates a new authentication request applying any applicable configuration on this authenticator.
|
String |
resolveDn(User user)
This will attempt to find the DN for the supplied user.
|
protected LdapEntry |
resolveEntry(AuthenticationCriteria criteria,
AuthenticationHandlerResponse response)
Attempts to find the ldap entry for the supplied DN.
|
void |
setAuthenticationHandler(AuthenticationHandler handler)
Sets the authentication handler.
|
void |
setAuthenticationRequestHandlers(AuthenticationRequestHandler... handlers)
Sets the authentication request handlers.
|
void |
setAuthenticationResponseHandlers(AuthenticationResponseHandler... handlers)
Sets the authentication response handlers.
|
void |
setDnResolver(DnResolver resolver)
Sets the DN resolver.
|
void |
setEntryResolver(EntryResolver resolver)
Sets the entry resolver.
|
void |
setResolveEntryOnFailure(boolean b)
Sets whether to execute the entry resolver on authentication failure.
|
void |
setReturnAttributes(String... attrs)
Sets the return attributes.
|
String |
toString() |
protected AuthenticationResponse |
validateInput(String dn,
AuthenticationRequest request)
Validates the authentication request and resolved DN.
|
private static final EntryResolver NOOP_RESOLVER
protected final Logger logger
private DnResolver dnResolver
private AuthenticationHandler authenticationHandler
private EntryResolver entryResolver
private String[] returnAttributes
AuthenticationRequest.getReturnAttributes().private AuthenticationRequestHandler[] authenticationRequestHandlers
private AuthenticationResponseHandler[] authenticationResponseHandlers
private boolean resolveEntryOnFailure
public Authenticator()
public Authenticator(DnResolver resolver, AuthenticationHandler handler)
resolver - dn resolverhandler - authentication handlerpublic DnResolver getDnResolver()
public void setDnResolver(DnResolver resolver)
resolver - for finding DNspublic AuthenticationHandler getAuthenticationHandler()
public void setAuthenticationHandler(AuthenticationHandler handler)
handler - for performing authenticationpublic EntryResolver getEntryResolver()
public void setEntryResolver(EntryResolver resolver)
resolver - for finding entriespublic boolean getResolveEntryOnFailure()
public void setResolveEntryOnFailure(boolean b)
b - whether to execute the entry resolverpublic String[] getReturnAttributes()
public void setReturnAttributes(String... attrs)
attrs - return attributespublic AuthenticationRequestHandler[] getAuthenticationRequestHandlers()
public void setAuthenticationRequestHandlers(AuthenticationRequestHandler... handlers)
handlers - authentication request handlerspublic AuthenticationResponseHandler[] getAuthenticationResponseHandlers()
public void setAuthenticationResponseHandlers(AuthenticationResponseHandler... handlers)
handlers - authentication response handlerspublic String resolveDn(User user) throws LdapException
DnResolver.resolve(User) is invoked to perform this
operation.user - to find DN forLdapException - if an LDAP error occurs during resolutionpublic AuthenticationResponse authenticate(AuthenticationRequest request) throws LdapException
request - authentication requestLdapException - if an LDAP error occursprotected AuthenticationResponse authenticate(String dn, AuthenticationRequest request) throws LdapException
AuthenticationHandler. Executes any configured AuthenticationResponseHandler.dn - to authenticate asrequest - containing authentication parametersLdapException - if an LDAP error occursprotected AuthenticationResponse validateInput(String dn, AuthenticationRequest request)
dn - to validaterequest - to validateprotected AuthenticationRequest processRequest(String dn, AuthenticationRequest request) throws LdapException
dn - to processrequest - to processLdapException - if an error occurs with a request handlerprotected LdapEntry resolveEntry(AuthenticationCriteria criteria, AuthenticationHandlerResponse response) throws LdapException
SearchEntryResolver is used if return attributes have been requested. If none of these criteria is met, a NoOpDnResolver is used.criteria - needed by the entry resolverresponse - from the authentication handlerLdapException - if an error occurs resolving the entryCopyright © 2003-2019 Virginia Tech. All Rights Reserved.