com.sun.grizzly
Class SSLConnectorHandler

java.lang.Object
  extended by com.sun.grizzly.SSLConnectorHandler
All Implemented Interfaces:
AsyncQueueReadable, AsyncQueueWritable, CallbackHandler, ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>, Handler, Closeable

public class SSLConnectorHandler
extends Object
implements ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>, CallbackHandler, AsyncQueueWritable, AsyncQueueReadable

Non blocking SSL Connector Handler. The recommended way to use this class is by creating an external Controller and share the same SelectorHandler instance.

Recommended -----------


 Controller controller = new Controller();
 // new SSLSelectorHandler(true) means the Selector will be used only
 // for client operation (OP_READ, OP_WRITE, OP_CONNECT).
 SSLSelectorHandler sslSelectorHandler = new SSLSelectorHandler(true);
 controller.setSelectorHandler(sslSelectorHandler);
 SSLConnectorHandler sslConnectorHandler = new SSLConnectorHandler();
 sslConnectorHandler.connect(localhost,port, new SSLCallbackHandler(){...},
                             sslSelectorHandler);
 SSLConnectorHandler sslConnectorHandler2 = new SSLConnectorHandler();
 sslConnectorHandler2.connect(localhost,port, new SSLCallbackHandler(){...},
                             sslSelectorHandler);
 

Not recommended (but still works) ---------------------------------


 SSLConnectorHandler sslConnectorHandler = new SSLConnectorHandler();
 sslConnectorHandler.connect(localhost,port);

 Internally, an new Controller will be created everytime connect(localhost,port)
 is invoked, which has an impact on performance.

 As common comment: developer should be very careful if dealing directly with
 SSLConnectorHandler's underlying socket channel! In most cases
 there is no need to do this, but use read, write methods provided
 by SSLConnectorHandler
 

Author:
Alexey Stashok, Jeanfrancois Arcand

Constructor Summary
SSLConnectorHandler()
           
SSLConnectorHandler(SSLConfig sslConfig)
           
