org.ldaptive.auth
Class Authenticator

java.lang.Object
  extended by org.ldaptive.auth.Authenticator

public class Authenticator
extends Object

Provides functionality to authenticate users against an ldap directory.

Version:
$Revision: 2885 $ $Date: 2014-02-05 16:28:49 -0500 (Wed, 05 Feb 2014) $
Author:
Middleware Services

Field Summary
protected  org.slf4j.Logger logger
          Logger for this class.
 
Constructor Summary
Authenticator()
          Default constructor.
Authenticator(DnResolver resolver, AuthenticationHandler handler)
          Creates a new authenticator.
 
Method Summary
 AuthenticationResponse authenticate(AuthenticationRequest request)
          Authenticate the user in the supplied request.
protected  AuthenticationResponse authenticate(String dn, AuthenticationRequest request)
          Performs authentication by opening a new connection to the LDAP and binding as the supplied DN.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected final org.slf4j.Logger logger
Logger for this class.

Constructor Detail

Authenticator

public Authenticator()
Default constructor.


Authenticator

public Authenticator(DnResolver resolver,
                     AuthenticationHandler handler)
Creates a new authenticator.

Parameters:
resolver - dn resolver
handler - authentication handler
Method Detail

getDnResolver

public DnResolver getDnResolver()
Returns the DN resolver.

Returns:
DN resolver

setDnResolver

public void setDnResolver(DnResolver resolver)
Sets the DN resolver.

Parameters:
resolver - for finding DNs

getAuthenticationHandler

public AuthenticationHandler getAuthenticationHandler()
Returns the authentication handler.

Returns:
authentication handler

setAuthenticationHandler

public void setAuthenticationHandler(AuthenticationHandler handler)
Sets the authentication handler.

Parameters:
handler - for performing authentication

getEntryResolver

public EntryResolver getEntryResolver()
Returns the entry resolver.

Returns:
entry resolver

setEntryResolver

public void setEntryResolver(EntryResolver resolver)
Sets the entry resolver.

Parameters:
resolver - for finding entries

getResolveEntryOnFailure

public boolean getResolveEntryOnFailure()
Returns whether to execute the entry resolver on authentication failure.

Returns:
whether to execute the entry resolver on authentication failure

setResolveEntryOnFailure

public void setResolveEntryOnFailure(boolean b)
Sets whether to execute the entry resolver on authentication failure.

Parameters:
b - whether to execute the entry resolver

getAuthenticationResponseHandlers

public AuthenticationResponseHandler[] getAuthenticationResponseHandlers()
Returns the authentication response handlers.

Returns:
authentication response handlers

setAuthenticationResponseHandlers

public void setAuthenticationResponseHandlers(AuthenticationResponseHandler... handlers)
Sets the authentication response handlers.

Parameters:
handlers - authentication response handlers

resolveDn

public String resolveDn(String user)
                 throws LdapException
This will attempt to find the DN for the supplied user. DnResolver.resolve(String) is invoked to perform this operation.

Parameters:
user - to find DN for
Returns:
user DN
Throws:
LdapException - if an LDAP error occurs during resolution

authenticate

public AuthenticationResponse authenticate(AuthenticationRequest request)
                                    throws LdapException
Authenticate the user in the supplied request.

Parameters:
request - authentication request
Returns:
response containing the ldap entry of the user authenticated
Throws:
LdapException - if an LDAP error occurs

authenticate

protected AuthenticationResponse authenticate(String dn,
                                              AuthenticationRequest request)
                                       throws LdapException
Performs authentication by opening a new connection to the LDAP and binding as the supplied DN. If return attributes have been request, the user entry will be searched on the same connection.

Parameters:
dn - to authenticate as
request - containing authentication parameters
Returns:
ldap entry for the supplied DN
Throws:
LdapException - if an LDAP error occurs

validateInput

protected AuthenticationResponse validateInput(String dn,
                                               AuthenticationRequest request)
Validates the authentication request and resolved DN. Returns an authentication response if validation failed.

Parameters:
dn - to validate
request - to validate
Returns:
authentication response if validation failed, otherwise null

resolveEntry

protected LdapEntry resolveEntry(AuthenticationRequest request,
                                 AuthenticationHandlerResponse response,
                                 AuthenticationCriteria criteria)
                          throws LdapException
Attempts to find the ldap entry for the supplied DN. If an entry resolver has been configured it is used. A SearchEntryResolver is used if return attributes have been requested. If none of these criteria is met, a NoOpDnResolver is used.

Parameters:
request - authentication request
response - from the authentication handler
criteria - needed by the entry resolver
Returns:
ldap entry
Throws:
LdapException - if an error occurs resolving the entry

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2003-2015 Virginia Tech. All Rights Reserved.