Interface LdapClientSocket
- All Superinterfaces:
AutoCloseable,Closeable
Operation processing
Operations are performed asynchronously once theFlowable has been subscribed to. As as result,
send(Request, RequestHandle) will send the request only once the returned Flowable has been
subscribed.
Cancellation
Request cancellation can be done in different ways:- Using the standard reactive-stream way: Using the
SubscriptiontheSubscriberreceived upon its subscription to the response, it's possible to invokeSubscription.cancel(). This will send anAbandonRequestto the server. - Another way is to use the
RequestHandle.abandon()orRequestHandle.cancel()to respectively send anAbandonRequestor aCancelExtendedRequest.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionadd(AddRequest request) Adds an entry to the Directory Server using the provided add request.voidRegisters the provided connection event listener so that it will be notified when this connection is closed by the application, receives an unsolicited notification, or experiences a fatal error.applyChange(ChangeRecord request) Applies the provided change request to the Directory Server.default Single<BindResult>bind(BindRequest request) Authenticates to the Directory Server using the provided bind request.default voidclose()Releases any resources associated with this connection.voidclose(UnbindRequest request, String reason) Releases any resources associated with this connection.default Single<CompareResult>compare(CompareRequest request) Asynchronously compares an entry in the Directory Server using the provided compare request.delete(DeleteRequest request) Deletes an entry from the Directory Server using the provided delete request.default <R extends ExtendedResult>
Single<R>extendedRequest(ExtendedRequest<R> request) Requests that the Directory Server performs the provided extended request.booleanisClosed()Indicates whether this connection has been explicitly closed by callingclose().booleanisValid()Returnstrueif this connection has not been closed and no fatal errors have been detected.modify(ModifyRequest request) Modifies an entry in the Directory Server using the provided modify request.modifyDn(ModifyDnRequest request) Renames an entry in the Directory Server using the provided modify DN request.default Single<SearchResultEntry>Reads the named entry from the Directory Server.voidRemoves the provided connection event listener from this connection so that it will no longer be notified when this connection is closed by the application, receives an unsolicited notification, or experiences a fatal error.default Flowable<SearchResultEntry>search(SearchRequest request) Searches the Directory Server using the provided search request.default Single<SearchResultEntry>searchSingleEntry(SearchRequest request) Searches the Directory Server for a single entry using the provided search request.Sends a request to the Directory Server.send(Request request, RequestHandle handle) Sends a request to the Directory Server.
-
Method Details
-
send
Sends a request to the Directory Server.Note that the request will only be sent when the returned
Flowablehas been subscribed.- Parameters:
request- The request to send.handle- TheRequestHandleto track the request cancellation.- Returns:
- The asynchronous result of the operation. Note that this
Flowablecan be subscribed only once. Canceling the subscription of thisFlowablewill send anAbandonRequestto the server. - Throws:
NullPointerException- Ifrequestorhandlewasnull.- See Also:
-
send
Sends a request to the Directory Server.Note that the request will only be sent when the returned
Flowablehas been subscribed.- Parameters:
request- The request to send.- Returns:
- The asynchronous result of the operation. Note that this
Flowablecan be subscribed only once. Canceling the subscription of thisFlowablewill send anAbandonRequestto the server. - Throws:
NullPointerException- Ifrequestwasnull.- See Also:
-
isValid
boolean isValid()Returnstrueif this connection has not been closed and no fatal errors have been detected. This method is guaranteed to returnfalseonly when it is called after the methodclose()has been called.- Returns:
trueif this connection is valid,falseotherwise.
-
isClosed
boolean isClosed()Indicates whether this connection has been explicitly closed by callingclose(). This method will not returntrueif a fatal error has occurred on the connection unlessclose()has been called.- Returns:
trueif this connection has been explicitly closed by callingclose(), orfalseotherwise.
-
addConnectionEventListener
Registers the provided connection event listener so that it will be notified when this connection is closed by the application, receives an unsolicited notification, or experiences a fatal error.- Parameters:
listener- The listener which wants to be notified when events occur on this connection.- Throws:
IllegalStateException- If this connection has already been closed, i.e. ifisClosed() == true.NullPointerException- If thelistenerwasnull.
-
removeConnectionEventListener
Removes the provided connection event listener from this connection so that it will no longer be notified when this connection is closed by the application, receives an unsolicited notification, or experiences a fatal error.- Parameters:
listener- The listener which no longer wants to be notified when events occur on this connection.- Throws:
NullPointerException- If thelistenerwasnull.
-
close
Releases any resources associated with this connection. For physical connections to a Directory Server this will mean that the provided unbind request is sent and the underlying socket is closed.Other connection implementations may behave differently, and may choose to ignore the provided 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).
Calling
close()on a connection that is already closed has no effect.This method is not blocking and as such, does not guarantee that the socket is being effectively closed when this method returns.
- Parameters:
request- The unbind request to use in the case where a physical connection is closed.reason- A reason describing why the connection was closed.- Throws:
NullPointerException- Ifrequestwasnull.
-
close
default void close()Releases any resources associated with this connection. For physical connections to a Directory Server this will mean that an unbind request is sent and the underlying socket is closed.Other 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, null);
Calling this method on a connection that is already closed has no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
bind
Authenticates to the Directory Server using the provided bind request.If you need to handle
IntermediateResponses, please usesend(Request)instead.Note that the request will only be sent when the returned
Singlehas been subscribed.- Parameters:
request- The bind request.- Returns:
- The asynchronous result of the operation. Note that this
Singlecan be subscribed only once. Canceling the subscription of thisSinglewill send anAbandonRequestto the server. - Throws:
UnsupportedOperationException- If this socket does not support bind operations.IllegalStateException- If this socket has already been closed, i.e. ifisClosed() == true.NullPointerException- Ifrequestwasnull.- See Also:
-
searchSingleEntry
Searches the Directory Server for a single entry using the provided search request.If the requested entry is not returned by the Directory Server then the request will fail with an
EntryNotFoundException. If multiple matching entries are returned by the Directory Server then the request will fail with anMultipleEntriesFoundException.Note that the request will only be sent when the returned
Singlehas been subscribed.- Parameters:
request- The request to send.- Returns:
- The asynchronous result of the operation. Note that this
Singlecan be subscribed only once. Canceling the subscription of thisSinglewill send anAbandonRequestto the server. - Throws:
UnsupportedOperationException- If this connection does not support search operations.IllegalStateException- If this socket has already been closed, i.e. ifisClosed() == true.NullPointerException- If therequestwasnull.- See Also:
-
search
Searches the Directory Server using the provided search request. Note that onlySearchResultEntrywill be returned throughout theFlowable.If you need to handle the search
Result(e.g. for processing paged results),SearchResultReference, orSearchResultReferenceorIntermediateResponses, please usesend(Request)instead.Note that the request will only be sent when the returned
Flowablehas been subscribed.- Parameters:
request- The request to send.- Returns:
- The asynchronous result of the operation. Note that this
Flowablecan be subscribed only once. Canceling the subscription of thisFlowablewill send anAbandonRequestto the server. - Throws:
UnsupportedOperationException- If this connection does not support search operations.IllegalStateException- If this socket has already been closed, i.e. ifisClosed() == true.NullPointerException- If therequestwasnull.- See Also:
-
readEntry
Reads the named entry from the Directory Server.If the requested entry is not returned by the Directory Server then the request will fail with an
EntryNotFoundException.This method is equivalent to the following code:
SearchRequest request = new SearchRequest(name, SearchScope.BASE_OBJECT, "(objectClass=*)", attributeDescriptions); socket.searchSingleEntry(request);Note that the request will only be sent when the returned
Singlehas been subscribed.- Parameters:
name- The distinguished name of the entry to be read.attributeDescriptions- The names of the attributes to be included with the entry, which may benullor empty indicating that all user attributes should be returned.- Returns:
- The asynchronous result of the operation. Note that this
Singlecan be subscribed only once. Canceling the subscription of thisSinglewill send anAbandonRequestto the server. - Throws:
UnsupportedOperationException- If this socket does not support search operations.IllegalStateException- If this socket has already been closed, i.e. ifisClosed() == true.NullPointerException- If thenamewasnull.
-
modify
Modifies an entry in the Directory Server using the provided modify request.If you need to handle
IntermediateResponses, please usesend(Request)instead.Note that the request will only be sent when the returned
Singlehas been subscribed.- Parameters:
request- The modify request.- Returns:
- The asynchronous result of the operation. Note that this
Singlecan be subscribed only once. Canceling the subscription of thisSinglewill send anAbandonRequestto the server. - Throws:
UnsupportedOperationException- If this connection does not support modify operations.IllegalStateException- If this socket has already been closed, i.e. ifisClosed() == true.NullPointerException- Ifrequestwasnull.- See Also:
-
add
Adds an entry to the Directory Server using the provided add request.If you need to handle
IntermediateResponses, please usesend(Request)instead.Note that the request will only be sent when the returned
Singlehas been subscribed.- Parameters:
request- The add request.- Returns:
- The asynchronous result of the operation. Note that this
Singlecan be subscribed only once. Canceling the subscription of thisSinglewill send anAbandonRequestto the server. - Throws:
UnsupportedOperationException- If this connection does not support add operations.IllegalStateException- If this connection has already been closed, i.e. ifisClosed() == true.NullPointerException- Ifrequestwasnull.- See Also:
-
modifyDn
Renames an entry in the Directory Server using the provided modify DN request.If you need to handle
IntermediateResponses, please usesend(Request)instead.Note that the request will only be sent when the returned
Singlehas been subscribed.- Parameters:
request- The modify DN request.- Returns:
- The asynchronous result of the operation. Note that this
Singlecan be subscribed only once. Canceling the subscription of thisSinglewill send anAbandonRequestto the server. - Throws:
UnsupportedOperationException- If this connection does not support modify DN operations.IllegalStateException- If this connection has already been closed, i.e. ifisClosed() == true.NullPointerException- Ifrequestwasnull.- See Also:
-
delete
Deletes an entry from the Directory Server using the provided delete request.If you need to handle
IntermediateResponses, please usesend(Request)instead.Note that the request will only be sent when the returned
Singlehas been subscribed.- Parameters:
request- The delete request.- Returns:
- The asynchronous result of the operation. Note that this
Singlecan be subscribed only once. Canceling the subscription of thisSinglewill send anAbandonRequestto the server. - Throws:
UnsupportedOperationException- If this connection does not support delete operations.IllegalStateException- If this socket has already been closed, i.e. ifisClosed() == true.NullPointerException- Ifrequestwasnull.- See Also:
-
compare
Asynchronously compares an entry in the Directory Server using the provided compare request.If you need to handle
IntermediateResponses, please usesend(Request)instead.Note that the request will only be sent when the returned
Singlehas been subscribed.- Parameters:
request- The compare request.- Returns:
- The asynchronous result of the operation. Note that this
Singlecan be subscribed only once. Canceling the subscription of thisSinglewill send anAbandonRequestto the server. - Throws:
UnsupportedOperationException- If this connection does not support compare operations.IllegalStateException- If this connection has already been closed, i.e. ifisClosed() == true.NullPointerException- Ifrequestwasnull.- See Also:
-
extendedRequest
Requests that the Directory Server performs the provided extended request.If you need to handle
IntermediateResponses, please usesend(Request)instead.Note that the request will only be sent when the returned
Singlehas been subscribed.- Type Parameters:
R- The type of result returned by the extended request.- Parameters:
request- The extended request.- Returns:
- The asynchronous result of the operation. Note that this
Singlecan be subscribed only once. Canceling the subscription of thisSinglewill send anAbandonRequestto the server. - Throws:
UnsupportedOperationException- If this socket does not support extended operations.IllegalStateException- If this socket has already been closed, i.e. ifisClosed() == true.NullPointerException- Ifrequestwasnull.- See Also:
-
applyChange
Applies the provided change request to the Directory Server.If you need to handle
IntermediateResponses, please usesend(Request)instead.Note that the request will only be sent when the returned
Singlehas been subscribed.- Parameters:
request- The change request.- Returns:
- The asynchronous result of the operation. Note that this
Singlecan be subscribed only once. Canceling the subscription of thisSinglewill send anAbandonRequestto the server. - Throws:
UnsupportedOperationException- If this socket does not support the provided change request.IllegalStateException- If this socket has already been closed, i.e. ifisClosed() == true.NullPointerException- Ifrequestwasnull.- See Also:
-