org.java_websocket
Class SSLSocketChannel2

java.lang.Object
  extended by org.java_websocket.SSLSocketChannel2
All Implemented Interfaces:
Closeable, ByteChannel, Channel, ReadableByteChannel, WritableByteChannel, WrappedByteChannel

public class SSLSocketChannel2
extends Object
implements ByteChannel, WrappedByteChannel

Implements the relevant portions of the SocketChannel interface with the SSLEngine wrapper.


Field Summary
protected static ByteBuffer emptybuffer
           
protected  SSLEngineResult engineResult
           
protected  ExecutorService exec
           
protected  ByteBuffer inCrypt
          encrypted data incoming
protected  ByteBuffer inData
          raw payload incomming
protected  ByteBuffer outCrypt
          encrypted data outgoing
protected  SelectionKey selectionKey
          used to set interestOP SelectionKey.OP_WRITE for the underlying channel
protected  SocketChannel socketChannel
          the underlying channel
protected  SSLEngine sslEngine
           
protected  List<Future<?>> tasks
           
 
Constructor Summary
SSLSocketChannel2(SocketChannel channel, SSLEngine sslEngine, ExecutorService exec, SelectionKey key)
           
 
Method Summary
 void close()
           
 SelectableChannel configureBlocking(boolean b)
           
 boolean connect(SocketAddress remote)
           
protected  void consumeDelegatedTasks()
           
protected  void createBuffers(SSLSession session)
           
 boolean finishConnect()
           
 boolean isBlocking()
           
 boolean isConnected()
           
 boolean isInboundDone()
           
 boolean isNeedRead()
          returns whether readMore should be called to fetch data which has been decoded but not yet been returned.
 boolean isNeedWrite()
           
 boolean isOpen()
           
 int read(ByteBuffer dst)
          Blocks when in blocking mode until at least one byte has been decoded.
When not in blocking mode 0 may be returned.
 int readMore(ByteBuffer dst)
          This function does not read data from the underlying channel at all.
 Socket socket()
           
 int write(ByteBuffer src)
           
 void writeMore()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

emptybuffer

protected static ByteBuffer emptybuffer

exec

protected ExecutorService exec

tasks

protected List<Future<?>> tasks

inData

protected ByteBuffer inData
raw payload incomming


outCrypt

protected ByteBuffer outCrypt
encrypted data outgoing


inCrypt

protected ByteBuffer inCrypt
encrypted data incoming


socketChannel

protected SocketChannel socketChannel
the underlying channel


selectionKey

protected SelectionKey selectionKey
used to set interestOP SelectionKey.OP_WRITE for the underlying channel


engineResult

protected SSLEngineResult engineResult

sslEngine

protected SSLEngine sslEngine
Constructor Detail

SSLSocketChannel2

public SSLSocketChannel2(SocketChannel channel,
                         SSLEngine sslEngine,
                         ExecutorService exec,
                         SelectionKey key)
                  throws IOException
Throws:
IOException
Method Detail

consumeDelegatedTasks

protected void consumeDelegatedTasks()

createBuffers

protected void createBuffers(SSLSession session)

write

public int write(ByteBuffer src)
          throws IOException
Specified by:
write in interface WritableByteChannel
Throws:
IOException

read

public int read(ByteBuffer dst)
         throws IOException
Blocks when in blocking mode until at least one byte has been decoded.
When not in blocking mode 0 may be returned.

Specified by:
read in interface ReadableByteChannel
Throws:
IOException

isConnected

public boolean isConnected()

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in interface Channel
Throws:
IOException

configureBlocking

public SelectableChannel configureBlocking(boolean b)
                                    throws IOException
Throws:
IOException

connect

public boolean connect(SocketAddress remote)
                throws IOException
Throws:
IOException

finishConnect

public boolean finishConnect()
                      throws IOException
Throws:
IOException

socket

public Socket socket()

isInboundDone

public boolean isInboundDone()

isOpen

public boolean isOpen()
Specified by:
isOpen in interface Channel

isNeedWrite

public boolean isNeedWrite()
Specified by:
isNeedWrite in interface WrappedByteChannel

writeMore

public void writeMore()
               throws IOException
Specified by:
writeMore in interface WrappedByteChannel
Throws:
IOException

isNeedRead

public boolean isNeedRead()
Description copied from interface: WrappedByteChannel
returns whether readMore should be called to fetch data which has been decoded but not yet been returned.

Specified by:
isNeedRead in interface WrappedByteChannel
See Also:
ReadableByteChannel.read(ByteBuffer), WrappedByteChannel.readMore(ByteBuffer)

readMore

public int readMore(ByteBuffer dst)
             throws SSLException
Description copied from interface: WrappedByteChannel
This function does not read data from the underlying channel at all. It is just a way to fetch data which has already be received or decoded but was but was not yet returned to the user. This could be the case when the decoded data did not fit into the buffer the user passed to ReadableByteChannel.read(ByteBuffer).

Specified by:
readMore in interface WrappedByteChannel
Throws:
SSLException

isBlocking

public boolean isBlocking()
Specified by:
isBlocking in interface WrappedByteChannel


Copyright © 2013 Pusher. All Rights Reserved.