Class AsyncChannelWrapperSecure

  • All Implemented Interfaces:
    AsyncChannelWrapper

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

      Constructors 
      Constructor Description
      AsyncChannelWrapperSecure​(java.nio.channels.AsynchronousSocketChannel socketChannel, javax.net.ssl.SSLEngine sslEngine)
      Constructs a new secure wrapper for the given channel and SSL engine.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the underlying channel.
      java.net.SocketAddress getLocalAddress()
      Returns the local address to which the channel is bound.
      java.util.concurrent.Future<java.lang.Void> handshake()
      Performs the SSL/TLS handshake.
      java.util.concurrent.Future<java.lang.Integer> read​(java.nio.ByteBuffer dst)
      Reads data from the channel into the given buffer.
      <B,​A extends B>
      void
      read​(java.nio.ByteBuffer dst, A attachment, java.nio.channels.CompletionHandler<java.lang.Integer,​B> handler)
      Reads data from the channel into the given buffer with a completion handler.
      java.util.concurrent.Future<java.lang.Integer> write​(java.nio.ByteBuffer src)
      Writes data from the given buffer to the channel.
      <B,​A extends B>
      void
      write​(java.nio.ByteBuffer[] srcs, int offset, int length, long timeout, java.util.concurrent.TimeUnit unit, A attachment, java.nio.channels.CompletionHandler<java.lang.Long,​B> handler)
      Writes data from the given buffers to the channel with a completion handler.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AsyncChannelWrapperSecure

        public AsyncChannelWrapperSecure​(java.nio.channels.AsynchronousSocketChannel socketChannel,
                                         javax.net.ssl.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 Detail

      • read

        public java.util.concurrent.Future<java.lang.Integer> read​(java.nio.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​(java.nio.ByteBuffer dst,
                                               A attachment,
                                               java.nio.channels.CompletionHandler<java.lang.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 java.util.concurrent.Future<java.lang.Integer> write​(java.nio.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​(java.nio.ByteBuffer[] srcs,
                                                int offset,
                                                int length,
                                                long timeout,
                                                java.util.concurrent.TimeUnit unit,
                                                A attachment,
                                                java.nio.channels.CompletionHandler<java.lang.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
      • handshake

        public java.util.concurrent.Future<java.lang.Void> handshake()
                                                              throws javax.net.ssl.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:
        javax.net.ssl.SSLException - if an SSL error occurs
      • getLocalAddress

        public java.net.SocketAddress getLocalAddress()
                                               throws java.io.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:
        java.io.IOException - if an I/O error occurs