org.springframework.security.ldap
Class SpringSecurityLdapTemplate

java.lang.Object
  extended by org.springframework.ldap.core.LdapTemplate
      extended by org.springframework.security.ldap.SpringSecurityLdapTemplate
All Implemented Interfaces:
InitializingBean, LdapOperations

public class SpringSecurityLdapTemplate
extends LdapTemplate

Extension of Spring LDAP's LdapTemplate class which adds extra functionality required by Spring Security.

Since:
2.0

Nested Class Summary
 
Nested classes/interfaces inherited from class org.springframework.ldap.core.LdapTemplate
LdapTemplate.MappingCollectingNameClassPairCallbackHandler
 
Field Summary
static String[] NO_ATTRS
           
 
Constructor Summary
SpringSecurityLdapTemplate(ContextSource contextSource)
           
 
Method Summary
 boolean compare(String dn, String attributeName, Object value)
          Performs an LDAP compare operation of the value of an attribute for a particular directory entry.
 DirContextOperations retrieveEntry(String dn, String[] attributesToRetrieve)
          Composes an object from the attributes of the given DN.
 Set<String> searchForSingleAttributeValues(String base, String filter, Object[] params, String attributeName)
          Performs a search using the supplied filter and returns the union of the values of the named attribute found in all entries matched by the search.
 DirContextOperations searchForSingleEntry(String base, String filter, Object[] params)
          Performs a search, with the requirement that the search shall return a single directory entry, and uses the supplied mapper to create the object from that entry.
 void setSearchControls(SearchControls searchControls)
          Sets the search controls which will be used for search operations by the template.
 
Methods inherited from class org.springframework.ldap.core.LdapTemplate
afterPropertiesSet, authenticate, authenticate, authenticate, authenticate, authenticate, authenticate, authenticate, authenticate, bind, bind, bind, deleteRecursively, executeReadOnly, executeReadWrite, getContextSource, list, list, list, list, list, list, listBindings, listBindings, listBindings, listBindings, listBindings, listBindings, listBindings, listBindings, lookup, lookup, lookup, lookup, lookup, lookup, lookup, lookup, lookup, lookup, lookupContext, lookupContext, modifyAttributes, modifyAttributes, modifyAttributes, rebind, rebind, rebind, rename, rename, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, search, searchForObject, searchForObject, setContextSource, setIgnoreNameNotFoundException, setIgnorePartialResultException, unbind, unbind, unbind, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ATTRS

public static final String[] NO_ATTRS
Constructor Detail

SpringSecurityLdapTemplate

public SpringSecurityLdapTemplate(ContextSource contextSource)
Method Detail

compare

public boolean compare(String dn,
                       String attributeName,
                       Object value)
Performs an LDAP compare operation of the value of an attribute for a particular directory entry.

Parameters:
dn - the entry who's attribute is to be used
attributeName - the attribute who's value we want to compare
value - the value to be checked against the directory value
Returns:
true if the supplied value matches that in the directory

retrieveEntry

public DirContextOperations retrieveEntry(String dn,
                                          String[] attributesToRetrieve)
Composes an object from the attributes of the given DN.

Parameters:
dn - the directory entry which will be read
attributesToRetrieve - the named attributes which will be retrieved from the directory entry.
Returns:
the object created by the mapper

searchForSingleAttributeValues

public Set<String> searchForSingleAttributeValues(String base,
                                                  String filter,
                                                  Object[] params,
                                                  String attributeName)
Performs a search using the supplied filter and returns the union of the values of the named attribute found in all entries matched by the search. Note that one directory entry may have several values for the attribute. Intended for role searches and similar scenarios.

Parameters:
base - the DN to search in
filter - search filter to use
params - the parameters to substitute in the search filter
attributeName - the attribute who's values are to be retrieved.
Returns:
the set of String values for the attribute as a union of the values found in all the matching entries.

searchForSingleEntry

public DirContextOperations searchForSingleEntry(String base,
                                                 String filter,
                                                 Object[] params)
Performs a search, with the requirement that the search shall return a single directory entry, and uses the supplied mapper to create the object from that entry.

Ignores PartialResultException if thrown, for compatibility with Active Directory (see LdapTemplate.setIgnorePartialResultException(boolean)).

Parameters:
base - the search base, relative to the base context supplied by the context source.
filter - the LDAP search filter
params - parameters to be substituted in the search.
Returns:
a DirContextOperations instance created from the matching entry.
Throws:
IncorrectResultSizeDataAccessException - if no results are found or the search returns more than one result.

setSearchControls

public void setSearchControls(SearchControls searchControls)
Sets the search controls which will be used for search operations by the template.

Parameters:
searchControls - the SearchControls instance which will be cached in the template.