SSLConnectorHandler(SSLContext sslContext)
           
 
Method Summary
 void close()
          Close the underlying connection.
 void configure(SSLConfig sslConfig)
          Configure SSLConnectorHandler's SSL settings.
 void connect(SocketAddress remoteAddress)
          Connect to hostname:port.
 void connect(SocketAddress remoteAddress, SocketAddress localAddress)
          Connect to hostname:port.
 void connect(SocketAddress remoteAddress, SocketAddress localAddress, SSLCallbackHandler callbackHandler)
          Connect to hostname:port.
 void connect(SocketAddress remoteAddress, SocketAddress localAddress, SSLCallbackHandler callbackHandler, SSLSelectorHandler selectorHandler)
          Connect to hostname:port.
 void connect(SocketAddress remoteAddress, SSLCallbackHandler callbackHandler)
          Connect to hostname:port.
 void connect(SocketAddress remoteAddress, SSLCallbackHandler callbackHandler, SSLSelectorHandler selectorHandler)
          Connect to hostname:port.
 void finishConnect(SelectionKey key)
          Finish handling the OP_CONNECT interest ops.
 void finishHandshake()
          Changes SSLConnectorHandler state, after handshake operation is done.
 int getApplicationBufferSize()
          Gets the size of the largest application buffer that may occur when using this session.
 SSLCallbackHandler getCallbackHandler()
          Returns ConnectorHandler's callback handler instance, which is used to process occuring events
 Controller getController()
          Return the Controller
 boolean getDelegateSSLTasks()
           
 ByteBuffer getSecuredInputBuffer()
          Returns SSLConnectorHandler's secured input buffer, it uses for reading data from a socket channel.
 ByteBuffer getSecuredOutputBuffer()
          Returns SSLConnectorHandler's secured output buffer, it uses for writing data to a socket channel.
 SSLSelectorHandler getSelectorHandler()
          Method returns SelectorHandler, which manages this ConnectorHandler
 SSLContext getSSLContext()
          Get SSLConnector's SSLContext
 SSLEngine getSSLEngine()
          Returns SSLConnector's SSLEngine
 SelectableChannel getUnderlyingChannel()
          Method returns ConnectorHandler's underlying channel
 boolean handshake(ByteBuffer byteBuffer, boolean blocking)
          Initiate SSL handshake phase.
 boolean isConnected()
          Is the underlying SocketChannel connected.
 boolean isHandshakeDone()
          Is the underlying SocketChannel connected.
 void onConnect(IOEvent ioEvent)
          This method is called when an non blocking OP_CONNECT is ready to get processed.
 void onRead(IOEvent ioEvent)
          This method is called when an non blocking OP_READ is ready to get processed.
 void onWrite(IOEvent ioEvent)
          This method is called when an non blocking OP_WRITE is ready to get processed.
 Controller.Protocol protocol()
          A token decribing the protocol supported by an implementation of this interface
 long read(ByteBuffer byteBuffer, boolean blocking)
          Read bytes.
 void readFromAsyncQueue(ByteBuffer buffer, AsyncReadCallbackHandler callbackHandler)
          Method reads data to the ByteBuffer using async read queue.
 void readFromAsyncQueue(ByteBuffer buffer, AsyncReadCallbackHandler callbackHandler, AsyncReadCondition condition)
          Method reads data to the ByteBuffer using async read queue.
 void readFromAsyncQueue(ByteBuffer buffer, AsyncReadCallbackHandler callbackHandler, AsyncReadCondition condition, AsyncQueueDataProcessor readPostProcessor)
          Method reads data to the ByteBuffer using async read queue.
 void setCallbackHandler(SSLCallbackHandler callbackHandler)
          Sets ConnectorHandler's callback handler instance, which is used to process occuring events
 void setController(Controller controller)
          Set the Controller associated with this instance.
 void setDelegateSSLTasks(boolean delegateSSLTasks)
           
 void setSSLContext(SSLContext sslContext)
          Set SSLContext.
 void setSSLEngine(SSLEngine sslEngine)
          Set SSLEngine
 long write(ByteBuffer byteBuffer, boolean blocking)
          Writes bytes.
 void writeToAsyncQueue(ByteBuffer buffer)
          Method writes ByteBuffer using async write queue.
 void writeToAsyncQueue(ByteBuffer buffer, AsyncWriteCallbackHandler callbackHandler)
          Method writes ByteBuffer using async write queue.
 void writeToAsyncQueue(ByteBuffer buffer, AsyncWriteCallbackHandler callbackHandler, AsyncQueueDataProcessor writePreProcessor)
          Method writes ByteBuffer using async write queue.
 void writeToAsyncQueue(ByteBuffer buffer, AsyncWriteCallbackHandler callbackHandler, AsyncQueueDataProcessor writePreProcessor, boolean isCloneByteBuffer)
          Method writes ByteBuffer using async write queue.
 void writeToAsyncQueue(SocketAddress dstAddress, ByteBuffer buffer)
          Method sends ByteBuffer using async write queue.
 void writeToAsyncQueue(SocketAddress dstAddress, ByteBuffer buffer, AsyncWriteCallbackHandler callbackHandler)
          Method sends ByteBuffer using async write queue.
 void writeToAsyncQueue(SocketAddress dstAddress, ByteBuffer buffer, AsyncWriteCallbackHandler callbackHandler, AsyncQueueDataProcessor writePreProcessor)
          Method sends ByteBuffer using async write queue.
 void writeToAsyncQueue(SocketAddress dstAddress, ByteBuffer buffer, AsyncWriteCallbackHandler callbackHandler, AsyncQueueDataProcessor writePreProcessor, boolean isCloneByteBuffer)
          Method sends ByteBuffer using async write queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SSLConnectorHandler

public SSLConnectorHandler()

SSLConnectorHandler

public SSLConnectorHandler(SSLConfig sslConfig)

SSLConnectorHandler

public SSLConnectorHandler(SSLContext sslContext)
Method Detail

getDelegateSSLTasks

public boolean getDelegateSSLTasks()

setDelegateSSLTasks

public void setDelegateSSLTasks(boolean delegateSSLTasks)

connect

public void connect(SocketAddress remoteAddress,
                    SSLCallbackHandler callbackHandler)
             throws IOException
Connect to hostname:port. When an aysnchronous event happens (e.g OP_READ or OP_WRITE), the Controller will invoke the CallBackHandler.

