com.sun.enterprise.web.connector.grizzly.ssl
Class SSLReadTask

java.lang.Object
  extended by com.sun.enterprise.web.connector.grizzly.TaskBase
      extended by com.sun.enterprise.web.connector.grizzly.DefaultReadTask
          extended by com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask
All Implemented Interfaces:
ReadTask, Task, TaskListener, Runnable, Callable
Direct Known Subclasses:
SSLAsyncReadTask

public class SSLReadTask
extends DefaultReadTask

SSL support over NIO. This Task handles the SSL requests using a non blocking socket. The SSL handshake is done using this class. Once the handshake is successful, the SSLProcessorTask is executed.

Author:
Jean-Francois Arcand

Field Summary
protected  int appBBSize
          Decrypted ByteBuffer default size.
protected  boolean handshake
          Is the handshake completed.
protected  ByteBuffer inputBB
          The encrypted input ByteBuffer.
protected  int inputBBSize
          Encrypted ByteBuffer default size.
protected  ByteBuffer outputBB
          The encrupted output ByteBuffer
protected  SSLEngine sslEngine
          The SSLEngine required to encrypt/decrypt SSL request bytes.
protected  SSLImplementation sslImplementation
          The Coyote SSLImplementation used to retrive the SSLContext
 
Fields inherited from class com.sun.enterprise.web.connector.grizzly.DefaultReadTask
algorithm, byteBuffer, bytesAvailable, inputStream, maxPostSize, processorTask, taskContext, taskEvent, useByteBufferView, useDirectByteBuffer
 
Fields inherited from class com.sun.enterprise.web.connector.grizzly.TaskBase
key, listeners, pipeline, recycle, selectorThread, type
 
Fields inherited from interface com.sun.enterprise.web.connector.grizzly.Task
ACCEPT_TASK, PROCESSOR_TASK, READ_TASK
 
Constructor Summary
SSLReadTask()
           
 
Method Summary
 void allocateBuffers()
          Allocate themandatory ByteBuffers.
protected  void configureProcessorTask()
          Configure the SSLProcessorTask.
 void detachProcessor()
          Return the ProcessorTask to the pool.
protected  boolean doHandshake(int timeout)
          Execute a non blocking SSL handshake.
protected  Object[] doPeerCertificateChain(boolean needClientAuth)
          Get the peer certificate list by enatiating a new handshake.
 void doTask()
          Perform an SSL handshake using an SSLEngine.
 boolean getHandshake()
          Return the handshake status.
 ByteBuffer getInputBB()
          Return the encrypted ByteBuffer used to handle request.
 ByteBuffer getOutputBB()
           
 SSLEngine getSSLEngine()
          Return the SSLEngine used by this instance.
 void initialize(StreamAlgorithm algorithm, boolean useDirectByteBuffer, boolean useByteBufferView)
          Initialize this object.
protected  boolean process()
          Process the request using the decrypted ByteBuffer.
 void recycle()
          Recycle this object so it can be re-used.
 void registerKey()
          Register the SelectionKey with the Selector.
 void setHandshake(boolean handshake)
          Set true if the handshake already occured.
 void setInputBB(ByteBuffer inputBB)
          Set the encrypted ByteBuffer used to handle request.
 void setOutputBB(ByteBuffer outputBB)
           
 void setSSLEngine(SSLEngine sslEngine)
          Set the SSLEngine.
 void setSSLImplementation(SSLImplementation sslImplementation)
          Set the Coyote SSLImplemenation
 
Methods inherited from class com.sun.enterprise.web.connector.grizzly.DefaultReadTask
attachProcessor, doTask, executeProcessorTask, finishConnection, getByteBuffer, getIdleTime, getProcessorTask, manageKeepAlive, returnTask, setByteBuffer, setBytesAvailable, setIdleTime, taskEvent, terminate
 
