Class JSSSocketChannel

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.ByteChannel, java.nio.channels.Channel, java.nio.channels.GatheringByteChannel, java.nio.channels.InterruptibleChannel, java.nio.channels.NetworkChannel, java.nio.channels.ReadableByteChannel, java.nio.channels.ScatteringByteChannel, java.nio.channels.WritableByteChannel

    public class JSSSocketChannel
    extends java.nio.channels.SocketChannel
    SSL-enabled SocketChannel following the javax.net.ssl.SSLSocket interface. This class should never be constructed directly and instead only accessed once a Socket is wrapped in a JSSSocket. This class contains all low-level interactions with the underlying SSLEngine and reading/writing to/from the underlying Socket.
    • Constructor Summary

      Constructors 
      Constructor Description
      JSSSocketChannel​(JSSSocket sslSocket, java.net.Socket parentSocket, java.nio.channels.ReadableByteChannel readChannel, java.nio.channels.WritableByteChannel writeChannel, JSSEngine engine)  
      JSSSocketChannel​(JSSSocket sslSocket, java.nio.channels.SocketChannel parent, java.net.Socket parentSocket, java.nio.channels.ReadableByteChannel readChannel, java.nio.channels.WritableByteChannel writeChannel, JSSEngine engine)  
      JSSSocketChannel​(JSSSocket sslSocket, java.nio.channels.SocketChannel parent, JSSEngine engine)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      JSSSocketChannel bind​(java.net.SocketAddress local)  
      boolean connect​(java.net.SocketAddress remote)  
      boolean finishConnect()  
      java.net.SocketAddress getLocalAddress()  
      <T> T getOption​(java.net.SocketOption<T> name)  
      java.net.SocketAddress getRemoteAddress()  
      void implCloseSelectableChannel()  
      void implConfigureBlocking​(boolean block)  
      boolean isConnected()  
      boolean isConnectionPending()  
      int read​(java.nio.ByteBuffer dst)  
      long read​(java.nio.ByteBuffer[] dsts, int offset, int length)  
      void setAutoClose​(boolean on)
      Set whether or not to close the underlying Socket when the SSLSocket or this channel is closed.
      void setConsumedData​(java.io.InputStream consumed)
      Give data already consumed by a call to the underlying socket's read method to this Socket, allowing it to be read by the SSLEngine.
      <T> JSSSocketChannel setOption​(java.net.SocketOption<T> name, T value)  
      JSSSocketChannel shutdownInput()  
      JSSSocketChannel shutdownOutput()  
      JSSSocket socket()  
      java.util.Set<java.net.SocketOption<?>> supportedOptions()  
      int write​(java.nio.ByteBuffer src)  
      long write​(java.nio.ByteBuffer[] srcs, int offset, int length)  
      • Methods inherited from class java.nio.channels.SocketChannel

        open, open, read, validOps, write
      • Methods inherited from class java.nio.channels.spi.AbstractSelectableChannel

        blockingLock, configureBlocking, implCloseChannel, isBlocking, isRegistered, keyFor, provider, register
      • Methods inherited from class java.nio.channels.SelectableChannel

        register
      • Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel

        begin, close, end, isOpen
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.nio.channels.Channel

        isOpen
    • Constructor Detail

      • JSSSocketChannel

        public JSSSocketChannel​(JSSSocket sslSocket,
                                java.nio.channels.SocketChannel parent,
                                java.net.Socket parentSocket,
                                java.nio.channels.ReadableByteChannel readChannel,
                                java.nio.channels.WritableByteChannel writeChannel,
                                JSSEngine engine)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • JSSSocketChannel

        public JSSSocketChannel​(JSSSocket sslSocket,
                                java.nio.channels.SocketChannel parent,
                                JSSEngine engine)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • JSSSocketChannel

        public JSSSocketChannel​(JSSSocket sslSocket,
                                java.net.Socket parentSocket,
                                java.nio.channels.ReadableByteChannel readChannel,
                                java.nio.channels.WritableByteChannel writeChannel,
                                JSSEngine engine)
                         throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • setConsumedData

        public void setConsumedData​(java.io.InputStream consumed)
                             throws java.io.IOException
        Give data already consumed by a call to the underlying socket's read method to this Socket, allowing it to be read by the SSLEngine.
        Throws:
        java.io.IOException
      • setAutoClose

        public void setAutoClose​(boolean on)
        Set whether or not to close the underlying Socket when the SSLSocket or this channel is closed.
      • finishConnect

        public boolean finishConnect()
                              throws java.io.IOException
        Specified by:
        finishConnect in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • read

        public int read​(java.nio.ByteBuffer dst)
                 throws java.io.IOException
        Specified by:
        read in interface java.nio.channels.ReadableByteChannel
        Specified by:
        read in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • read

        public long read​(java.nio.ByteBuffer[] dsts,
                         int offset,
                         int length)
                  throws java.io.IOException
        Specified by:
        read in interface java.nio.channels.ScatteringByteChannel
        Specified by:
        read in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • write

        public int write​(java.nio.ByteBuffer src)
                  throws java.io.IOException
        Specified by:
        write in interface java.nio.channels.WritableByteChannel
        Specified by:
        write in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • write

        public long write​(java.nio.ByteBuffer[] srcs,
                          int offset,
                          int length)
                   throws java.io.IOException
        Specified by:
        write in interface java.nio.channels.GatheringByteChannel
        Specified by:
        write in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • implCloseSelectableChannel

        public void implCloseSelectableChannel()
                                        throws java.io.IOException
        Specified by:
        implCloseSelectableChannel in class java.nio.channels.spi.AbstractSelectableChannel
        Throws:
        java.io.IOException
      • bind

        public JSSSocketChannel bind​(java.net.SocketAddress local)
                              throws java.io.IOException
        Specified by:
        bind in interface java.nio.channels.NetworkChannel
        Specified by:
        bind in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • connect

        public boolean connect​(java.net.SocketAddress remote)
                        throws java.io.IOException
        Specified by:
        connect in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • getOption

        public <T> T getOption​(java.net.SocketOption<T> name)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • supportedOptions

        public java.util.Set<java.net.SocketOption<?>> supportedOptions()
      • setOption

        public <T> JSSSocketChannel setOption​(java.net.SocketOption<T> name,
                                              T value)
                                       throws java.io.IOException
        Specified by:
        setOption in interface java.nio.channels.NetworkChannel
        Specified by:
        setOption in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • socket

        public JSSSocket socket()
        Specified by:
        socket in class java.nio.channels.SocketChannel
      • isConnected

        public boolean isConnected()
        Specified by:
        isConnected in class java.nio.channels.SocketChannel
      • isConnectionPending

        public boolean isConnectionPending()
        Specified by:
        isConnectionPending in class java.nio.channels.SocketChannel
      • getLocalAddress

        public java.net.SocketAddress getLocalAddress()
                                               throws java.io.IOException
        Specified by:
        getLocalAddress in interface java.nio.channels.NetworkChannel
        Specified by:
        getLocalAddress in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • getRemoteAddress

        public java.net.SocketAddress getRemoteAddress()
                                                throws java.io.IOException
        Specified by:
        getRemoteAddress in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • shutdownInput

        public JSSSocketChannel shutdownInput()
                                       throws java.io.IOException
        Specified by:
        shutdownInput in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • shutdownOutput

        public JSSSocketChannel shutdownOutput()
                                        throws java.io.IOException
        Specified by:
        shutdownOutput in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • implConfigureBlocking

        public void implConfigureBlocking​(boolean block)
                                   throws java.io.IOException
        Specified by:
        implConfigureBlocking in class java.nio.channels.spi.AbstractSelectableChannel
        Throws:
        java.io.IOException