Specified by:
connect in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Parameters:
remoteAddress - remote address to connect
callbackHandler - the handler invoked by the Controller when an non blocking operation is ready to be handled.
Throws:
IOException

connect

public void connect(SocketAddress remoteAddress,
                    SocketAddress localAddress,
                    SSLCallbackHandler callbackHandler)
             throws IOException
Connect to hostname:port. When an aysnchronous event happens (e.g OP_READ or OP_WRITE), the Controller will invoke the CallBackHandler.

Specified by:
connect in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Parameters:
remoteAddress - remote address to connect
localAddress - local address to bind
callbackHandler - the handler invoked by the Controller when an non blocking operation is ready to be handled.
Throws:
IOException

connect

public void connect(SocketAddress remoteAddress,
                    SSLCallbackHandler callbackHandler,
                    SSLSelectorHandler selectorHandler)
             throws IOException
Connect to hostname:port. When an aysnchronous event happens (e.g OP_READ or OP_WRITE), the Controller will invoke the CallBackHandler.

Specified by:
connect in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Parameters:
remoteAddress - remote address to connect
callbackHandler - the handler invoked by the Controller when an non blocking operation is ready to be handled.
selectorHandler - an instance of SelectorHandler.
Throws:
IOException

connect

public void connect(SocketAddress remoteAddress,
                    SocketAddress localAddress,
                    SSLCallbackHandler callbackHandler,
                    SSLSelectorHandler selectorHandler)
             throws IOException
Connect to hostname:port. When an aysnchronous event happens (e.g OP_READ or OP_WRITE), the Controller will invoke the CallBackHandler.

Specified by:
connect in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Parameters:
remoteAddress - remote address to connect
localAddress - local address to bin
callbackHandler - the handler invoked by the Controller when an non blocking operation is ready to be handled.
selectorHandler - an instance of SelectorHandler.
Throws:
IOException

connect

public void connect(SocketAddress remoteAddress)
             throws IOException
Connect to hostname:port. Internally an instance of Controller and its default SelectorHandler will be created everytime this method is called. This method should be used only and only if no external Controller has been initialized.

Specified by:
connect in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Parameters:
remoteAddress - remote address to connect
Throws:
IOException

connect

public void connect(SocketAddress remoteAddress,
                    SocketAddress localAddress)
             throws IOException
Connect to hostname:port. Internally an instance of Controller and its default SelectorHandler will be created everytime this method is called. This method should be used only and only if no external Controller has been initialized.

Specified by:
connect in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Parameters:
remoteAddress - remote address to connect
localAddress - local address to bin
Throws:
IOException

handshake

public boolean handshake(ByteBuffer byteBuffer,
                         boolean blocking)
                  throws IOException
Initiate SSL handshake phase. Handshake is required to be done after connection established.

Parameters:
byteBuffer - Application ByteBuffer, where application data will be stored
blocking - true, if handshake should be done in blocking mode, for non-blocking false
Returns:
If blocking parameter is true - method should always return true if handshake is done, or throw IOException otherwise. For non-blocking mode method returns true if handshake is done, or false if handshake will be completed in non-blocking manner. If False returned - SSLConnectorHandler will call callbackHandler.onHandshake() to notify about finishing handshake phase.
Throws:
IOException - if some error occurs during processing I/O operations/

read

public long read(ByteBuffer byteBuffer,
                 boolean blocking)
          throws IOException
Read bytes. If blocking is set to true, a pool of temporary Selector will be used to read bytes.

Specified by:
read in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Parameters:
byteBuffer - The byteBuffer to store bytes.
blocking - true if a a pool of temporary Selector is required to handle a blocking read.
Returns:
number of bytes read from a channel. Be careful, because return value represents the length of encrypted data, which was read from a channel. Don't use return value to determine the availability of a decrypted data to process, but use byteBuffer.remaining().
Throws:
IOException

write

public long write(ByteBuffer byteBuffer,
                  boolean blocking)
           throws IOException
Writes bytes. If blocking is set to true, a pool of temporary Selector will be used to writes bytes.

Specified by:
write in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Parameters:
byteBuffer - The byteBuffer to write.
blocking - true if a a pool of temporary Selector is required to handle a blocking write.
Returns:
number of bytes written on a channel. Be careful, as non-crypted data is passed, but crypted data is written on channel. Don't use return value to determine the number of bytes from original buffer, which were written.
Throws:
IOException