Methods inherited from class com.sun.enterprise.web.connector.grizzly.TaskBase
addTaskListener, call, cancelTask, clearTaskListeners, execute, fireTaskEvent, getKeepAliveStats, getPipeline, getRecycle, getRequestGroupInfo, getSelectionKey, getSelectorThread, getSocket, getTaskListeners, getType, isMonitoringEnabled, removeTaskListener, run, setPipeline, setRecycle, setSelectionKey, setSelectorThread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.enterprise.web.connector.grizzly.Task
addTaskListener, cancelTask, clearTaskListeners, execute, getKeepAliveStats, getPipeline, getRecycle, getRequestGroupInfo, getSelectionKey, getSelectorThread, getTaskListeners, getType, isMonitoringEnabled, removeTaskListener, setPipeline, setRecycle, setSelectionKey, setSelectorThread
 
Methods inherited from interface java.lang.Runnable
run
 
Methods inherited from interface java.util.concurrent.Callable
call
 

Field Detail

sslEngine

protected SSLEngine sslEngine
The SSLEngine required to encrypt/decrypt SSL request bytes.


appBBSize

protected int appBBSize
Decrypted ByteBuffer default size.


inputBBSize

protected int inputBBSize
Encrypted ByteBuffer default size.


inputBB

protected ByteBuffer inputBB
The encrypted input ByteBuffer.


outputBB

protected ByteBuffer outputBB
The encrupted output ByteBuffer


handshake

protected boolean handshake
Is the handshake completed.


sslImplementation

protected SSLImplementation sslImplementation
The Coyote SSLImplementation used to retrive the SSLContext

Constructor Detail

SSLReadTask

public SSLReadTask()
Method Detail

initialize

public void initialize(StreamAlgorithm algorithm,
                       boolean useDirectByteBuffer,
                       boolean useByteBufferView)
Initialize this object.

Specified by:
initialize in interface ReadTask
Overrides:
initialize in class DefaultReadTask

allocateBuffers

public void allocateBuffers()
Allocate themandatory ByteBuffers. Since the ByteBuffer are maintaned on the SSLWorkerThread lazily, this method makes sure the ByteBuffers are properly allocated and configured.


registerKey

public void registerKey()
Register the SelectionKey with the Selector. The SSLEngine is attached because it is impossible to keep-alive an ssl connection without re-using the same SSLEngine.

Overrides:
registerKey in class DefaultReadTask

doTask

public void doTask()
            throws IOException
Perform an SSL handshake using an SSLEngine. If the handshake is successfull, process the connection.

Specified by:
doTask in interface Task
Overrides:
doTask in class DefaultReadTask
Throws:
IOException

doHandshake

protected boolean doHandshake(int timeout)
                       throws IOException
Execute a non blocking SSL handshake.

Throws:
IOException

doPeerCertificateChain

protected Object[] doPeerCertificateChain(boolean needClientAuth)
                                   throws IOException
Get the peer certificate list by enatiating a new handshake.

Returns:
Object[] An array of X509Certificate.
Throws:
IOException

configureProcessorTask

protected void configureProcessorTask()
Configure the SSLProcessorTask.

Overrides:
configureProcessorTask in class DefaultReadTask

detachProcessor

public void detachProcessor()
Return the ProcessorTask to the pool.

Specified by:
detachProcessor in interface ReadTask
Overrides:
detachProcessor in class DefaultReadTask

process

protected boolean process()
                   throws IOException
Process the request using the decrypted ByteBuffer. The SSLProcessorTask

Throws:
IOException

recycle

public void recycle()
Recycle this object so it can be re-used. Make sure all ByteBuffers are properly recycled.

Specified by:
recycle in interface Task
Overrides:
recycle in class DefaultReadTask

setSSLImplementation

public void setSSLImplementation(SSLImplementation sslImplementation)
Set the Coyote SSLImplemenation


setHandshake

public void setHandshake(boolean handshake)
Set true if the handshake already occured.


getHandshake

public boolean getHandshake()
Return the handshake status.


setSSLEngine

public void setSSLEngine(SSLEngine sslEngine)
Set the SSLEngine.


getSSLEngine

public SSLEngine getSSLEngine()
Return the SSLEngine used by this instance.


getInputBB

public ByteBuffer getInputBB()
Return the encrypted ByteBuffer used to handle request.


setInputBB

public void setInputBB(ByteBuffer inputBB)
Set the encrypted ByteBuffer used to handle request.


getOutputBB

public ByteBuffer getOutputBB()

setOutputBB

public void setOutputBB(ByteBuffer outputBB)


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.