Interface LdapSocket

  • All Superinterfaces:
    AutoCloseable, Closeable

    public interface LdapSocket
    extends Closeable
    A socket implementation representing a stream of LDAP messages. LDAP sockets are role agnostic and may be used for implementing LDAP clients and servers.

    Support for StartTLS is provided through the usage of StartTlsExtendedRequest. Support for SASL quality of protection is provided through the usage of BindRequest.

    • Method Detail

      • read

        Flowable<LdapMessage> read()
        Returns a Flowable of LDAP messages read from the network. Message reception is suspended until a subscriber subscribes to it. Note that no message will be dropped in the mean time.

        This Flowable only supports one Subscriber. Subsequent Subscribers will receive an IllegalStateException. Consider subscribing using one of the FlowableProcessor implementations in order to broadcast messages to multiple subscribers.

        If this socket is disconnected locally using close() or closeWithReason(Throwable), then the subscriber will be notified through Subscriber.onError(Throwable) with the exception provided to the abort method or EOFException if none was provided.

        When this socket is disconnected remotely by the peer, the subscriber will be notified through Subscriber.onComplete().

        Returns:
        The stream of LdapMessages read from the network.
      • write

        Completable write​(Flowable<LdapMessage> messages)
        Returns a Completable which, once subscribed, will write all the messages to the network.

        The publisher must respect back-pressure constraints which reflect the capacity of the remote peer to read the flow of messages.

        When this socket is disconnected, the Completable will be signaled with an EOFException and the messages stream will be Subscription.cancel()ed.

        Parameters:
        messages - The stream of message to write.
        Returns:
        A Completable transmitting all messages to the network.
      • write

        default Completable write​(LdapMessage message)
        Returns a Completable which, once subscribed, will write the message to the network.

        When this socket is disconnected, the Completable will be signaled with an EOFException.

        Parameters:
        message - The message to write.
        Returns:
        A Completable transmitting the message to the network.
      • getLocalAddress

        InetSocketAddress getLocalAddress()
        Returns the InetSocketAddress associated with the local system.
        Returns:
        The InetSocketAddress associated with the local system.
      • getRemoteAddress

        InetSocketAddress getRemoteAddress()
        Returns the InetSocketAddress associated with the remote system.
        Returns:
        The InetSocketAddress associated with the remote system.
      • getSslSession

        SSLSession getSslSession()
        Returns the SSL session currently in use by the underlying connection, or null if SSL/TLS is not enabled.
        Returns:
        The SSL session currently in use by the underlying connection, or null if SSL/TLS is not enabled.
      • getSaslServer

        SaslServer getSaslServer()
        Returns the SaslServer currently in use by the underlying connection, or null if SASL integrity and/or privacy protection is not enabled.
        Returns:
        The SaslServer currently in use by the underlying connection, or null if SASL integrity and/or privacy protection is not enabled.
      • getSaslClient

        SaslClient getSaslClient()
        Returns the SaslClient currently in use by the underlying connection, or null if SASL integrity and/or privacy protection is not enabled.
        Returns:
        The SaslClient currently in use by the underlying connection, or null if SASL integrity and/or privacy protection is not enabled.
      • close

        void close()
        Disconnects this socket. Disconnecting the socket will invoke read()'s Subscriber.onError(Throwable) with a EOFException and will cancel the write(Flowable)'s publisher. All messages which have not yet been sent could be dropped.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
      • closeWithReason

        void closeWithReason​(Throwable reason)
        Disconnects the socket. Disconnecting the socket will invoke read()'s Subscriber.onError(Throwable) with the provided reason. All messages which have not yet been sent could be dropped.
        Parameters:
        reason - The reason of this disconnection.
      • isClosed

        boolean isClosed()
        Returns true if this socket is disconnected (locally or remotely) or false if this socket is still connected to a peer.
        Returns:
        true if this socket is disconnected (locally or remotely) or false if this socket is still connected to a peer.