writeToAsyncQueue

public void writeToAsyncQueue(ByteBuffer buffer)
                       throws IOException
Method writes ByteBuffer using async write queue. First, if write queue is empty - it tries to write ByteBuffer directly (without putting to the queue). If associated write queue is not empty or after direct writing ByteBuffer still has ready data to be written - ByteBuffer will be added to AsyncQueue. If an exception occurs, during direct writing - it will be propagated to the caller directly, otherwise it will be just logged by Grizzly framework.

Specified by:
writeToAsyncQueue in interface AsyncQueueWritable
Parameters:
buffer - ByteBuffer
Throws:
IOException

writeToAsyncQueue

public void writeToAsyncQueue(ByteBuffer buffer,
                              AsyncWriteCallbackHandler callbackHandler)
                       throws IOException
Method writes ByteBuffer using async write queue. First, if write queue is empty - it tries to write ByteBuffer directly (without putting to the queue). If associated write queue is not empty or after direct writing ByteBuffer still has ready data to be written - ByteBuffer will be added to AsyncQueue. If an exception occurs, during direct writing - it will be propagated to the caller directly, otherwise, if the ByteBuffer is added to a writing queue - exception notification will come via AsyncWriteCallbackHandler.onIOException()

Specified by:
writeToAsyncQueue in interface AsyncQueueWritable
Parameters:
buffer - ByteBuffer
callbackHandler - AsyncWriteCallbackHandler, which will get notified, when ByteBuffer will be completely written
Throws:
IOException

writeToAsyncQueue

public void writeToAsyncQueue(ByteBuffer buffer,
                              AsyncWriteCallbackHandler callbackHandler,
                              AsyncQueueDataProcessor writePreProcessor)
                       throws IOException
Method writes ByteBuffer using async write queue. First, if write queue is empty - it tries to write ByteBuffer directly (without putting to the queue). If associated write queue is not empty or after direct writing ByteBuffer still has ready data to be written - ByteBuffer will be added to AsyncQueue. If an exception occurs, during direct writing - it will be propagated to the caller directly, otherwise, if the ByteBuffer is added to a writing queue - exception notification will come via AsyncWriteCallbackHandler.onIOException() Before data will be written on SelectableChannel, first it will be passed for preprocessing to AsyncQueueDataProcessor, and then preprocessor result data (AsyncQueueDataProcessor.getResultByteBuffer()) will be written on the SelectableChannel.

Specified by:
writeToAsyncQueue in interface AsyncQueueWritable
Parameters:
buffer - ByteBuffer
callbackHandler - AsyncWriteCallbackHandler, which will get notified, when ByteBuffer will be completely written
writePreProcessor - AsyncQueueDataProcessor, which will perform data processing, before it will be written on SelectableChannel
Throws:
IOException

writeToAsyncQueue

public void writeToAsyncQueue(ByteBuffer buffer,
                              AsyncWriteCallbackHandler callbackHandler,
                              AsyncQueueDataProcessor writePreProcessor,
                              boolean isCloneByteBuffer)
                       throws IOException
Method writes ByteBuffer using async write queue. First, if write queue is empty - it tries to write ByteBuffer directly (without putting to the queue). If associated write queue is not empty or after direct writing ByteBuffer still has ready data to be written - ByteBuffer will be added to AsyncQueue. If an exception occurs, during direct writing - it will be propagated to the caller directly, otherwise, if the ByteBuffer is added to a writing queue - exception notification will come via AsyncWriteCallbackHandler.onIOException() Before data will be written on SelectableChannel, first it will be passed for preprocessing to AsyncQueueDataProcessor, and then preprocessor result data (AsyncQueueDataProcessor.getResultByteBuffer()) will be written on the SelectableChannel.

Specified by:
writeToAsyncQueue in interface AsyncQueueWritable
Parameters:
buffer - ByteBuffer
callbackHandler - AsyncWriteCallbackHandler, which will get notified, when ByteBuffer will be completely written
writePreProcessor - AsyncQueueDataProcessor, which will perform data processing, before it will be written on SelectableChannel
isCloneByteBuffer - if true - AsyncQueueWriter will clone given ByteBuffer before puting it to the AsyncQueue
Throws:
IOException

