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 ExceptionHandlerFunction to handle exceptions.private ExtendedDnControl.FlagExtendedDn flags.private final ConnectionFactoryConnection factory to get a connection from.protected final LoggerLogger for this class.private final intMaximum attribute count.private SearchReferenceHandler[]Functions to handle response references.private ResultHandler[]Functions to handle response results.private SearchResultHandler[]Functions to handle response results.private ResultPredicateFunction 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[]appendRequestControls(SearchRequest request, byte[] cookie) Creates a new array of request controls which includes the dir sync control, extended DN control and show deleted control.protected SearchOperationCreates 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 longgetDirSyncFlags(SearchResponse result) Returns the dir sync flags in the supplied response or -1 if no flags exists.Returns the entry handlers.Returns the exception handler.Returns the flag that is used on the extended dn control.Returns the reference handlers.Returns the result handlers.Returns the search result handlers.Returns the throw condition.booleanhasMore(SearchResponse result) Returns whetherexecute(SearchRequest, SearchResponse)can be invoked again.voidsetEntryHandlers(LdapEntryHandler... handlers) Sets the entry handlers.voidsetExceptionHandler(ExceptionHandler handler) Sets the exception handler.voidSets the flag to use on the extended dn control.voidsetReferenceHandlers(SearchReferenceHandler... handlers) Sets the reference handlers.voidsetResultHandlers(ResultHandler... handlers) Sets the result handlers.voidsetSearchResultHandlers(SearchResultHandler... handlers) Sets the search result handlers.voidsetThrowCondition(ResultPredicate function) Sets the throw condition.
-
Field Details
-
logger
Logger 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
Returns the result handlers.- Returns:
- result handlers
-
setResultHandlers
Sets the result handlers.- Parameters:
handlers- result handlers
-
getExceptionHandler
Returns the exception handler.- Returns:
- exception handler
-
setExceptionHandler
Sets the exception handler.- Parameters:
handler- exception handler
-
getThrowCondition
Returns the throw condition.- Returns:
- throw condition
-
setThrowCondition
Sets the throw condition.- Parameters:
function- throw condition
-
getEntryHandlers
Returns the entry handlers.- Returns:
- entry handlers
-
setEntryHandlers
Sets the entry handlers.- Parameters:
handlers- entry handlers
-
getReferenceHandlers
Returns the reference handlers.- Returns:
- reference handlers
-
setReferenceHandlers
Sets the reference handlers.- Parameters:
handlers- reference handlers
-
getSearchResultHandlers
Returns the search result handlers.- Returns:
- search result handlers
-
setSearchResultHandlers
Sets the search result handlers.- Parameters:
handlers- search result handlers
-
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
-
appendRequestControls
Creates a new array of request controls which includes the dir sync control, extended DN control and show deleted control. Any other request controls are included.- Parameters:
request- to read controls fromcookie- to add to the dir sync control or null- Returns:
- search request controls
-