Class LdapConnectionTemplate

java.lang.Object
org.apache.directory.ldap.client.template.LdapConnectionTemplate
All Implemented Interfaces:
LdapConnectionOperations, ModelFactory

public class LdapConnectionTemplate extends Object implements LdapConnectionOperations, ModelFactory
A facade for LDAP operations that handles all of the boiler plate code for you allowing more concise operations through the use of callbacks.
Author:
Apache Directory Project
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of LdapConnectionTemplate.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.directory.api.ldap.model.message.AddResponse
    add(org.apache.directory.api.ldap.model.message.AddRequest addRequest)
    Adds an entry specified by an AddRequest to the LDAP server.
    org.apache.directory.api.ldap.model.message.AddResponse
    add(org.apache.directory.api.ldap.model.name.Dn dn, org.apache.directory.api.ldap.model.entry.Attribute... attributes)
    Adds an entry specified by a Dn and an array of Attribute's to the LDAP server.
    org.apache.directory.api.ldap.model.message.AddResponse
    add(org.apache.directory.api.ldap.model.name.Dn dn, RequestBuilder<org.apache.directory.api.ldap.model.message.AddRequest> requestBuilder)
    Adds an entry specified by a Dn, to be filled out by a RequestBuilder, to the LDAP server.
    authenticate(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, char[] password)
    Attempts to authenticate the supplied credentials against the first entry found matching the search criteria.
    authenticate(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest, char[] password)
    Attempts to authenticate the supplied credentials against the first entry found matching the search criteria.
    authenticate(org.apache.directory.api.ldap.model.name.Dn userDn, char[] password)
    Attempts to authenticate the supplied credentials.
    authenticate(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, char[] password)
    Attempts to authenticate the supplied credentials against the first entry found matching the search criteria.
    org.apache.directory.api.ldap.model.message.DeleteResponse
    delete(org.apache.directory.api.ldap.model.message.DeleteRequest deleteRequest)
    Deletes an entry specified by a DeleteRequest from the LDAP server.
    org.apache.directory.api.ldap.model.message.DeleteResponse
    delete(org.apache.directory.api.ldap.model.name.Dn dn)
    Deletes an entry specified by Dn from the LDAP server.
    org.apache.directory.api.ldap.model.message.DeleteResponse
    delete(org.apache.directory.api.ldap.model.name.Dn dn, RequestBuilder<org.apache.directory.api.ldap.model.message.DeleteRequest> requestBuilder)
    Deletes an entry specified by Dn, and whose request is configured by a RequestBuilder, from the LDAP server.
    <T> T
    execute(ConnectionCallback<T> connectionCallback)
    Executes the connectionCallback, supplying it a managed connection.
    <T> T
    lookup(org.apache.directory.api.ldap.model.name.Dn dn, String[] attributes, EntryMapper<T> entryMapper)
    Performs a lookup, requesting attributes, and supplies the matching entry to the entryMapper.
    <T> T
    lookup(org.apache.directory.api.ldap.model.name.Dn dn, EntryMapper<T> entryMapper)
    Performs a lookup, and supplies the matching entry to the entryMapper.
    org.apache.directory.api.ldap.model.message.ModifyResponse
    modify(org.apache.directory.api.ldap.model.message.ModifyRequest modifyRequest)
    Modifies an entry specified by a ModifyRequest on the LDAP server.
    org.apache.directory.api.ldap.model.message.ModifyResponse
    modify(org.apache.directory.api.ldap.model.name.Dn dn, RequestBuilder<org.apache.directory.api.ldap.model.message.ModifyRequest> requestBuilder)
    Modifies an entry specified by Dn, and whose request is configured by a RequestBuilder, on the LDAP server.
    void
    modifyPassword(org.apache.directory.api.ldap.model.name.Dn userDn, char[] newPassword)
    Modifies the password for userDn to newPassword using the admin account.
    void
    modifyPassword(org.apache.directory.api.ldap.model.name.Dn userDn, char[] oldPassword, char[] newPassword)
    Modifies the password for userDn from oldPassword to newPassword.
    void
    modifyPassword(org.apache.directory.api.ldap.model.name.Dn userDn, char[] oldPassword, char[] newPassword, boolean asAdmin)
    Modifies the password for userDn from oldPassword to newPassword, optionally using an admin account.
    org.apache.directory.api.ldap.model.message.AddRequest
    newAddRequest(org.apache.directory.api.ldap.model.entry.Entry entry)
    Returns a new AddRequest for the entry.
    org.apache.directory.api.ldap.model.entry.Attribute
    Returns a new Attribute for with the provided name and a null value.
    org.apache.directory.api.ldap.model.entry.Attribute
    newAttribute(String name, byte[]... values)
    Returns a new Attribute for with the provided name and value(s).
    org.apache.directory.api.ldap.model.entry.Attribute
    newAttribute(String name, String... values)
    Returns a new Attribute for with the provided name and value(s).
    org.apache.directory.api.ldap.model.entry.Attribute
    newAttribute(String name, org.apache.directory.api.ldap.model.entry.Value... values)
    Returns a new Attribute for with the provided name and value(s).
    org.apache.directory.api.ldap.model.message.DeleteRequest
    newDeleteRequest(org.apache.directory.api.ldap.model.name.Dn dn)
    Returns a new DeleteRequest for the dn.
    org.apache.directory.api.ldap.model.name.Dn
    Returns a Dn that represents dn.
    org.apache.directory.api.ldap.model.entry.Entry
    Returns a Entry with the specified dn.
    org.apache.directory.api.ldap.model.entry.Entry
    newEntry(org.apache.directory.api.ldap.model.name.Dn dn)
    Returns a Entry with the specified dn.
    org.apache.directory.api.ldap.model.message.ModifyRequest
    Returns a new ModifyRequest for the dn.
    org.apache.directory.api.ldap.model.message.ModifyRequest
    newModifyRequest(org.apache.directory.api.ldap.model.name.Dn dn)
    Returns a new ModifyRequest for the dn.
    org.apache.directory.api.ldap.model.message.SearchRequest
    newSearchRequest(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope)
    Returns a new SearchRequest over baseDn in scope matching filter returning all normal attributes for each matching entry.
    org.apache.directory.api.ldap.model.message.SearchRequest
    newSearchRequest(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
    Returns a new SearchRequest over baseDn in scope matching filter returning attributes for each matching entry.
    org.apache.directory.api.ldap.model.message.SearchRequest
    newSearchRequest(String baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope)
    Returns a new SearchRequest over baseDn in scope matching filter returning all normal attributes for each matching entry.
    org.apache.directory.api.ldap.model.message.SearchRequest
    newSearchRequest(String baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
    Returns a new SearchRequest over baseDn in scope matching filter returning attributes for each matching entry.
    org.apache.directory.api.ldap.model.message.SearchRequest
    newSearchRequest(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope)
    Returns a new SearchRequest over baseDn in scope matching filter returning all normal attributes for each matching entry.
    org.apache.directory.api.ldap.model.message.SearchRequest
    newSearchRequest(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
    Returns a new SearchRequest over baseDn in scope matching filter returning attributes for each matching entry.
    org.apache.directory.api.ldap.model.message.SearchRequest
    newSearchRequest(org.apache.directory.api.ldap.model.name.Dn baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope)
    Returns a new SearchRequest over baseDn in scope matching filter returning all normal attributes for each matching entry.
    org.apache.directory.api.ldap.model.message.SearchRequest
    newSearchRequest(org.apache.directory.api.ldap.model.name.Dn baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
    Returns a new SearchRequest over baseDn in scope matching filter returning attributes for each matching entry.
    <T extends org.apache.directory.api.ldap.model.message.ResultResponse>
    T
    responseOrException(T response)
    Checks the supplied response for its result code, and if not ResultCodeEnum#SUCCESS, an exception is thrown.
    <T> List<T>
    search(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
    Searches for the entries matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
    <T> List<T>
    search(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
    Searches for the entries matching the supplied criteria, feeding the result into the entryMapper.
    <T> List<T>
    search(String baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
    Searches for the entries matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
    <T> List<T>
    search(String baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
    Searches for the entries matching the supplied criteria, feeding the result into the entryMapper.
    <T> List<T>
    search(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest, EntryMapper<T> entryMapper)
    Searches for the entries matching the supplied searchRequest, feeding the result into the entryMapper.
    <T> List<T>
    search(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
    Searches for the entries matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
    <T> List<T>
    search(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
    Searches for the entries matching the supplied criteria, feeding the result into the entryMapper.
    <T> List<T>
    search(org.apache.directory.api.ldap.model.name.Dn baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
    Searches for the entries matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
    <T> List<T>
    search(org.apache.directory.api.ldap.model.name.Dn baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
    Searches for the entries matching the supplied criteria, feeding the result into the entryMapper.
    <T> T
    searchFirst(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
    Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
    <T> T
    searchFirst(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
    Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper.
    <T> T
    searchFirst(String baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
    Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
    <T> T
    searchFirst(String baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
    Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper.
    <T> T
    searchFirst(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest, EntryMapper<T> entryMapper)
    Searches for the first entry matching the supplied searchRequest, feeding the result into the entryMapper.
    <T> T
    searchFirst(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
    Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
    <T> T
    searchFirst(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
    Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper.
    <T> T
    searchFirst(org.apache.directory.api.ldap.model.name.Dn baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
    Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
    <T> T
    searchFirst(org.apache.directory.api.ldap.model.name.Dn baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
    Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper.
    void
    Sets the modelFactory implementation for this facade.
    void
    Sets the passwordPolicyResponder implementation for this facade.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LdapConnectionTemplate

      public LdapConnectionTemplate(LdapConnectionPool connectionPool)
      Creates a new instance of LdapConnectionTemplate.
      Parameters:
      connectionPool - The pool to obtain connections from.
  • Method Details

    • add

      public org.apache.directory.api.ldap.model.message.AddResponse add(org.apache.directory.api.ldap.model.name.Dn dn, org.apache.directory.api.ldap.model.entry.Attribute... attributes)
      Adds an entry specified by a Dn and an array of Attribute's to the LDAP server.
      Specified by:
      add in interface LdapConnectionOperations
      Parameters:
      dn - The distinguished name of the new entry
      attributes - The attributes of the new entry
      Returns:
      An AddResponse
    • add

      public org.apache.directory.api.ldap.model.message.AddResponse add(org.apache.directory.api.ldap.model.name.Dn dn, RequestBuilder<org.apache.directory.api.ldap.model.message.AddRequest> requestBuilder)
      Adds an entry specified by a Dn, to be filled out by a RequestBuilder, to the LDAP server.
      Specified by:
      add in interface LdapConnectionOperations
      Parameters:
      dn - The distinguished name of the new entry
      requestBuilder - The request builder
      Returns:
      An AddResponse
    • add

      public org.apache.directory.api.ldap.model.message.AddResponse add(org.apache.directory.api.ldap.model.message.AddRequest addRequest)
      Adds an entry specified by an AddRequest to the LDAP server.
      Specified by:
      add in interface LdapConnectionOperations
      Parameters:
      addRequest - The request
      Returns:
      An AddResponse
    • authenticate

      public PasswordWarning authenticate(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, char[] password) throws PasswordException
      Attempts to authenticate the supplied credentials against the first entry found matching the search criteria. If authentication fails, a PasswordException is thrown. If successful, the response is checked for warnings, and if present, a PasswordWarning is returned. Otherwise, null is returned.
      Specified by:
      authenticate in interface LdapConnectionOperations
      Parameters:
      baseDn - The base DN from which to start the search for the user to authenticate
      filter - The filter selecting the entries
      scope - The scope to look from
      password - The password
      Returns:
      A PasswordWarning or null
      Throws:
      PasswordException - If the authentication failed
      See Also:
    • authenticate

      public PasswordWarning authenticate(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, char[] password) throws PasswordException
      Attempts to authenticate the supplied credentials against the first entry found matching the search criteria. If authentication fails, a PasswordException is thrown. If successful, the response is checked for warnings, and if present, a PasswordWarning is returned. Otherwise, null is returned.
      Specified by:
      authenticate in interface LdapConnectionOperations
      Parameters:
      baseDn - The base DN from which to start the search for the user to authenticate
      filter - The filter selecting the entries
      scope - The scope to look from
      password - The password
      Returns:
      A PasswordWarning or null
      Throws:
      PasswordException - If the authentication failed
      See Also:
    • authenticate

      public PasswordWarning authenticate(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest, char[] password) throws PasswordException
      Attempts to authenticate the supplied credentials against the first entry found matching the search criteria. If authentication fails, a PasswordException is thrown. If successful, the response is checked for warnings, and if present, a PasswordWarning is returned. Otherwise, null is returned.
      Specified by:
      authenticate in interface LdapConnectionOperations
      Parameters:
      searchRequest - The SearchRequst to use to find the user to authenticate
      password - The password
      Returns:
      A PasswordWarning or null
      Throws:
      PasswordException - If the authentication failed
      See Also:
    • authenticate

      public PasswordWarning authenticate(org.apache.directory.api.ldap.model.name.Dn userDn, char[] password) throws PasswordException
      Attempts to authenticate the supplied credentials. If authentication fails, a PasswordException is thrown. If successful, the response is checked for warnings, and if present, a PasswordWarning is returned. Otherwise, null is returned.
      Specified by:
      authenticate in interface LdapConnectionOperations
      Parameters:
      userDn - The distinguished name of the user
      password - The password
      Returns:
      A PasswordWarning or null
      Throws:
      PasswordException - If authentication fails
    • delete

      public org.apache.directory.api.ldap.model.message.DeleteResponse delete(org.apache.directory.api.ldap.model.name.Dn dn)
      Deletes an entry specified by Dn from the LDAP server.
      Specified by:
      delete in interface LdapConnectionOperations
      Parameters:
      dn - The distinguished name of the entry
      Returns:
      A DeleteResponse
    • delete

      public org.apache.directory.api.ldap.model.message.DeleteResponse delete(org.apache.directory.api.ldap.model.name.Dn dn, RequestBuilder<org.apache.directory.api.ldap.model.message.DeleteRequest> requestBuilder)
      Deletes an entry specified by Dn, and whose request is configured by a RequestBuilder, from the LDAP server.
      Specified by:
      delete in interface LdapConnectionOperations
      Parameters:
      dn - The distinguished name of the entry
      requestBuilder - The RequestBuilder
      Returns:
      A DeleteResponse
    • delete

      public org.apache.directory.api.ldap.model.message.DeleteResponse delete(org.apache.directory.api.ldap.model.message.DeleteRequest deleteRequest)
      Deletes an entry specified by a DeleteRequest from the LDAP server.
      Specified by:
      delete in interface LdapConnectionOperations
      Parameters:
      deleteRequest - The request
      Returns:
      A DeleteResponse
    • execute

      public <T> T execute(ConnectionCallback<T> connectionCallback)
      Executes the connectionCallback, supplying it a managed connection.
      Specified by:
      execute in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      connectionCallback - The callback
      Returns:
      Whatever the callback returns
    • lookup

      public <T> T lookup(org.apache.directory.api.ldap.model.name.Dn dn, EntryMapper<T> entryMapper)
      Performs a lookup, and supplies the matching entry to the entryMapper.
      Specified by:
      lookup in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      dn - The distinguished name of the entry
      entryMapper - The mapper from entry to model object
      Returns:
      Whatever the entryMapper returns
    • lookup

      public <T> T lookup(org.apache.directory.api.ldap.model.name.Dn dn, String[] attributes, EntryMapper<T> entryMapper)
      Performs a lookup, requesting attributes, and supplies the matching entry to the entryMapper.
      Specified by:
      lookup in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      dn - The distinguished name of the entry
      attributes - The attributes to be fetched
      entryMapper - The mapper from entry to model object
      Returns:
      Whatever the entryMapper returns
    • modifyPassword

      public void modifyPassword(org.apache.directory.api.ldap.model.name.Dn userDn, char[] newPassword) throws PasswordException
      Modifies the password for userDn to newPassword using the admin account.
      Specified by:
      modifyPassword in interface LdapConnectionOperations
      Parameters:
      userDn - The DN of the entry we want to modify the pwassword for
      newPassword - The new password
      Throws:
      PasswordException - If the password change failed
      See Also:
    • modifyPassword

      public void modifyPassword(org.apache.directory.api.ldap.model.name.Dn userDn, char[] oldPassword, char[] newPassword) throws PasswordException
      Modifies the password for userDn from oldPassword to newPassword.
      Specified by:
      modifyPassword in interface LdapConnectionOperations
      Parameters:
      userDn - The DN of the entry we want to modify the pwassword for
      oldPassword - The old password
      newPassword - The new password
      Throws:
      PasswordException - If the password change failed
      See Also:
    • modifyPassword

      public void modifyPassword(org.apache.directory.api.ldap.model.name.Dn userDn, char[] oldPassword, char[] newPassword, boolean asAdmin) throws PasswordException
      Modifies the password for userDn from oldPassword to newPassword, optionally using an admin account. If asAdmin is true, then the operation is performed in admin context which means oldPassword is may be null.
      Specified by:
      modifyPassword in interface LdapConnectionOperations
      Parameters:
      userDn - The distinguished name of the user
      oldPassword - The users old password (optional if asAdmin is true)
      newPassword - The users new password
      asAdmin - If true, execute in admin context
      Throws:
      PasswordException - If the password modification fails
    • modify

      public org.apache.directory.api.ldap.model.message.ModifyResponse modify(org.apache.directory.api.ldap.model.name.Dn dn, RequestBuilder<org.apache.directory.api.ldap.model.message.ModifyRequest> requestBuilder)
      Modifies an entry specified by Dn, and whose request is configured by a RequestBuilder, on the LDAP server.
      Specified by:
      modify in interface LdapConnectionOperations
      Parameters:
      dn - The distinguished name of the entry
      requestBuilder - The RequestBuilder
      Returns:
      A ModifyResponse
    • modify

      public org.apache.directory.api.ldap.model.message.ModifyResponse modify(org.apache.directory.api.ldap.model.message.ModifyRequest modifyRequest)
      Modifies an entry specified by a ModifyRequest on the LDAP server.
      Specified by:
      modify in interface LdapConnectionOperations
      Parameters:
      modifyRequest - The request
      Returns:
      A ModifyResponse
    • newAddRequest

      public org.apache.directory.api.ldap.model.message.AddRequest newAddRequest(org.apache.directory.api.ldap.model.entry.Entry entry)
      Returns a new AddRequest for the entry.
      Specified by:
      newAddRequest in interface ModelFactory
      Parameters:
      entry - The Entry to add
      Returns:
      The resulting AddRequest
    • newAttribute

      public org.apache.directory.api.ldap.model.entry.Attribute newAttribute(String name)
      Returns a new Attribute for with the provided name and a null value. This is useful for clearing out an Attribute with a ModifyRequest, replace function.
      Specified by:
      newAttribute in interface ModelFactory
      Parameters:
      name - The attribute's name
      Returns:
      The resulting Attribute
    • newAttribute

      public org.apache.directory.api.ldap.model.entry.Attribute newAttribute(String name, byte[]... values)
      Returns a new Attribute for with the provided name and value(s).
      Specified by:
      newAttribute in interface ModelFactory
      Parameters:
      name - The attribute's name
      values - The attribute's values
      Returns:
      The resulting Attribute
    • newAttribute

      public org.apache.directory.api.ldap.model.entry.Attribute newAttribute(String name, String... values)
      Returns a new Attribute for with the provided name and value(s).
      Specified by:
      newAttribute in interface ModelFactory
      Parameters:
      name - The attribute's name
      values - The attribute's values
      Returns:
      The resulting Attribute
    • newAttribute

      public org.apache.directory.api.ldap.model.entry.Attribute newAttribute(String name, org.apache.directory.api.ldap.model.entry.Value... values)
      Returns a new Attribute for with the provided name and value(s).
      Specified by:
      newAttribute in interface ModelFactory
      Parameters:
      name - The attribute's name
      values - The attribute's values
      Returns:
      The resulting Attribute
    • newDeleteRequest

      public org.apache.directory.api.ldap.model.message.DeleteRequest newDeleteRequest(org.apache.directory.api.ldap.model.name.Dn dn)
      Returns a new DeleteRequest for the dn.
      Specified by:
      newDeleteRequest in interface ModelFactory
      Parameters:
      dn - The Dn for the Entry to delete
      Returns:
      The resulting DeleteRequest
    • newDn

      public org.apache.directory.api.ldap.model.name.Dn newDn(String dn)
      Returns a Dn that represents dn.
      Specified by:
      newDn in interface ModelFactory
      Parameters:
      dn - The Entry's Dn
      Returns:
      The resulting Dn
    • newEntry

      public org.apache.directory.api.ldap.model.entry.Entry newEntry(String dn)
      Returns a Entry with the specified dn.
      Specified by:
      newEntry in interface ModelFactory
      Parameters:
      dn - The Entry's Dn
      Returns:
      The resulting Entry
    • newEntry

      public org.apache.directory.api.ldap.model.entry.Entry newEntry(org.apache.directory.api.ldap.model.name.Dn dn)
      Returns a Entry with the specified dn.
      Specified by:
      newEntry in interface ModelFactory
      Parameters:
      dn - The Entry's Dn
      Returns:
      The resulting Entry
    • newModifyRequest

      public org.apache.directory.api.ldap.model.message.ModifyRequest newModifyRequest(String dn)
      Returns a new ModifyRequest for the dn.
      Specified by:
      newModifyRequest in interface ModelFactory
      Parameters:
      dn - The Dn of the entry to modify
      Returns:
      The resulting ModifyRequest
    • newModifyRequest

      public org.apache.directory.api.ldap.model.message.ModifyRequest newModifyRequest(org.apache.directory.api.ldap.model.name.Dn dn)
      Returns a new ModifyRequest for the dn.
      Specified by:
      newModifyRequest in interface ModelFactory
      Parameters:
      dn - The DN of the entry to modify
      Returns:
      The resulting ModifyRequest
    • newSearchRequest

      public org.apache.directory.api.ldap.model.message.SearchRequest newSearchRequest(String baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope)
      Returns a new SearchRequest over baseDn in scope matching filter returning all normal attributes for each matching entry.
      Specified by:
      newSearchRequest in interface ModelFactory
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      Returns:
      The resulting SearchRequest
    • newSearchRequest

      public org.apache.directory.api.ldap.model.message.SearchRequest newSearchRequest(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope)
      Returns a new SearchRequest over baseDn in scope matching filter returning all normal attributes for each matching entry.
      Specified by:
      newSearchRequest in interface ModelFactory
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      Returns:
      The resulting SearchRequest
    • newSearchRequest

      public org.apache.directory.api.ldap.model.message.SearchRequest newSearchRequest(org.apache.directory.api.ldap.model.name.Dn baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope)
      Returns a new SearchRequest over baseDn in scope matching filter returning all normal attributes for each matching entry.
      Specified by:
      newSearchRequest in interface ModelFactory
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      Returns:
      The resulting SearchRequest
    • newSearchRequest

      public org.apache.directory.api.ldap.model.message.SearchRequest newSearchRequest(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope)
      Returns a new SearchRequest over baseDn in scope matching filter returning all normal attributes for each matching entry.
      Specified by:
      newSearchRequest in interface ModelFactory
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      Returns:
      The resulting SearchRequest
    • newSearchRequest

      public org.apache.directory.api.ldap.model.message.SearchRequest newSearchRequest(String baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
      Returns a new SearchRequest over baseDn in scope matching filter returning attributes for each matching entry.
      Specified by:
      newSearchRequest in interface ModelFactory
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      attributes - The list of AttributeType to return
      Returns:
      The resulting SearchRequest
    • newSearchRequest

      public org.apache.directory.api.ldap.model.message.SearchRequest newSearchRequest(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
      Returns a new SearchRequest over baseDn in scope matching filter returning attributes for each matching entry.
      Specified by:
      newSearchRequest in interface ModelFactory
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      attributes - The list of AttributeType to return
      Returns:
      The resulting SearchRequest
    • newSearchRequest

      public org.apache.directory.api.ldap.model.message.SearchRequest newSearchRequest(org.apache.directory.api.ldap.model.name.Dn baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
      Returns a new SearchRequest over baseDn in scope matching filter returning attributes for each matching entry.
      Specified by:
      newSearchRequest in interface ModelFactory
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      attributes - The list of AttributeType to return
      Returns:
      The resulting SearchRequest
    • newSearchRequest

      public org.apache.directory.api.ldap.model.message.SearchRequest newSearchRequest(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
      Returns a new SearchRequest over baseDn in scope matching filter returning attributes for each matching entry.
      Specified by:
      newSearchRequest in interface ModelFactory
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      attributes - The list of AttributeType to return
      Returns:
      The resulting SearchRequest
    • responseOrException

      public <T extends org.apache.directory.api.ldap.model.message.ResultResponse> T responseOrException(T response)
      Checks the supplied response for its result code, and if not ResultCodeEnum#SUCCESS, an exception is thrown. This method is intended to be used inline:
      template.responseOrException( template.delete( dn ) );
      
      Specified by:
      responseOrException in interface LdapConnectionOperations
      Type Parameters:
      T - The type of response
      Parameters:
      response - The response to check for success
      Returns:
      The supplied response
    • search

      public <T> List<T> search(String baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
      Searches for the entries matching the supplied criteria, feeding the result into the entryMapper.
      Specified by:
      search in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • search

      public <T> List<T> search(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
      Searches for the entries matching the supplied criteria, feeding the result into the entryMapper.
      Specified by:
      search in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • search

      public <T> List<T> search(org.apache.directory.api.ldap.model.name.Dn baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
      Searches for the entries matching the supplied criteria, feeding the result into the entryMapper.
      Specified by:
      search in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • search

      public <T> List<T> search(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
      Searches for the entries matching the supplied criteria, feeding the result into the entryMapper.
      Specified by:
      search in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • search

      public <T> List<T> search(String baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
      Searches for the entries matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
      Specified by:
      search in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      attributes - The list of AttributeType to return
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • search

      public <T> List<T> search(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
      Searches for the entries matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
      Specified by:
      search in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      attributes - The list of AttributeType to return
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • search

      public <T> List<T> search(org.apache.directory.api.ldap.model.name.Dn baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
      Searches for the entries matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
      Specified by:
      search in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      attributes - The list of AttributeType to return
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • search

      public <T> List<T> search(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
      Searches for the entries matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
      Specified by:
      search in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      attributes - The list of AttributeType to return
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • search

      public <T> List<T> search(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest, EntryMapper<T> entryMapper)
      Searches for the entries matching the supplied searchRequest, feeding the result into the entryMapper.
      Specified by:
      search in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      searchRequest - The search request
      entryMapper - The mapper
      Returns:
      The mapped entries
    • searchFirst

      public <T> T searchFirst(String baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
      Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper.
      Specified by:
      searchFirst in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • searchFirst

      public <T> T searchFirst(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
      Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper.
      Specified by:
      searchFirst in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • searchFirst

      public <T> T searchFirst(org.apache.directory.api.ldap.model.name.Dn baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
      Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper.
      Specified by:
      searchFirst in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • searchFirst

      public <T> T searchFirst(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, EntryMapper<T> entryMapper)
      Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper.
      Specified by:
      searchFirst in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • searchFirst

      public <T> T searchFirst(String baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
      Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
      Specified by:
      searchFirst in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      attributes - The list of AttributeType to return
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • searchFirst

      public <T> T searchFirst(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
      Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
      Specified by:
      searchFirst in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      attributes - The list of AttributeType to return
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • searchFirst

      public <T> T searchFirst(org.apache.directory.api.ldap.model.name.Dn baseDn, FilterBuilder filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
      Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
      Specified by:
      searchFirst in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      attributes - The list of AttributeType to return
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • searchFirst

      public <T> T searchFirst(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String[] attributes, EntryMapper<T> entryMapper)
      Searches for the first entry matching the supplied criteria, feeding the result into the entryMapper, querying only the requested attributes.
      Specified by:
      searchFirst in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      baseDn - The base DN from which to start the search
      filter - The filter selecting the entries
      scope - The scope to look from
      attributes - The list of AttributeType to return
      entryMapper - The mapper
      Returns:
      The mapped entries
      See Also:
    • searchFirst

      public <T> T searchFirst(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest, EntryMapper<T> entryMapper)
      Searches for the first entry matching the supplied searchRequest, feeding the result into the entryMapper. This is basically the same as LdapConnectionOperations.search(SearchRequest, EntryMapper), but is optimized by modifying the searchRequest to set its size limit to 1. The searchRequest is returned to its original size limit before this method returns (or throws an exception).
      Specified by:
      searchFirst in interface LdapConnectionOperations
      Type Parameters:
      T - The type of the mapped entry
      Parameters:
      searchRequest - The search request
      entryMapper - The mapper
      Returns:
      The mapped entry
    • setModelFactory

      public void setModelFactory(ModelFactory modelFactory)
      Sets the modelFactory implementation for this facade.
      Parameters:
      modelFactory - The model factory implementation
    • setPasswordPolicyResponder

      public void setPasswordPolicyResponder(PasswordPolicyResponder passwordPolicyResponder)
      Sets the passwordPolicyResponder implementation for this facade.
      Parameters:
      passwordPolicyResponder - The password policy responder implementation