writeToAsyncQueue

public void writeToAsyncQueue(SocketAddress dstAddress,
                              ByteBuffer buffer)
                       throws IOException
Method sends ByteBuffer using async write queue. First, if write queue is empty - it tries to send ByteBuffer to the given SocketAddress directly (without putting to the queue). If associated write queue is not empty or after direct sending ByteBuffer still has ready data to be written - ByteBuffer will be added to AsyncQueue. If an exception occurs, during direct writing - it will be propagated to the caller directly, otherwise it will be just logged by Grizzly framework.

Specified by:
writeToAsyncQueue in interface AsyncQueueWritable
Parameters:
dstAddress - destination SocketAddress data will be sent to
buffer - ByteBuffer
Throws:
IOException

writeToAsyncQueue

public void writeToAsyncQueue(SocketAddress dstAddress,
                              ByteBuffer buffer,
                              AsyncWriteCallbackHandler callbackHandler)
                       throws IOException
Method sends ByteBuffer using async write queue. First, if write queue is empty - it tries to send ByteBuffer to the given SocketAddress directly (without putting to the queue). If associated write queue is not empty or after direct sending ByteBuffer still has ready data to be written - ByteBuffer will be added to AsyncQueue. If an exception occurs, during direct writing - it will be propagated to the caller directly, otherwise, if the ByteBuffer is added to a writing queue - exception notification will come via AsyncWriteCallbackHandler.onIOException()

Specified by:
writeToAsyncQueue in interface AsyncQueueWritable
Parameters:
dstAddress - destination SocketAddress data will be sent to
buffer - ByteBuffer
callbackHandler - AsyncWriteCallbackHandler, which will get notified, when ByteBuffer will be completely written
Throws:
IOException

writeToAsyncQueue

public void writeToAsyncQueue(SocketAddress dstAddress,
                              ByteBuffer buffer,
                              AsyncWriteCallbackHandler callbackHandler,
                              AsyncQueueDataProcessor writePreProcessor)
                       throws IOException
Method sends ByteBuffer using async write queue. First, if write queue is empty - it tries to send ByteBuffer to the given SocketAddress directly (without putting to the queue). If associated write queue is not empty or after direct sending ByteBuffer still has ready data to be written - ByteBuffer will be added to AsyncQueue. If an exception occurs, during direct writing - it will be propagated to the caller directly, otherwise, if the ByteBuffer is added to a writing queue - exception notification will come via AsyncWriteCallbackHandler.onIOException() Before data will be written on SelectableChannel, first it will be passed for preprocessing to AsyncQueueDataProcessor, and then preprocessor result data (AsyncQueueDataProcessor.getResultByteBuffer()) will be written on the SelectableChannel.

Specified by:
writeToAsyncQueue in interface AsyncQueueWritable
Parameters:
dstAddress - destination SocketAddress data will be sent to
buffer - ByteBuffer
callbackHandler - AsyncWriteCallbackHandler, which will get notified, when ByteBuffer will be completely written
writePreProcessor - AsyncQueueDataProcessor, which will perform data processing, before it will be written on SelectableChannel
Throws:
IOException

writeToAsyncQueue

public void writeToAsyncQueue(SocketAddress dstAddress,
                              ByteBuffer buffer,
                              AsyncWriteCallbackHandler callbackHandler,
                              AsyncQueueDataProcessor writePreProcessor,
                              boolean isCloneByteBuffer)
                       throws IOException
Method sends ByteBuffer using async write queue. First, if write queue is empty - it tries to send ByteBuffer to the given SocketAddress directly (without putting to the queue). If associated write queue is not empty or after direct sending ByteBuffer still has ready data to be written - ByteBuffer will be added to AsyncQueue. If an exception occurs, during direct writing - it will be propagated to the caller directly, otherwise, if the ByteBuffer is added to a writing queue - exception notification will come via AsyncWriteCallbackHandler.onIOException() Before data will be written on SelectableChannel, first it will be passed for preprocessing to AsyncQueueDataProcessor, and then preprocessor result data (AsyncQueueDataProcessor.getResultByteBuffer()) will be written on the SelectableChannel.

