org.ldaptive.auth
Class AbstractSearchDnResolver

java.lang.Object
  extended by org.ldaptive.auth.AbstractSearchOperationFactory
      extended by org.ldaptive.auth.AbstractSearchDnResolver
All Implemented Interfaces:
DnResolver, DnResolverEx
Direct Known Subclasses:
PooledSearchDnResolver, SearchDnResolver

public abstract class AbstractSearchDnResolver
extends AbstractSearchOperationFactory
implements DnResolver, DnResolverEx

Base implementation for search dn resolvers.

Version:
$Revision: 3146 $ $Date: 2016-04-08 18:05:47 -0400 (Fri, 08 Apr 2016) $
Author:
Middleware Services

Field Summary
 
Fields inherited from class org.ldaptive.auth.AbstractSearchOperationFactory
logger
 
Constructor Summary
AbstractSearchDnResolver()
           
 
Method Summary
protected  SearchFilter createSearchFilter(String user)
          See createSearchFilter(User).
protected  SearchFilter createSearchFilter(User user)
          Returns a search filter using userFilter and userFilterParameters.
protected  SearchRequest createSearchRequest(SearchFilter filter)
          Returns a search request for searching for a single entry in an LDAP, returning no attributes.
 boolean getAllowMultipleDns()
          Returns whether DN resolution should fail if multiple DNs are found.
 String getBaseDn()
          Returns the base DN.
protected abstract  Connection getConnection()
          Retrieve a connection that is ready for use.
 DerefAliases getDerefAliases()
          Returns how to dereference aliases.
 boolean getFollowReferrals()
          Returns whether to follow referrals.
 boolean getSubtreeSearch()
          Returns whether subtree searching will be used.
 String getUserFilter()
          Returns the filter used to search for the user.
 Object[] getUserFilterParameters()
          Returns the filter parameters used to search for the user.
protected  SearchResult performLdapSearch(SearchFilter filter)
          Executes the ldap search operation with the supplied filter.
 String resolve(String user)
          See resolve(User).
 String resolve(User user)
          Attempts to find the DN for the supplied user.
protected  String resolveDn(LdapEntry entry)
          Returns the DN for the supplied ldap entry.
 void setAllowMultipleDns(boolean b)
          Sets whether DN resolution should fail if multiple DNs are found.
 void setBaseDn(String dn)
          Sets the base DN.
 void setDerefAliases(DerefAliases da)
          Sets how to dereference aliases.
 void setFollowReferrals(boolean b)
          Sets whether to follow referrals.
 void setSubtreeSearch(boolean b)
          Sets whether subtree searching will be used.
 void setUserFilter(String filter)
          Sets the filter used to search for the user.
 void setUserFilterParameters(Object[] filterParams)
          Sets the filter parameters used to search for the user.
 
Methods inherited from class org.ldaptive.auth.AbstractSearchOperationFactory
createSearchOperation, getSearchCache, getSearchExceptionHandler, getSearchResponseHandlers, setSearchCache, setSearchExceptionHandler, setSearchResponseHandlers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSearchDnResolver

public AbstractSearchDnResolver()
Method Detail

getBaseDn

public String getBaseDn()
Returns the base DN.

Returns:
base DN

setBaseDn

public void setBaseDn(String dn)
Sets the base DN.

Parameters:
dn - base DN

getUserFilter

public String getUserFilter()
Returns the filter used to search for the user.

Returns:
filter for searching

setUserFilter

public void setUserFilter(String filter)
Sets the filter used to search for the user.

Parameters:
filter - for searching

getUserFilterParameters

public Object[] getUserFilterParameters()
Returns the filter parameters used to search for the user.

Returns:
filter parameters

setUserFilterParameters

public void setUserFilterParameters(Object[] filterParams)
Sets the filter parameters used to search for the user.

Parameters:
filterParams - filter parameters

getAllowMultipleDns

public boolean getAllowMultipleDns()
Returns whether DN resolution should fail if multiple DNs are found.

Returns:
whether an exception will be thrown if multiple DNs are found

setAllowMultipleDns

public void setAllowMultipleDns(boolean b)
Sets whether DN resolution should fail if multiple DNs are found. If false an exception will be thrown if resolve(User) finds more than one DN matching it's filter. Otherwise the first DN found is returned.

Parameters:
b - whether multiple DNs are allowed

getSubtreeSearch

public boolean getSubtreeSearch()
Returns whether subtree searching will be used.

Returns:
whether the DN will be searched for over the entire base

setSubtreeSearch

public void setSubtreeSearch(boolean b)
Sets whether subtree searching will be used. If true, the DN used for authenticating will be searched for over the entire getBaseDn(). Otherwise the DN will be searched for in the getBaseDn() context.

Parameters:
b - whether the DN will be searched for over the entire base

getDerefAliases

public DerefAliases getDerefAliases()
Returns how to dereference aliases.

Returns:
how to dereference aliases

setDerefAliases

public void setDerefAliases(DerefAliases da)
Sets how to dereference aliases.

Parameters:
da - how to dereference aliases

getFollowReferrals

public boolean getFollowReferrals()
Returns whether to follow referrals.

Returns:
whether to follow referrals

setFollowReferrals

public void setFollowReferrals(boolean b)
Sets whether to follow referrals.

Parameters:
b - whether to follow referrals

resolve

public String resolve(String user)
               throws LdapException
See resolve(User).

Specified by:
resolve in interface DnResolver
Parameters:
user - to find DN for
Returns:
user DN
Throws:
LdapException - if the entry resolution fails

resolve

public String resolve(User user)
               throws LdapException
Attempts to find the DN for the supplied user. getUserFilter() is used to look up the DN. The user is provided as the 'user' variable filter parameter. If more than one entry matches the search, the result is controlled by setAllowMultipleDns(boolean).

Specified by:
resolve in interface DnResolverEx
Parameters:
user - to find DN for
Returns:
user DN
Throws:
LdapException - if the entry resolution fails

resolveDn

protected String resolveDn(LdapEntry entry)
Returns the DN for the supplied ldap entry.

Parameters:
entry - to retrieve the DN from
Returns:
dn

createSearchFilter

protected SearchFilter createSearchFilter(String user)
See createSearchFilter(User).

Parameters:
user - identifier
Returns:
search filter

createSearchFilter

protected SearchFilter createSearchFilter(User user)
Returns a search filter using userFilter and userFilterParameters. The user parameter is injected as a named parameter of 'user'.

Parameters:
user - identifier
Returns:
search filter

createSearchRequest

protected SearchRequest createSearchRequest(SearchFilter filter)
Returns a search request for searching for a single entry in an LDAP, returning no attributes.

Parameters:
filter - to execute
Returns:
search request

performLdapSearch

protected SearchResult performLdapSearch(SearchFilter filter)
                                  throws LdapException
Executes the ldap search operation with the supplied filter.

Parameters:
filter - to execute
Returns:
ldap search result
Throws:
LdapException - if an error occurs

getConnection

protected abstract Connection getConnection()
                                     throws LdapException
Retrieve a connection that is ready for use.

Returns:
connection
Throws:
LdapException - if an error occurs opening the connection


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