org.ldaptive.auth
Class AbstractSearchEntryResolver

java.lang.Object
  extended by org.ldaptive.auth.AbstractSearchOperationFactory
      extended by org.ldaptive.auth.AbstractSearchEntryResolver
All Implemented Interfaces:
EntryResolver
Direct Known Subclasses:
PooledSearchEntryResolver, SearchEntryResolver, WhoAmIEntryResolver

public abstract class AbstractSearchEntryResolver
extends AbstractSearchOperationFactory
implements EntryResolver

Base implementation for search entry resolvers. Uses an object level search on the AuthenticationCriteria.getDn() if no userFilter is configured. If a userFilter is configured, then a search is executed using that filter.

Version:
$Revision: 3059 $ $Date: 2014-09-10 10:01:15 -0400 (Wed, 10 Sep 2014) $
Author:
Middleware Services

Field Summary
 
Fields inherited from class org.ldaptive.auth.AbstractSearchOperationFactory
logger
 
Constructor Summary
AbstractSearchEntryResolver()
           
 
Method Summary
protected  SearchFilter createSearchFilter(AuthenticationCriteria ac)
          Returns a search filter using userFilter and userFilterParameters.
protected  SearchRequest createSearchRequest(AuthenticationCriteria ac)
          Returns a search request for the supplied authentication criteria.
protected  SearchRequest createSearchRequest(AuthenticationCriteria ac, String[] returnAttributes)
          Deprecated. use createSearchRequest(AuthenticationCriteria)
 boolean getAllowMultipleEntries()
          Returns whether entry resolution should fail if multiple entries are found.
 String getBaseDn()
          Returns the base DN.
 DerefAliases getDerefAliases()
          Returns how to dereference aliases.
 boolean getFollowReferrals()
          Returns whether to follow referrals.
 String[] getReturnAttributes()
          Deprecated. return attributes retrieved from the authentication request
 SearchEntryHandler[] getSearchEntryHandlers()
          Returns the search entry handlers.
 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 abstract  SearchResult performLdapSearch(Connection conn, AuthenticationCriteria ac)
          Executes an ldap search with the supplied authentication criteria.
 LdapEntry resolve(Connection conn, AuthenticationCriteria ac)
          Attempts to find the LDAP entry for the supplied authentication criteria, using the supplied connection.
 void setAllowMultipleEntries(boolean b)
          Sets whether entry resolution should fail if multiple entries 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 setReturnAttributes(String... attrs)
          Deprecated. return attributes retrieved from the authentication request
 void setSearchEntryHandlers(SearchEntryHandler... handlers)
          Sets the search entry handlers.
 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

AbstractSearchEntryResolver

public AbstractSearchEntryResolver()
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

getAllowMultipleEntries

public boolean getAllowMultipleEntries()
Returns whether entry resolution should fail if multiple entries are found.

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

setAllowMultipleEntries

public void setAllowMultipleEntries(boolean b)
Sets whether entry resolution should fail if multiple entries are found. If false an exception will be thrown if resolve(Connection, AuthenticationCriteria) finds more than one entry matching it's filter. Otherwise the first entry found is returned.

Parameters:
b - whether multiple entries are allowed

getSubtreeSearch

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

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

setSubtreeSearch

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

Parameters:
b - whether the entry 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

getReturnAttributes

@Deprecated
public String[] getReturnAttributes()
Deprecated. return attributes retrieved from the authentication request

Returns the return attributes.

Returns:
attributes to return

setReturnAttributes

@Deprecated
public void setReturnAttributes(String... attrs)
Deprecated. return attributes retrieved from the authentication request

Sets the return attributes.

Parameters:
attrs - to return

getSearchEntryHandlers

public SearchEntryHandler[] getSearchEntryHandlers()
Returns the search entry handlers.

Returns:
search entry handlers

setSearchEntryHandlers

public void setSearchEntryHandlers(SearchEntryHandler... handlers)
Sets the search entry handlers.

Parameters:
handlers - search entry handlers

performLdapSearch

protected abstract SearchResult performLdapSearch(Connection conn,
                                                  AuthenticationCriteria ac)
                                           throws LdapException
Executes an ldap search with the supplied authentication criteria.

Parameters:
conn - that the user attempted to bind on
ac - authentication criteria associated with the user
Returns:
search result
Throws:
LdapException - if an error occurs attempting the search

createSearchFilter

protected SearchFilter createSearchFilter(AuthenticationCriteria ac)
Returns a search filter using userFilter and userFilterParameters. AuthenticationRequest.getUser() is injected with a named parameter of 'user', AuthenticationCriteria.getDn() is injected with a named parameter of 'dn'.

Parameters:
ac - authentication criteria
Returns:
search filter

createSearchRequest

@Deprecated
protected SearchRequest createSearchRequest(AuthenticationCriteria ac,
                                                       String[] returnAttributes)
Deprecated. use createSearchRequest(AuthenticationCriteria)

Returns a search request for the supplied authentication criteria. If no userFilter is defined then an object level search on the authentication criteria DN is returned. Otherwise the userFilter, baseDn and subtreeSearch are used to create the search request.

Parameters:
ac - authentication criteria containing a DN
returnAttributes - to request
Returns:
search request

createSearchRequest

protected SearchRequest createSearchRequest(AuthenticationCriteria ac)
Returns a search request for the supplied authentication criteria. If no userFilter is defined then an object level search on the authentication criteria DN is returned. Otherwise the userFilter, baseDn and subtreeSearch are used to create the search request.

Parameters:
ac - authentication criteria containing a DN
Returns:
search request

resolve

public LdapEntry resolve(Connection conn,
                         AuthenticationCriteria ac)
                  throws LdapException
Attempts to find the LDAP entry for the supplied authentication criteria, using the supplied connection. The supplied connection should not be closed in this method.

Specified by:
resolve in interface EntryResolver
Parameters:
conn - that authentication occurred on
ac - authentication criteria used to perform the authentication
Returns:
ldap entry
Throws:
LdapException - if an LDAP error occurs


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