Specified by:
writeToAsyncQueue in interface AsyncQueueWritable
Parameters:
dstAddress - destination SocketAddress data will be sent to
buffer - ByteBuffer
callbackHandler - AsyncWriteCallbackHandler, which will get notified, when ByteBuffer will be completely written
writePreProcessor - AsyncQueueDataProcessor, which will perform data processing, before it will be written on SelectableChannel
isCloneByteBuffer - if true - AsyncQueueWriter will clone given ByteBuffer before puting it to the AsyncQueue
Throws:
IOException

readFromAsyncQueue

public void readFromAsyncQueue(ByteBuffer buffer,
                               AsyncReadCallbackHandler callbackHandler)
                        throws IOException
Method reads data to the ByteBuffer using async read queue. First, if read queue is empty - it tries to read to the ByteBuffer directly (without putting to the queue). If associated read queue is not empty or after direct reading ByteBuffer still has remaining place for next read - ByteBuffer will be added to AsyncQueue. If an exception occurs, during direct reading - it will be propagated to the caller directly, otherwise, if the ByteBuffer is added to a reading queue - exception notification will come via AsyncReadCallbackHandler.onIOException()

Specified by:
readFromAsyncQueue in interface AsyncQueueReadable
Parameters:
buffer - ByteBuffer
callbackHandler - AsyncReadCallbackHandler, which will get notified, when ByteBuffer will get full
Throws:
IOException

readFromAsyncQueue

public void readFromAsyncQueue(ByteBuffer buffer,
                               AsyncReadCallbackHandler callbackHandler,
                               AsyncReadCondition condition)
                        throws IOException
Method reads data to the ByteBuffer using async read queue. First, if read queue is empty - it tries to read to the ByteBuffer directly (without putting to the queue). If associated read queue is not empty or after direct reading ByteBuffer still has remaining place for next read - ByteBuffer will be added to AsyncQueue. If an exception occurs, during direct reading - it will be propagated to the caller directly, otherwise, if the ByteBuffer is added to a reading queue - exception notification will come via AsyncReadCallbackHandler.onIOException()

Specified by:
readFromAsyncQueue in interface AsyncQueueReadable
Parameters:
buffer - ByteBuffer
callbackHandler - AsyncReadCallbackHandler, which will get notified, when ByteBuffer will get full
condition - AsyncReadCondition, which will be called to check if read data is complete, and callbackHandler could be called
Throws:
IOException

readFromAsyncQueue

public void readFromAsyncQueue(ByteBuffer buffer,
                               AsyncReadCallbackHandler callbackHandler,
                               AsyncReadCondition condition,
                               AsyncQueueDataProcessor readPostProcessor)
                        throws IOException
Method reads data to the ByteBuffer using async read queue. First, if read queue is empty - it tries to read to the ByteBuffer directly (without putting to the queue). If associated read queue is not empty or after direct reading ByteBuffer still has remaining place for next read - ByteBuffer will be added to AsyncQueue. If an exception occurs, during direct reading - it will be propagated to the caller directly, otherwise, if the ByteBuffer is added to a reading queue - exception notification will come via AsyncReadCallbackHandler.onIOException()

Specified by:
readFromAsyncQueue in interface AsyncQueueReadable
Parameters:
buffer - ByteBuffer
callbackHandler - AsyncReadCallbackHandler, which will get notified, when ByteBuffer will get full
condition - AsyncReadCondition, which will be called to check if read data is complete, and callbackHandler could be called
readPostProcessor - post processor, to be called to process read data
Throws:
IOException

close

public void close()
           throws IOException
Close the underlying connection.

Specified by:
close in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Specified by:
close in interface Closeable
Throws:
IOException

finishConnect

public void finishConnect(SelectionKey key)
                   throws IOException
Finish handling the OP_CONNECT interest ops.

Specified by:
finishConnect in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Parameters:
key - - a SelectionKey
Throws:
IOException

finishHandshake

public void finishHandshake()
Changes SSLConnectorHandler state, after handshake operation is done. Normally should not be called by outside Grizzly, just in case when custom handshake code was used.


protocol

public Controller.Protocol protocol()
A token decribing the protocol supported by an implementation of this interface

Specified by:
protocol in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Returns:
this ConnectorHandler's protocol

isConnected

