Package org.ldaptive.ad.control.util
Class DirSyncClient
java.lang.Object
org.ldaptive.ad.control.util.DirSyncClient
Client that simplifies using the active directory dir sync control.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DirSyncControl.Flag[]
DirSync flags.private LdapEntryHandler[]
Functions to handle response entries.private ExceptionHandler
Function to handle exceptions.private ExtendedDnControl.Flag
ExtendedDn flags.private final ConnectionFactory
Connection factory to get a connection from.protected final org.slf4j.Logger
Logger for this class.private final int
Maximum attribute count.private SearchReferenceHandler[]
Functions to handle response references.private ResultHandler[]
Functions to handle response results.private SearchResultHandler[]
Functions to handle response results.private ResultPredicate
Function to test results. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new dir sync client.DirSyncClient
(ConnectionFactory cf, DirSyncControl.Flag[] dsFlags) Creates a new dir sync client.DirSyncClient
(ConnectionFactory cf, DirSyncControl.Flag[] dsFlags, int count) Creates a new dir sync client. -
Method Summary
Modifier and TypeMethodDescriptionprivate RequestControl[]
createRequestControls
(byte[] cookie) Returns the list of request controls configured for this client.protected SearchOperation
Creates a new search operation configured with the properties on this client.execute
(SearchRequest request) Performs a search operation with theDirSyncControl
.execute
(SearchRequest request, CookieManager manager) Performs a search operation with theDirSyncControl
.execute
(SearchRequest request, SearchResponse result) Performs a search operation with theDirSyncControl
.executeToCompletion
(SearchRequest request) Invokesexecute(SearchRequest, CookieManager)
with aDefaultCookieManager
.executeToCompletion
(SearchRequest request, CookieManager manager) Performs a search operation with theDirSyncControl
.protected byte[]
getDirSyncCookie
(SearchResponse result) Returns the dir sync cookie in the supplied response or null if no cookie exists.protected long
getDirSyncFlags
(SearchResponse result) Returns the dir sync flags in the supplied response or -1 if no flags exists.Returns the flag that is used on the extended dn control.boolean
hasMore
(SearchResponse result) Returns whetherexecute(SearchRequest, SearchResponse)
can be invoked again.void
setEntryHandlers
(LdapEntryHandler... handlers) void
setExceptionHandler
(ExceptionHandler handler) void
Sets the flag to use on the extended dn control.void
setReferenceHandlers
(SearchReferenceHandler... handlers) void
setResultHandlers
(ResultHandler... handlers) void
setSearchResultHandlers
(SearchResultHandler... handlers) void
setThrowCondition
(ResultPredicate function)
-
Field Details
-
logger
protected final org.slf4j.Logger loggerLogger for this class. -
factory
Connection factory to get a connection from. -
dirSyncFlags
DirSync flags. -
maxAttributeCount
private final int maxAttributeCountMaximum attribute count. -
extendedDnFlag
ExtendedDn flags. -
resultHandlers
Functions to handle response results. -
exceptionHandler
Function to handle exceptions. -
throwCondition
Function to test results. -
entryHandlers
Functions to handle response entries. -
referenceHandlers
Functions to handle response references. -
searchResultHandlers
Functions to handle response results.
-
-
Constructor Details
-
DirSyncClient
Creates a new dir sync client.- Parameters:
cf
- to get a connection from
-
DirSyncClient
Creates a new dir sync client.- Parameters:
cf
- to get a connection fromdsFlags
- to set on the dir sync control
-
DirSyncClient
Creates a new dir sync client.- Parameters:
cf
- to get a connection fromdsFlags
- to set on the dir sync controlcount
- max attribute count
-
-
Method Details
-
getResultHandlers
-
setResultHandlers
-
getExceptionHandler
-
setExceptionHandler
-
getThrowCondition
-
setThrowCondition
-
getEntryHandlers
-
setEntryHandlers
-
getReferenceHandlers
-
setReferenceHandlers
-
getSearchResultHandlers
-
setSearchResultHandlers
-
getExtendedDnFlag
Returns the flag that is used on the extended dn control.- Returns:
- extended dn control flag
-
setExtendedDnFlag
Sets the flag to use on the extended dn control.- Parameters:
flag
- to set on the extended dn control
-
execute
Performs a search operation with theDirSyncControl
. The supplied request is modified in the following way:- Parameters:
request
- search request to execute- Returns:
- search operation response
- Throws:
LdapException
- if the search fails
-
execute
Performs a search operation with theDirSyncControl
. The supplied request is modified in the following way:AbstractRequestMessage.setControls(org.ldaptive.control.RequestControl...)
is invoked withDirSyncControl
,ShowDeletedControl
, andExtendedDnControl
The cookie is extracted from the supplied response and replayed in the request.
- Parameters:
request
- search request to executeresult
- of a previous dir sync operation- Returns:
- search operation response
- Throws:
IllegalArgumentException
- if the response does not contain a dir sync cookieLdapException
- if the search fails
-
execute
Performs a search operation with theDirSyncControl
. The supplied request is modified in the following way:AbstractRequestMessage.setControls(org.ldaptive.control.RequestControl...)
is invoked withDirSyncControl
,ShowDeletedControl
, andExtendedDnControl
The cookie used in the request is read from the cookie manager and written to the cookie manager after a successful search, if the response contains a cookie.
- Parameters:
request
- search request to executemanager
- for reading and writing cookies- Returns:
- search operation response
- Throws:
LdapException
- if the search fails
-
hasMore
Returns whetherexecute(SearchRequest, SearchResponse)
can be invoked again.- Parameters:
result
- of a previous dir sync operation- Returns:
- whether more dir sync results can be retrieved from the server
-
executeToCompletion
Invokesexecute(SearchRequest, CookieManager)
with aDefaultCookieManager
.- Parameters:
request
- search request to execute- Returns:
- search operation response of the last dir sync operation
- Throws:
LdapException
- if the search fails
-
executeToCompletion
public SearchResponse executeToCompletion(SearchRequest request, CookieManager manager) throws LdapException Performs a search operation with theDirSyncControl
. The supplied request is modified in the following way:AbstractRequestMessage.setControls(org.ldaptive.control.RequestControl...)
is invoked withDirSyncControl
,ShowDeletedControl
, andExtendedDnControl
This method will continue to execute search operations until all dir sync search results have been retrieved from the server. The returned response contains the response data of the last dir sync operation plus the entries and references returned by all previous search operations.
The cookie used for each request is read from the cookie manager and written to the cookie manager after a successful search, if the response contains a cookie.
- Parameters:
request
- search request to executemanager
- for reading and writing cookies- Returns:
- search operation response of the last dir sync operation
- Throws:
LdapException
- if the search fails
-
createSearchOperation
Creates a new search operation configured with the properties on this client.- Returns:
- new search operation
-
getDirSyncFlags
Returns the dir sync flags in the supplied response or -1 if no flags exists.- Parameters:
result
- of a previous dir sync operation- Returns:
- dir sync flags or -1
-
getDirSyncCookie
Returns the dir sync cookie in the supplied response or null if no cookie exists.- Parameters:
result
- of a previous dir sync operation- Returns:
- dir sync cookie or null
-
createRequestControls
Returns the list of request controls configured for this client.- Parameters:
cookie
- to add to the dir sync control or null- Returns:
- search request controls
-