public abstract class AbstractConnection extends Object implements Connection
Connection
interface, to minimize the effort required to implement this interface.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractConnection()
Creates a new abstract connection.
|
| Modifier and Type | Method and Description |
|---|---|
Result |
add(Entry entry)
Adds the provided entry to the Directory Server.
|
Result |
add(String... ldifLines)
Adds an entry to the Directory Server using the provided lines of LDIF.
|
LdapPromise<Result> |
addAsync(AddRequest request)
Asynchronously adds an entry to the Directory Server using the provided
add request.
|
Result |
applyChange(ChangeRecord request)
Applies the provided change request to the Directory Server.
|
LdapPromise<Result> |
applyChangeAsync(ChangeRecord request)
Asynchronously applies the provided change request to the Directory
Server.
|
LdapPromise<Result> |
applyChangeAsync(ChangeRecord request,
IntermediateResponseHandler intermediateResponseHandler)
Asynchronously applies the provided change request to the Directory
Server.
|
BindResult |
bind(String name,
char[] password)
Authenticates to the Directory Server using simple authentication and the
provided user name and password.
|
LdapPromise<BindResult> |
bindAsync(BindRequest request)
Asynchronously authenticates to the Directory Server using the provided
bind request.
|
void |
close()
Releases any resources associated with this connection.
|
CompareResult |
compare(String name,
String attributeDescription,
String assertionValue)
Compares the named entry in the Directory Server against the provided
attribute value assertion.
|
LdapPromise<CompareResult> |
compareAsync(CompareRequest request)
Asynchronously compares an entry in the Directory Server using the
provided compare request.
|
Result |
delete(String name)
Deletes the named entry from the Directory Server.
|
LdapPromise<Result> |
deleteAsync(DeleteRequest request)
Asynchronously deletes an entry from the Directory Server using the
provided delete request.
|
Result |
deleteSubtree(String name)
Deletes the named entry and all of its subordinates from the Directory
Server.
|
<R extends ExtendedResult> |
extendedRequest(ExtendedRequest<R> request)
Requests that the Directory Server performs the provided extended
request.
|
GenericExtendedResult |
extendedRequest(String requestName,
ByteString requestValue)
Requests that the Directory Server performs the provided extended
request.
|
<R extends ExtendedResult> |
extendedRequestAsync(ExtendedRequest<R> request)
Asynchronously performs the provided extended request in the Directory
Server.
|
Result |
modify(String... ldifLines)
Modifies an entry in the Directory Server using the provided lines of
LDIF.
|
LdapPromise<Result> |
modifyAsync(ModifyRequest request)
Asynchronously modifies an entry in the Directory Server using the
provided modify request.
|
Result |
modifyDN(String name,
String newRDN)
Renames the named entry in the Directory Server using the provided new
RDN.
|
LdapPromise<Result> |
modifyDNAsync(ModifyDNRequest request)
Asynchronously renames an entry in the Directory Server using the
provided modify DN request.
|
SearchResultEntry |
readEntry(DN baseObject,
String... attributeDescriptions)
Reads the named entry from the Directory Server.
|
SearchResultEntry |
readEntry(String baseObject,
String... attributeDescriptions)
Reads the named entry from the Directory Server.
|
LdapPromise<SearchResultEntry> |
readEntryAsync(DN name,
Collection<String> attributeDescriptions)
Asynchronously reads the named entry from the Directory Server.
|
ConnectionEntryReader |
search(SearchRequest request)
Searches the Directory Server using the provided search parameters.
|
Result |
search(SearchRequest request,
Collection<? super SearchResultEntry> entries)
Searches the Directory Server using the provided search request.
|
Result |
search(SearchRequest request,
Collection<? super SearchResultEntry> entries,
Collection<? super SearchResultReference> references)
Searches the Directory Server using the provided search request.
|
ConnectionEntryReader |
search(String baseObject,
SearchScope scope,
String filter,
String... attributeDescriptions)
Searches the Directory Server using the provided search parameters.
|
LdapPromise<Result> |
searchAsync(SearchRequest request,
SearchResultHandler resultHandler)
Asynchronously searches the Directory Server using the provided search
request.
|
SearchResultEntry |
searchSingleEntry(SearchRequest request)
Searches the Directory Server for a single entry using the provided
search request.
|
SearchResultEntry |
searchSingleEntry(String baseObject,
SearchScope scope,
String filter,
String... attributeDescriptions)
Searches the Directory Server for a single entry using the provided
search parameters.
|
LdapPromise<SearchResultEntry> |
searchSingleEntryAsync(SearchRequest request)
Asynchronously searches the Directory Server for a single entry using the
provided search request.
|
abstract String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitabandonAsync, add, addAsync, addConnectionEventListener, bind, bindAsync, close, compare, compareAsync, delete, deleteAsync, extendedRequest, extendedRequestAsync, isClosed, isValid, modify, modifyAsync, modifyDN, modifyDNAsync, removeConnectionEventListener, search, searchAsyncprotected AbstractConnection()
public Result add(Entry entry) throws LdapException
ConnectionThis method is equivalent to the following code:
AddRequest request = new AddRequest(entry); connection.add(request);
add in interface Connectionentry - The entry to be added.LdapException - If the result code indicates that the request failed for some
reason.public Result add(String... ldifLines) throws LdapException
ConnectionThis method is equivalent to the following code:
AddRequest request = new AddRequest(ldifLines); connection.add(request);
add in interface ConnectionldifLines - Lines of LDIF containing the an LDIF add change record or an
LDIF entry record.LdapException - If the result code indicates that the request failed for some
reason.public LdapPromise<Result> addAsync(AddRequest request)
ConnectionaddAsync in interface Connectionrequest - The add request.public Result applyChange(ChangeRecord request) throws LdapException
ConnectionapplyChange in interface Connectionrequest - The change request.LdapException - If the result code indicates that the request failed for some
reason.public LdapPromise<Result> applyChangeAsync(ChangeRecord request)
ConnectionapplyChangeAsync in interface Connectionrequest - The change request.public LdapPromise<Result> applyChangeAsync(ChangeRecord request, IntermediateResponseHandler intermediateResponseHandler)
ConnectionapplyChangeAsync in interface Connectionrequest - The change request.intermediateResponseHandler - An intermediate response handler which can be used to process
any intermediate responses as they are received, may be
null.public BindResult bind(String name, char[] password) throws LdapException
ConnectionThis method is equivalent to the following code:
BindRequest request = new SimpleBindRequest(name, password); connection.bind(request);
bind in interface Connectionname - The distinguished name of the Directory object that the client
wishes to bind as, which may be empty.password - The password of the Directory object that the client wishes to
bind as, which may be empty.LdapException - If the result code indicates that the request failed for some
reason.public LdapPromise<BindResult> bindAsync(BindRequest request)
ConnectionbindAsync in interface Connectionrequest - The bind request.public void close()
ConnectionOther connection implementations may behave differently, and may choose not to send an unbind request if its use is inappropriate (for example a pooled connection will be released and returned to its connection pool without ever issuing an unbind request).
This method is equivalent to the following code:
UnbindRequest request = new UnbindRequest(); connection.close(request);Calling
close on a connection that is already closed has no
effect.close in interface Closeableclose in interface AutoCloseableclose in interface ConnectionConnections.uncloseable(Connection)public CompareResult compare(String name, String attributeDescription, String assertionValue) throws LdapException
ConnectionThis method is equivalent to the following code:
CompareRequest request = new CompareRequest(name, attributeDescription, assertionValue); connection.compare(request);
compare in interface Connectionname - The distinguished name of the entry to be compared.attributeDescription - The name of the attribute to be compared.assertionValue - The assertion value to be compared.LdapException - If the result code indicates that the request failed for some
reason.public LdapPromise<CompareResult> compareAsync(CompareRequest request)
ConnectioncompareAsync in interface Connectionrequest - The compare request.public Result delete(String name) throws LdapException
ConnectionThis method is equivalent to the following code:
DeleteRequest request = new DeleteRequest(name); connection.delete(request);
delete in interface Connectionname - The distinguished name of the entry to be deleted.LdapException - If the result code indicates that the request failed for some
reason.public LdapPromise<Result> deleteAsync(DeleteRequest request)
ConnectiondeleteAsync in interface Connectionrequest - The delete request.public Result deleteSubtree(String name) throws LdapException
ConnectionThis method is equivalent to the following code:
DeleteRequest request = new DeleteRequest(name).addControl( connection.delete(request);
deleteSubtree in interface Connectionname - The distinguished name of the subtree base entry to be
deleted.LdapException - If the result code indicates that the request failed for some
reason.public <R extends ExtendedResult> R extendedRequest(ExtendedRequest<R> request) throws LdapException
ConnectionextendedRequest in interface ConnectionR - The type of result returned by the extended request.request - The extended request.LdapException - If the result code indicates that the request failed for some
reason.public GenericExtendedResult extendedRequest(String requestName, ByteString requestValue) throws LdapException
ConnectionThis method is equivalent to the following code:
GenericExtendedRequest request = new GenericExtendedRequest(requestName, requestValue); connection.extendedRequest(request);
extendedRequest in interface ConnectionrequestName - The dotted-decimal representation of the unique OID
corresponding to the extended request.requestValue - The content of the extended request in a form defined by the
extended operation, or null if there is no content.LdapException - If the result code indicates that the request failed for some
reason.public <R extends ExtendedResult> LdapPromise<R> extendedRequestAsync(ExtendedRequest<R> request)
ConnectionextendedRequestAsync in interface ConnectionR - The type of result returned by the extended request.request - The extended request.public Result modify(String... ldifLines) throws LdapException
ConnectionThis method is equivalent to the following code:
ModifyRequest request = new ModifyRequest(name, ldifChanges); connection.modify(request);
modify in interface ConnectionldifLines - Lines of LDIF containing the a single LDIF modify change
record.LdapException - If the result code indicates that the request failed for some
reason.public LdapPromise<Result> modifyAsync(ModifyRequest request)
ConnectionmodifyAsync in interface Connectionrequest - The modify request.public Result modifyDN(String name, String newRDN) throws LdapException
ConnectionThis method is equivalent to the following code:
ModifyDNRequest request = new ModifyDNRequest(name, newRDN); connection.modifyDN(request);
modifyDN in interface Connectionname - The distinguished name of the entry to be renamed.newRDN - The new RDN of the entry.LdapException - If the result code indicates that the request failed for some
reason.public LdapPromise<Result> modifyDNAsync(ModifyDNRequest request)
ConnectionmodifyDNAsync in interface Connectionrequest - The modify DN request.public SearchResultEntry readEntry(DN baseObject, String... attributeDescriptions) throws LdapException
Connection
If the requested entry is not returned by the Directory Server then the
request will fail with an EntryNotFoundException. More
specifically, this method will never return null.
This method is equivalent to the following code:
SearchRequest request = new SearchRequest(name, SearchScope.BASE_OBJECT, "(objectClass=*)", attributeDescriptions); connection.searchSingleEntry(request);
readEntry in interface ConnectionbaseObject - The distinguished name of the entry to be read.attributeDescriptions - The names of the attributes to be included with the entry,
which may be null or empty indicating that all user
attributes should be returned.LdapException - If the result code indicates that the request failed for some
reason.public SearchResultEntry readEntry(String baseObject, String... attributeDescriptions) throws LdapException
Connection
If the requested entry is not returned by the Directory Server then the
request will fail with an EntryNotFoundException. More
specifically, this method will never return null.
This method is equivalent to the following code:
SearchRequest request =
new SearchRequest(name, SearchScope.BASE_OBJECT, "(objectClass=*)", attributeDescriptions);
connection.searchSingleEntry(request);
readEntry in interface ConnectionbaseObject - The distinguished name of the entry to be read.attributeDescriptions - The names of the attributes to be included with the entry.LdapException - If the result code indicates that the request failed for some
reason.public LdapPromise<SearchResultEntry> readEntryAsync(DN name, Collection<String> attributeDescriptions)
Connection
If the requested entry is not returned by the Directory Server then the
request will fail with an EntryNotFoundException. More
specifically, the returned promise will never return null.
This method is equivalent to the following code:
SearchRequest request =
new SearchRequest(name, SearchScope.BASE_OBJECT, "(objectClass=*)", attributeDescriptions);
connection.searchSingleEntryAsync(request, resultHandler, p);
readEntryAsync in interface Connectionname - The distinguished name of the entry to be read.attributeDescriptions - The names of the attributes to be included with the entry,
which may be null or empty indicating that all user
attributes should be returned.public ConnectionEntryReader search(SearchRequest request)
ConnectionConnectionEntryReader.
Unless otherwise specified, calling this method is equivalent to:
ConnectionEntryReader reader = new ConnectionEntryReader(this, request);
search in interface Connectionrequest - The search request.public Result search(SearchRequest request, Collection<? super SearchResultEntry> entries) throws LdapException
Connectionentries,
even if the final search result indicates that the search failed. Search
result references will be discarded.
Warning: Usage of this method is discouraged if the search request
is expected to yield a large number of search results since the entire
set of results will be stored in memory, potentially causing an
OutOfMemoryError.
This method is equivalent to the following code:
connection.search(request, entries, null);
search in interface Connectionrequest - The search request.entries - The collection to which matching entries should be added.LdapException - If the result code indicates that the request failed for some
reason.public Result search(SearchRequest request, Collection<? super SearchResultEntry> entries, Collection<? super SearchResultReference> references) throws LdapException
Connectionentries,
even if the final search result indicates that the search failed.
Similarly, search result references returned by the search will be added
to references.
Warning: Usage of this method is discouraged if the search request
is expected to yield a large number of search results since the entire
set of results will be stored in memory, potentially causing an
OutOfMemoryError.
search in interface Connectionrequest - The search request.entries - The collection to which matching entries should be added.references - The collection to which search result references should be
added, or null if references are to be discarded.LdapException - If the result code indicates that the request failed for some
reason.public ConnectionEntryReader search(String baseObject, SearchScope scope, String filter, String... attributeDescriptions)
ConnectionEntryReader interface.
Warning: When using a queue with an optional capacity bound, the connection will stop reading responses and wait if necessary for space to become available.
This method is equivalent to the following code:
SearchRequest request = new SearchRequest(baseDN, scope, filter, attributeDescriptions); connection.search(request, new LinkedBlockingQueue<Response>());
search in interface ConnectionbaseObject - The distinguished name of the base entry relative to which the
search is to be performed.scope - The scope of the search.filter - The filter that defines the conditions that must be fulfilled
in order for an entry to be returned.attributeDescriptions - The names of the attributes to be included with each entry.public LdapPromise<Result> searchAsync(SearchRequest request, SearchResultHandler resultHandler)
ConnectionsearchAsync in interface Connectionrequest - The search request.resultHandler - A search result handler which can be used to asynchronously
process the search result entries and references as they are
received, may be null.public SearchResultEntry searchSingleEntry(SearchRequest request) throws LdapException
Connection
If the requested entry is not returned by the Directory Server then the
request will fail with an EntryNotFoundException. More
specifically, this method will never return null. If multiple
matching entries are returned by the Directory Server then the request
will fail with an MultipleEntriesFoundException.
searchSingleEntry in interface Connectionrequest - The search request.LdapException - If the result code indicates that the request failed for some
reason.public SearchResultEntry searchSingleEntry(String baseObject, SearchScope scope, String filter, String... attributeDescriptions) throws LdapException
Connection
If the requested entry is not returned by the Directory Server then the
request will fail with an EntryNotFoundException. More
specifically, this method will never return null. If multiple
matching entries are returned by the Directory Server then the request
will fail with an MultipleEntriesFoundException.
This method is equivalent to the following code:
SearchRequest request = new SearchRequest(baseObject, scope, filter, attributeDescriptions); connection.searchSingleEntry(request);
searchSingleEntry in interface ConnectionbaseObject - The distinguished name of the base entry relative to which the
search is to be performed.scope - The scope of the search.filter - The filter that defines the conditions that must be fulfilled
in order for an entry to be returned.attributeDescriptions - The names of the attributes to be included with each entry.LdapException - If the result code indicates that the request failed for some
reason.public LdapPromise<SearchResultEntry> searchSingleEntryAsync(SearchRequest request)
Connection
If the requested entry is not returned by the Directory Server then the
request will fail with an EntryNotFoundException. More
specifically, the returned promise will never return null. If
multiple matching entries are returned by the Directory Server then the
request will fail with an MultipleEntriesFoundException.
searchSingleEntryAsync in interface Connectionrequest - The search request.Copyright © 2011-2015 ForgeRock AS. All Rights Reserved.