org.apache.hc.core5.reactor.ssl

## Class SSLIOSession

- java.lang.Object
- - org.apache.hc.core5.reactor.ssl.SSLIOSession

- All Implemented Interfaces:
    Closeable, AutoCloseable, ByteChannel, Channel, ReadableByteChannel, WritableByteChannel, SocketModalCloseable, ModalCloseable, IOSession, Identifiable

      @Contract(threading=SAFE_CONDITIONAL)
       @Internal
      public class SSLIOSession
      extends Object
      implements IOSession

  `SSLIOSession` is a decorator class intended to transparently extend an `IOSession` with transport layer security capabilities based on the SSL/TLS protocol.
  Since:
    4.2

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.hc.core5.reactor.IOSession

      `IOSession.Status`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SSLIOSession(NamedEndpoint targetEndpoint, IOSession session, SSLMode sslMode, SSLContext sslContext, SSLBufferMode sslBufferMode, SSLSessionInitializer initializer, SSLSessionVerifier verifier, Callback<SSLIOSession> sessionStartCallback, Callback<SSLIOSession> sessionEndCallback, Timeout connectTimeout)` Creates new instance of `SSLIOSession` class.
    `SSLIOSession(NamedEndpoint targetEndpoint, IOSession session, SSLMode sslMode, SSLContext sslContext, SSLBufferMode sslBufferMode, SSLSessionInitializer initializer, SSLSessionVerifier verifier, Timeout handshakeTimeout, Callback<SSLIOSession> sessionStartCallback, Callback<SSLIOSession> sessionEndCallback, FutureCallback<SSLSession> resultCallback)` Creates new instance of `SSLIOSession` class.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `beginHandshake(IOSession protocolSession)`
    `ByteChannel` | `channel()` Returns the underlying I/O channel associated with this session.
    `void` | `clearEvent(int op)` Clears interest in a particular I/O event type by updating the event mask associated with the session.
    `void` | `close()` Terminates the session gracefully and closes the underlying I/O channel.
    `void` | `close(CloseMode closeMode)` Closes this process or endpoint and releases any system resources associated with it.
    `void` | `enqueue(Command command, Command.Priority priority)` Inserts `Command` at the end of the command queue.
    `int` | `getEventMask()` Returns mask of I/O evens this session declared interest in.
    `IOEventHandler` | `getHandler()` Returns event handler associated with the session.
    `String` | `getId()`
    `long` | `getLastEventTime()` Returns timestamp of the last I/O event including socket timeout reset.
    `long` | `getLastReadTime()` Returns timestamp of the last read event.
    `long` | `getLastWriteTime()` Returns timestamp of the last write event.
    `SocketAddress` | `getLocalAddress()` Returns local address.
    `Lock` | `getLock()` Returns session lock that should be used by I/O event handlers to synchronize access to the session.
    `SocketAddress` | `getRemoteAddress()` Returns address of the remote peer.
    `Timeout` | `getSocketTimeout()` Returns value of the socket timeout in milliseconds.
    `IOSession.Status` | `getStatus()` Returns status of the session:
    `TlsDetails` | `getTlsDetails()`
    `boolean` | `hasCommands()` Tests if there enqueued commands pending execution.
    `boolean` | `isOpen()`
    `Command` | `poll()` Removes first `Command` from the command queue if available.
    `int` | `read(ByteBuffer dst)`
    `void` | `setEvent(int op)` Declares interest in a particular I/O event type by updating the event mask associated with the session.
    `void` | `setEventMask(int ops)` Declares interest in I/O event notifications by setting the event mask associated with the session
    `void` | `setSocketTimeout(Timeout timeout)` Sets value of the socket timeout in milliseconds.
    `String` | `toString()`
    `void` | `updateReadTime()` Updates the timestamp of the last read event
    `void` | `updateWriteTime()` Updates the timestamp of the last write event
    `void` | `upgrade(IOEventHandler handler)` Upgrades event handler associated with the session.
    `int` | `write(ByteBuffer src)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SSLIOSession

          public SSLIOSession(NamedEndpoint targetEndpoint,
                              IOSession session,
                              SSLMode sslMode,
                              SSLContext sslContext,
                              SSLBufferMode sslBufferMode,
                              SSLSessionInitializer initializer,
                              SSLSessionVerifier verifier,
                              Callback<SSLIOSession> sessionStartCallback,
                              Callback<SSLIOSession> sessionEndCallback,
                              Timeout connectTimeout)

      Creates new instance of `SSLIOSession` class.
      Parameters:
        `session` - I/O session to be decorated with the TLS/SSL capabilities.
        `sslMode` - SSL mode (client or server)
        `targetEndpoint` - target endpoint (applicable in client mode only). May be `null`.
        `sslContext` - SSL context to use for this I/O session.
        `sslBufferMode` - buffer management mode
        `initializer` - optional SSL session initializer. May be `null`.
        `verifier` - optional SSL session verifier. May be `null`.
        `connectTimeout` - timeout to apply for the TLS/SSL handshake. May be `null`.
      Since:
        5.0

    - #### SSLIOSession

          public SSLIOSession(NamedEndpoint targetEndpoint,
                              IOSession session,
                              SSLMode sslMode,
                              SSLContext sslContext,
                              SSLBufferMode sslBufferMode,
                              SSLSessionInitializer initializer,
                              SSLSessionVerifier verifier,
                              Timeout handshakeTimeout,
                              Callback<SSLIOSession> sessionStartCallback,
                              Callback<SSLIOSession> sessionEndCallback,
                              FutureCallback<SSLSession> resultCallback)

      Creates new instance of `SSLIOSession` class.
      Parameters:
        `session` - I/O session to be decorated with the TLS/SSL capabilities.
        `sslMode` - SSL mode (client or server)
        `targetEndpoint` - target endpoint (applicable in client mode only). May be `null`.
        `sslContext` - SSL context to use for this I/O session.
        `sslBufferMode` - buffer management mode
        `initializer` - optional SSL session initializer. May be `null`.
        `verifier` - optional SSL session verifier. May be `null`.
        `handshakeTimeout` - timeout to apply for the TLS/SSL handshake. May be `null`.
        `resultCallback` - result callback. May be `null`.
      Since:
        5.2

  - ### Method Detail

    - #### getHandler

          public IOEventHandler getHandler()

      Description copied from interface: `IOSession`
      Returns event handler associated with the session.
      Specified by:
        `getHandler` in interface `IOSession`

    - #### beginHandshake

          public void beginHandshake(IOSession protocolSession)
                              throws IOException

      Throws:
        `IOException`

    - #### write

          public int write(ByteBuffer src)
                    throws IOException

      Specified by:
        `write` in interface `WritableByteChannel`
      Throws:
        `IOException`

    - #### read

          public int read(ByteBuffer dst)

      Specified by:
        `read` in interface `ReadableByteChannel`

    - #### getId

          public String getId()

      Specified by:
        `getId` in interface `Identifiable`

    - #### getLock

          public Lock getLock()

      Description copied from interface: `IOSession`
      Returns session lock that should be used by I/O event handlers to synchronize access to the session.
      Specified by:
        `getLock` in interface `IOSession`

    - #### upgrade

          public void upgrade(IOEventHandler handler)

      Description copied from interface: `IOSession`
      Upgrades event handler associated with the session.
      Specified by:
        `upgrade` in interface `IOSession`

    - #### getTlsDetails

          public TlsDetails getTlsDetails()

    - #### isOpen

          public boolean isOpen()

      Specified by:
        `isOpen` in interface `Channel`

    - #### close

          public void close()

      Description copied from interface: `IOSession`
      Terminates the session gracefully and closes the underlying I/O channel. This method ensures that session termination handshake, such as the one used by the SSL/TLS protocol, is correctly carried out.
      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `Channel`
      Specified by:
        `close` in interface `IOSession`

    - #### close

          public void close(CloseMode closeMode)

      Description copied from interface: `ModalCloseable`
      Closes this process or endpoint and releases any system resources associated with it. If the endpoint or the process is already closed then invoking this method has no effect.
      Specified by:
        `close` in interface `ModalCloseable`
      Parameters:
        `closeMode` - How to close the receiver.

    - #### getStatus

          public IOSession.Status getStatus()

      Description copied from interface: `IOSession`
      Returns status of the session:

      `IOSession.Status.ACTIVE`: session is active.

      `IOSession.Status.CLOSING`: session is being closed.

      `IOSession.Status.CLOSED`: session has been terminated.

      Specified by:
        `getStatus` in interface `IOSession`
      Returns:
        session status.

    - #### enqueue

          public void enqueue(Command command,
                              Command.Priority priority)

      Description copied from interface: `IOSession`
      Inserts `Command` at the end of the command queue.
      Specified by:
        `enqueue` in interface `IOSession`

    - #### hasCommands

          public boolean hasCommands()

      Description copied from interface: `IOSession`
      Tests if there enqueued commands pending execution.
      Specified by:
        `hasCommands` in interface `IOSession`

    - #### poll

          public Command poll()

      Description copied from interface: `IOSession`
      Removes first `Command` from the command queue if available.
      Specified by:
        `poll` in interface `IOSession`

    - #### channel

          public ByteChannel channel()

      Description copied from interface: `IOSession`
      Returns the underlying I/O channel associated with this session.
      Specified by:
        `channel` in interface `IOSession`
      Returns:
        the I/O channel.

    - #### getLocalAddress

          public SocketAddress getLocalAddress()

      Description copied from interface: `IOSession`
      Returns local address.
      Specified by:
        `getLocalAddress` in interface `IOSession`
      Returns:
        socket address.

    - #### getRemoteAddress

          public SocketAddress getRemoteAddress()

      Description copied from interface: `IOSession`
      Returns address of the remote peer.
      Specified by:
        `getRemoteAddress` in interface `IOSession`
      Returns:
        socket address.

    - #### getEventMask

          public int getEventMask()

      Description copied from interface: `IOSession`
      Returns mask of I/O evens this session declared interest in.
      Specified by:
        `getEventMask` in interface `IOSession`
      Returns:
        I/O event mask.

    - #### setEventMask

          public void setEventMask(int ops)

      Description copied from interface: `IOSession`
      Declares interest in I/O event notifications by setting the event mask associated with the session
      Specified by:
        `setEventMask` in interface `IOSession`
      Parameters:
        `ops` - new I/O event mask.

    - #### setEvent

          public void setEvent(int op)

      Description copied from interface: `IOSession`
      Declares interest in a particular I/O event type by updating the event mask associated with the session.
      Specified by:
        `setEvent` in interface `IOSession`
      Parameters:
        `op` - I/O event type.

    - #### clearEvent

          public void clearEvent(int op)

      Description copied from interface: `IOSession`
      Clears interest in a particular I/O event type by updating the event mask associated with the session.
      Specified by:
        `clearEvent` in interface `IOSession`
      Parameters:
        `op` - I/O event type.

    - #### getSocketTimeout

          public Timeout getSocketTimeout()

      Description copied from interface: `IOSession`
      Returns value of the socket timeout in milliseconds. The value of `0` signifies the session cannot time out.
      Specified by:
        `getSocketTimeout` in interface `SocketModalCloseable`
      Specified by:
        `getSocketTimeout` in interface `IOSession`
      Returns:
        socket timeout.

    - #### setSocketTimeout

          public void setSocketTimeout(Timeout timeout)

      Description copied from interface: `IOSession`
      Sets value of the socket timeout in milliseconds. The value of `0` signifies the session cannot time out.

      Please note this operation may affect the last event time.

      Specified by:
        `setSocketTimeout` in interface `SocketModalCloseable`
      Specified by:
        `setSocketTimeout` in interface `IOSession`
      Parameters:
        `timeout` - socket timeout.
      See Also:
        `IOSession.getLastEventTime()`

    - #### updateReadTime

          public void updateReadTime()

      Description copied from interface: `IOSession`
      Updates the timestamp of the last read event
      Specified by:
        `updateReadTime` in interface `IOSession`

    - #### updateWriteTime

          public void updateWriteTime()

      Description copied from interface: `IOSession`
      Updates the timestamp of the last write event
      Specified by:
        `updateWriteTime` in interface `IOSession`

    - #### getLastReadTime

          public long getLastReadTime()

      Description copied from interface: `IOSession`
      Returns timestamp of the last read event.
      Specified by:
        `getLastReadTime` in interface `IOSession`
      Returns:
        timestamp.

    - #### getLastWriteTime

          public long getLastWriteTime()

      Description copied from interface: `IOSession`
      Returns timestamp of the last write event.
      Specified by:
        `getLastWriteTime` in interface `IOSession`
      Returns:
        timestamp.

    - #### getLastEventTime

          public long getLastEventTime()

      Description copied from interface: `IOSession`
      Returns timestamp of the last I/O event including socket timeout reset.
      Specified by:
        `getLastEventTime` in interface `IOSession`
      Returns:
        timestamp.
      See Also:
        `IOSession.getSocketTimeout()`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.