Class DefaultDirContextValidator

java.lang.Object
org.springframework.ldap.pool.validation.DefaultDirContextValidator
All Implemented Interfaces:
DirContextValidator

public class DefaultDirContextValidator extends Object implements DirContextValidator
Default DirContext validator that executes DirContext.search(String, String, SearchControls). The name, filter and SearchControls are all configurable. There is no special handling for read only versus read write DirContexts.

Configuration:
Property Description Required Default
base The name parameter to the search method. No ""
filter The filter parameter to the search method. No "objectclass=*"
searchControls The SearchControls parameter to the search method. No SearchControls.setCountLimit(long) = 1
SearchControls.setReturningAttributes(String[]) = new String[] { "objectclass" }
SearchControls.setTimeLimit(int) = 500
  • Field Details

    • DEFAULT_FILTER

      public static final String DEFAULT_FILTER
      See Also:
    • logger

      protected final org.slf4j.Logger logger
      Logger for this class and sub-classes.
  • Constructor Details

    • DefaultDirContextValidator

      public DefaultDirContextValidator()
      Create the default validator, creates SearchControls with search scope OBJECT_SCOPE, a countLimit of 1, returningAttributes of objectclass and timeLimit of 500. The default base is an empty string and the default filter is objectclass=*
    • DefaultDirContextValidator

      public DefaultDirContextValidator(int searchScope)
      Create a validator with all the defaults of the default constructor, but with the search scope set to the referred value.
      Parameters:
      searchScope - The searchScope to be set in the default SearchControls
  • Method Details

    • getBase

      public String getBase()
      Get the base name.
      Returns:
      the baseName
    • setBase

      public void setBase(String base)
      Set the base name.
      Parameters:
      base - the baseName to set
    • getFilter

      public String getFilter()
      Get the filter.
      Returns:
      the filter
    • setFilter

      public void setFilter(String filter)
      Set the filter.
      Parameters:
      filter - the filter to set
    • getSearchControls

      public SearchControls getSearchControls()
      Get the search controls.
      Returns:
      the searchControls
    • setSearchControls

      public void setSearchControls(SearchControls searchControls)
      Set the search controls.
      Parameters:
      searchControls - the searchControls to set
    • validateDirContext

      public boolean validateDirContext(DirContextType contextType, DirContext dirContext)
      Validates the DirContext. A valid DirContext should be able to answer queries and if applicable write to the directory.
      Specified by:
      validateDirContext in interface DirContextValidator
      Parameters:
      contextType - The type of the DirContext, refers to if ContextSource.getReadOnlyContext() or ContextSource.getReadWriteContext() was called to create the DirContext
      dirContext - The DirContext to validate.
      Returns:
      true if the DirContext operated correctly during validation.