public boolean isConnected()
Is the underlying SocketChannel connected.

Returns:
true if connected, otherwise false

isHandshakeDone

public boolean isHandshakeDone()
Is the underlying SocketChannel connected.

Returns:
true if connected, otherwise false

getController

public Controller getController()
Description copied from interface: ConnectorHandler
Return the Controller

Specified by:
getController in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Returns:

setController

public void setController(Controller controller)
Description copied from interface: ConnectorHandler
Set the Controller associated with this instance.

Specified by:
setController in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Parameters:
controller - Controller

getSSLContext

public SSLContext getSSLContext()
Get SSLConnector's SSLContext


setSSLContext

public void setSSLContext(SSLContext sslContext)
Set SSLContext. Use this method to change SSLConnectorHandler configuration. New configuration will become active only after SSLConnector will be closed and connected again.


configure

public void configure(SSLConfig sslConfig)
Configure SSLConnectorHandler's SSL settings. Use this method to change SSLConnectorHandler configuration. New configuration will become active only after SSLConnector will be closed and connected again.


getSSLEngine

public SSLEngine getSSLEngine()
Returns SSLConnector's SSLEngine

Returns:
SSLEngine

setSSLEngine

public void setSSLEngine(SSLEngine sslEngine)
Set SSLEngine

Parameters:
sslEngine - SSLEngine

getSecuredInputBuffer

public ByteBuffer getSecuredInputBuffer()
Returns SSLConnectorHandler's secured input buffer, it uses for reading data from a socket channel.

Returns:
secured input ByteBuffer

getSecuredOutputBuffer

public ByteBuffer getSecuredOutputBuffer()
Returns SSLConnectorHandler's secured output buffer, it uses for writing data to a socket channel.

Returns:
secured output ByteBuffer

getUnderlyingChannel

public SelectableChannel getUnderlyingChannel()
Description copied from interface: ConnectorHandler
Method returns ConnectorHandler's underlying channel

Specified by:
getUnderlyingChannel in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Returns:
channel

getCallbackHandler

public SSLCallbackHandler getCallbackHandler()
Description copied from interface: ConnectorHandler
Returns ConnectorHandler's callback handler instance, which is used to process occuring events

Specified by:
getCallbackHandler in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Returns:
callback handler

setCallbackHandler

public void setCallbackHandler(SSLCallbackHandler callbackHandler)
Description copied from interface: ConnectorHandler
Sets ConnectorHandler's callback handler instance, which is used to process occuring events

Specified by:
setCallbackHandler in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Parameters:
callbackHandler - handler

getSelectorHandler

public SSLSelectorHandler getSelectorHandler()
Description copied from interface: ConnectorHandler
Method returns SelectorHandler, which manages this ConnectorHandler

Specified by:
getSelectorHandler in interface ConnectorHandler<SSLSelectorHandler,SSLCallbackHandler>
Returns:
SelectorHandler

getApplicationBufferSize

public int getApplicationBufferSize()
Gets the size of the largest application buffer that may occur when using this session. SSLEngine application data buffers must be large enough to hold the application data from any inbound network application data packet received. Typically, outbound application data buffers can be of any size. (javadoc is taken from SSLSession.getApplicationBufferSize())

Returns:
largets application buffer size, which may occur

onConnect

public void onConnect(IOEvent ioEvent)
Description copied from interface: CallbackHandler
This method is called when an non blocking OP_CONNECT is ready to get processed. This method must invoke ConnectorHandler.finishConnect() to complete the connection operations.

Specified by:
onConnect in interface CallbackHandler
Parameters:
ioEvent - an object containing information about the current non blocking connection.

onRead

public void onRead(IOEvent ioEvent)
Description copied from interface: CallbackHandler
This method is called when an non blocking OP_READ is ready to get processed.

Specified by:
onRead in interface CallbackHandler
Parameters:
ioEvent - an object containing information about the current non blocking connection.

onWrite

public void onWrite(IOEvent ioEvent)
Description copied from interface: CallbackHandler
This method is called when an non blocking OP_WRITE is ready to get processed.

Specified by:
onWrite in interface CallbackHandler
Parameters:
ioEvent - an object containing information about the current non blocking connection.


Copyright © 2010 SUN Microsystems. All Rights Reserved.