Class AsyncChannelWrapperSecure

java.lang.Object
org.apache.tomcat.websocket.AsyncChannelWrapperSecure
All Implemented Interfaces:
AsyncChannelWrapper

public class AsyncChannelWrapperSecure extends Object implements AsyncChannelWrapper
Wraps the AsynchronousSocketChannel with SSL/TLS. This needs a lot more testing before it can be considered robust.
  • Constructor Details

    • AsyncChannelWrapperSecure

      public AsyncChannelWrapperSecure(AsynchronousSocketChannel socketChannel, SSLEngine sslEngine)
      Constructs a new secure wrapper for the given channel and SSL engine.
      Parameters:
      socketChannel - the underlying AsynchronousSocketChannel
      sslEngine - the SSL engine for encryption
  • Method Details

    • read

      public Future<Integer> read(ByteBuffer dst)
      Description copied from interface: AsyncChannelWrapper
      Reads data from the channel into the given buffer.
      Specified by:
      read in interface AsyncChannelWrapper
      Parameters:
      dst - the buffer into which data is to be read
      Returns:
      a Future holding the number of bytes read
    • read

      public <B, A extends B> void read(ByteBuffer dst, A attachment, CompletionHandler<Integer,B> handler)
      Description copied from interface: AsyncChannelWrapper
      Reads data from the channel into the given buffer with a completion handler.
      Specified by:
      read in interface AsyncChannelWrapper
      Type Parameters:
      B - the attachment type
      A - the attachment subtype
      Parameters:
      dst - the buffer into which data is to be read
      attachment - the object to attach to the task
      handler - the handler to use on completion
    • write

      public Future<Integer> write(ByteBuffer src)
      Description copied from interface: AsyncChannelWrapper
      Writes data from the given buffer to the channel.
      Specified by:
      write in interface AsyncChannelWrapper
      Parameters:
      src - the buffer from which data is to be written
      Returns:
      a Future holding the number of bytes written
    • write

      public <B, A extends B> void write(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long,B> handler)
      Description copied from interface: AsyncChannelWrapper
      Writes data from the given buffers to the channel with a completion handler.
      Specified by:
      write in interface AsyncChannelWrapper
      Type Parameters:
      B - the attachment type
      A - the attachment subtype
      Parameters:
      srcs - the buffers from which data is to be written
      offset - the offset within the buffer array
      length - the number of buffers to write
      timeout - the maximum time to wait
      unit - the time unit of the timeout
      attachment - the object to attach to the task
      handler - the handler to use on completion
    • close

      public void close()
      Description copied from interface: AsyncChannelWrapper
      Closes the underlying channel.
      Specified by:
      close in interface AsyncChannelWrapper
    • handshake

      public Future<Void> handshake() throws SSLException
      Description copied from interface: AsyncChannelWrapper
      Performs the SSL/TLS handshake.
      Specified by:
      handshake in interface AsyncChannelWrapper
      Returns:
      a Future that completes when the handshake is finished
      Throws:
      SSLException - if an SSL error occurs
    • getLocalAddress

      public SocketAddress getLocalAddress() throws IOException
      Description copied from interface: AsyncChannelWrapper
      Returns the local address to which the channel is bound.
      Specified by:
      getLocalAddress in interface AsyncChannelWrapper
      Returns:
      the local socket address, or null if not bound
      Throws:
      IOException - if an I/O error occurs