public class Authenticator extends Object
Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
logger
Logger for this class.
|
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.
|
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 |
resolveDn(String user)
This will attempt to find the DN for the supplied user.
|
protected LdapEntry |
resolveEntry(AuthenticationRequest request,
AuthenticationHandlerResponse response,
AuthenticationCriteria criteria)
Attempts to find the ldap entry for the supplied DN.
|
void |
setAuthenticationHandler(AuthenticationHandler handler)
Sets the authentication handler.
|
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.
|
String |
toString() |
protected AuthenticationResponse |
validateInput(String dn,
AuthenticationRequest request)
Validates the authentication request and resolved DN.
|
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 AuthenticationResponseHandler[] getAuthenticationResponseHandlers()
public void setAuthenticationResponseHandlers(AuthenticationResponseHandler... handlers)
handlers
- authentication response handlerspublic String resolveDn(String user) throws LdapException
DnResolver.resolve(String)
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 LdapEntry resolveEntry(AuthenticationRequest request, AuthenticationHandlerResponse response, AuthenticationCriteria criteria) throws LdapException
SearchEntryResolver
is used if return attributes have been requested. If none of these criteria is met, a NoOpDnResolver
is used.request
- authentication requestresponse
- from the authentication handlercriteria
- needed by the entry resolverLdapException
- if an error occurs resolving the entryCopyright © 2021. All rights reserved.