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

java.lang.Object
  extended by java.lang.Thread
      extended by com.sun.enterprise.web.connector.grizzly.SelectorThread
          extended by com.sun.enterprise.web.connector.grizzly.ssl.SSLSelectorThread
All Implemented Interfaces:
SecureSelector<SSLImplementation>, Runnable, MBeanRegistration
Direct Known Subclasses:
SSLSelectorReadThread

public class SSLSelectorThread
extends SelectorThread
implements SecureSelector<SSLImplementation>

SSL over NIO Selector implementation. Mainly, this class replace the clear text implementation by defining the SSL tasks counterpart: SSLReadTask, SSLProcessorTask and SSLByteBufferInputStream. The SSLPipeline is the default and must not be replace unless all its attribute properly implemented.

Author:
Jean-Francois Arcand

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  SSLContext sslContext
          The SSLContext associated with the SSL implementation we are running on.
 
Fields inherited from class com.sun.enterprise.web.connector.grizzly.SelectorThread
activeProcessorTasks, adapter, algorithmClass, algorithmClassName, asyncExecution, asyncHandler, bannedKeys, bufferResponse, compressableMimeTypes, compression, compressionMinSize, currentConnectionNumber, DEFAULT_ALGORITHM, defaultAlgorithmInstalled, defaultResponseType, disableUploadTimeout, displayConfiguration, domain, enableNioLogging, fileCacheFactory, forcedRequestType, globalRequestProcessor, globalRequestProcessorName, inet, initialized, isFileCacheEnabled, isLargeFileCacheEnabled, isMonitoringEnabled, isWaiting, keepAlivePipeline, keepAliveTimeoutInSeconds, linger, logger, maxCacheEntries, maxEntrySize, maxHttpHeaderSize, maxKeepAliveRequests, maxLargeFileCacheSize, maxPostSize, maxProcessorWorkerThreads, maxQueueSizeInBytes, maxReadWorkerThreads, maxSelectors, maxSmallFileCacheSize, minEntrySize, minProcessorQueueLength, minReadQueueLength, minSpareThreads, minWorkerThreads, mserver, multiSelectorsCount, noCompressionUserAgents, oname, oOBInline, pipelineClassName, pipelineStat, port, processorPipeline, processorTasks, processorWorkerThreadName, readPipeline, readTasks, readThreads, recycleTasks, requestBufferSize, restrictedUserAgents, rootFolder, running, secondsMaxAge, selector, selectorTimeout, SERVER_NAME, serverSocket, serverSocketChannel, serverTimeout, socketKeepAlive, socketReceiveBufferSize, socketSendBufferSize, socketTimeout, ssBackLog, tcpNoDelay, threadsIncrement, threadsTimeout, uploadTimeout, useByteBufferView, useDirectByteBuffer
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SSLSelectorThread()
           
 
Method Summary
 void disableMonitoring()
          Disable gathering of monitoring datas.
 void enableMonitoring()
          Enable gathering of monitoring datas.
 void enableSelectionKeys()
          Enable all registered interestOps.
protected  void expireIdleKeys()
          Cancel keep-alive connections.
 String[] getEnabledCipherSuites()
          Returns the list of cipher suites to be enabled when SSLEngine is initialized.
 String[] getEnabledProtocols()
          Returns the list of protocols to be enabled when SSLEngine is initialized.
 ReadTask getReadTask(SelectionKey key)
          Return a SSLReadTask from the pool.
 ServerSocketFactory getServerSocketFactory()
          Return the ServerSocketFactory used when a blocking IO is enabled.
 SSLContext getSSLContext()
          Return the SSLContext required to support SSL over NIO.
 SSLImplementation getSSLImplementation()
          Return the current SSLImplementation this Thread
protected  ReadTask handleRead(SelectionKey key)
          Handle OP_READ
protected  void initFileCacheFactory()
          Initialize the fileCacheFactory associated with this instance
protected  void initMultiSelectors()
          Initialize SSLSelectorReadThread used to process OP_READ operations.
 boolean isClientMode()
          Returns true if the SSlEngine is set to use client mode when handshaking.
 boolean isNeedClientAuth()
          Returns true if the SSLEngine will require client authentication.
 boolean isWantClientAuth()
          Returns true if the engine will request client authentication.
protected  Pipeline newPipeline(int maxThreads, int minThreads, String name, int port, int priority)
          Create a new Pipeline instance using the pipelineClassName value.
protected  ProcessorTask newProcessorTask(boolean initialize)
          Create SSLProcessorTask objects and configure it to be ready to proceed request.
protected  DefaultReadTask newReadTask()
          Return a new SSLReadTask instance
 void registerKey(SelectionKey key)
          Register a SelectionKey to this Selector running of this thread.
 void setClientMode(boolean clientMode)
          Configures the engine to use client (or server) mode when handshaking.
 void setEnabledCipherSuites(String[] enabledCipherSuites)
          Sets the list of cipher suites to be enabled when SSLEngine is initialized.
 void setEnabledProtocols(String[] enabledProtocols)
          Sets the list of protocols to be enabled when SSLEngine is initialized.
 void setNeedClientAuth(boolean needClientAuth)
          Configures the engine to require client authentication.
 void setServerSocketFactory(ServerSocketFactory factory)
          Set the ServerSocketFactory used when a blocking IO is enabled.
 void setSSLContext(SSLContext sslContext)
          Set the SSLContext required to support SSL over NIO.
 void setSSLImplementation(SSLImplementation sslImplementation)
          Set the Coyote SSLImplementation.
 void setWantClientAuth(boolean wantClientAuth)
          Configures the engine to request client authentication.
 
Methods inherited from class com.sun.enterprise.web.connector.grizzly.SelectorThread
addBannedSelectionKey, cancelKey, cancelThreadExecution, clearTasks, configureCompression, configureProcessorTask, configureReadThread, disablePipelineStats, doSelect, enableCometSupport, enablePipelineStats, enableRcmSupport, getActiveProcessorTasks, getAdapter, getAddress, getAlgorithmClass, getAlgorithmClassName, getAsyncHandler, getBufferResponse, getBufferSize, getClassLoader, getCompressableMimeTypes, getCompression, getCompressionMinSize, getCountThreadsIdleStats, getCountThreadsStats, getCurReadThread, getCurrentBusyProcessorThreads, getCurrentConnectionNumber, getCurrentThreadCountStats, getCurrentThreadsBusyStats, getDefaultResponseType, getDisableUploadTimeout, getDomain, getEnableAsyncExecution, getForcedRequestType, getGlobalRequestProcessor, getGlobalRequestProcessorName, getInet, getKaTimeout, getKeepAliveMbeanName, getKeepAlivePipeline, getKeepAliveStats, getKeepAliveTimeoutInSeconds, getKeysToEnable, getLargeFileCacheEnabled, getLinger, getLogger, getManagement, getMaxCacheEntries, getMaxEntrySize, getMaxHttpHeaderSize, getMaxKeepAliveRequests, getMaxLargeCacheSize, getMaxPostSize, getMaxProcessorWorkerThreads, getMaxQueueSizeInBytes, getMaxReadWorkerThreads, getMaxSelectors, getMaxSmallCacheSize, getMaxSpareThreads, getMaxSpareThreadsStats, getMaxThreads, getMaxThreadsStats, getMinEntrySize, getMinProcessorQueueLength, getMinReadQueueLength, getMinSpareThreads, getMinSpareThreadsStats, getMinWorkerThreads, getMserver, getNextKeysExpiration, getNoCompressionUserAgents, getObjectName, getOname, getPipelineClassName, getPipelineStat, getPort, getPortLowLevel, getProcessorPipeline, getProcessorTask, getProcessorTasks, getProcessorWorkerThreadName, getPwcConnectionQueueMbeanName, getPwcFileCacheMbeanName, getQueueSizeInBytes, getReadPipeline, getReadTasks, getRequestGroupInfo, getRestrictedUserAgents, getReuseAddress, getRootFolder, getSelector, getSelector, getSelectorReadThreadsCount, getSelectors, getSelectorTimeout, getServerSocket, getServerSocketChannel, getServerSoTimeout, getServerTimeout, getSocketReceiveBufferSize, getSocketSendBufferSize, getSocketTimeout, getSoLinger, getSoTimeout, getSpinRate, getSsBackLog, getTcpNoDelay, getThreadsIncrement, getThreadsTimeout, getTimeout, getTransactionTimeout, getWebAppRootPath, handleAccept, handleConnection, initAlgorithm, initEndpoint, initKeepAlivePipeline, initMonitoringLevel, initPipeline, initProcessorTask, initReadTask, isBufferResponse, isDisplayConfiguration, isEnableNioLogging, isFileCacheEnabled, isInitialized, isIsMonitoringEnabled, isMonitoringEnabled, isRecycleTasks, isRunning, isSocketKeepAlive, isTcpNoDelay, isUseByteBufferView, isUseDirectByteBuffer, logger, postDeregister, postRegister, preDeregister, preRegister, rampUpProcessorTask, reconfigureAsyncExecution, registerComponents, removeCacheEntry, resetSpinCounter, returnTask, run, setActiveProcessorTasks, setAdapter, setAddress, setAlgorithmClass, setAlgorithmClassName, setAsyncHandler, setBufferResponse, setBufferSize, setClassLoader, setCompressableMimeTypes, setCompression, setCompressionMinSize, setCurReadThread, setCurrentConnectionNumber, setDefaultResponseType, setDisableUploadTimeout, setDisplayConfiguration, setDomain, setEnableAsyncExecution, setEnableNioLogging, setFileCacheIsEnabled, setForcedRequestType, setGlobalRequestProcessor, setGlobalRequestProcessorName, setInet, setInitialized, setIsMonitoringEnabled, setIsWaiting, setKaTimeout, setKeepAliveMbeanName, setKeepAlivePipeline, setKeepAliveStats, setKeepAliveThreadCount, setKeepAliveTimeoutInSeconds, setKeysToEnable, setLargeFileCacheEnabled, setLinger, setLogger, setManagement, setMaxCacheEntries, setMaxEntrySize, setMaxHttpHeaderSize, setMaxKeepAliveRequests, setMaxLargeCacheSize, setMaxPostSize, setMaxProcessorWorkerThreads, setMaxQueueSizeInBytes, setMaxReadWorkerThreads, setMaxSelectors, setMaxSmallCacheSize, setMaxSpareThreads, setMaxThreads, setMinEntrySize, setMinProcessorQueueLength, setMinReadQueueLength, setMinSpareThreads, setMinThreads, setMinWorkerThreads, setMserver, setNextKeysExpiration, setNoCompressionUserAgents, setOname, setPipelineClassName, setPipelineStat, setPort, setProcessorPipeline, setProcessorTasks, setProcessorWorkerThreadName, setPwcConnectionQueueMbeanName, setPwcFileCacheMbeanName, setReadPipeline, setReadTasks, setRecycleTasks, setRestrictedUserAgents, setReuseAddress, setRootFolder, setRunning, setSecondsMaxAge, setSelector, setSelectorReadThreadsCount, setSelectorTimeout, setServerSocket, setServerSocketChannel, setServerSoTimeout, setServerTimeout, setSocketKeepAlive, setSocketOptions, setSocketReceiveBufferSize, setSocketSendBufferSize, setSocketTimeout, setSoLinger, setSoTimeout, setSsBackLog, setTcpNoDelay, setThreadsIncrement, setThreadsTimeout, setTransactionTimeout, setUploadTimeout, setUseByteBufferView, setUseDirectByteBuffer, setWebAppRootPath, startEndpoint, startListener, startPipelines, stopEndpoint, stopPipelines, unregisterComponents, wakeup
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sslContext

protected SSLContext sslContext
The SSLContext associated with the SSL implementation we are running on.

Constructor Detail

SSLSelectorThread

public SSLSelectorThread()
Method Detail

initMultiSelectors

protected void initMultiSelectors()
                           throws IOException,
                                  InstantiationException
Initialize SSLSelectorReadThread used to process OP_READ operations.

Overrides:
initMultiSelectors in class SelectorThread
Throws:
IOException
InstantiationException

enableSelectionKeys

public void enableSelectionKeys()
Enable all registered interestOps. Due a a NIO bug, all interestOps invocation needs to occurs on the same thread as the selector thread.

Overrides:
enableSelectionKeys in class SelectorThread

handleRead

protected ReadTask handleRead(SelectionKey key)
                       throws IOException
Handle OP_READ

Overrides:
handleRead in class SelectorThread
Throws:
IOException

expireIdleKeys

protected void expireIdleKeys()
Cancel keep-alive connections.

Overrides:
expireIdleKeys in class SelectorThread

registerKey

public void registerKey(SelectionKey key)
Register a SelectionKey to this Selector running of this thread.

Overrides:
registerKey in class SelectorThread

newPipeline

protected Pipeline newPipeline(int maxThreads,
                               int minThreads,
                               String name,
                               int port,
                               int priority)
Create a new Pipeline instance using the pipelineClassName value.

Overrides:
newPipeline in class SelectorThread

getReadTask

public ReadTask getReadTask(SelectionKey key)
                     throws IOException
Return a SSLReadTask from the pool. If the pool is empty, create a new instance. Make sure the SSLEngine is reused when the SelectionKey is part of a keep-alive transaction.

Overrides:
getReadTask in class SelectorThread
Throws:
IOException

newReadTask

protected DefaultReadTask newReadTask()
Return a new SSLReadTask instance

Overrides:
newReadTask in class SelectorThread

newProcessorTask

protected ProcessorTask newProcessorTask(boolean initialize)
Create SSLProcessorTask objects and configure it to be ready to proceed request.

Overrides:
newProcessorTask in class SelectorThread

setSSLContext

public void setSSLContext(SSLContext sslContext)
Set the SSLContext required to support SSL over NIO.


getSSLContext

public SSLContext getSSLContext()
Return the SSLContext required to support SSL over NIO.


setSSLImplementation

public void setSSLImplementation(SSLImplementation sslImplementation)
Set the Coyote SSLImplementation.

Specified by:
setSSLImplementation in interface SecureSelector<SSLImplementation>

getSSLImplementation

public SSLImplementation getSSLImplementation()
Return the current SSLImplementation this Thread


getEnabledCipherSuites

public String[] getEnabledCipherSuites()
Returns the list of cipher suites to be enabled when SSLEngine is initialized.

Specified by:
getEnabledCipherSuites in interface SecureSelector<SSLImplementation>
Returns:
null means 'use SSLEngine's default.'

setEnabledCipherSuites

public void setEnabledCipherSuites(String[] enabledCipherSuites)
Sets the list of cipher suites to be enabled when SSLEngine is initialized.

Specified by:
setEnabledCipherSuites in interface SecureSelector<SSLImplementation>
Parameters:
cipherSuites - null means 'use SSLEngine's default.'

getEnabledProtocols

public String[] getEnabledProtocols()
Returns the list of protocols to be enabled when SSLEngine is initialized.

Specified by:
getEnabledProtocols in interface SecureSelector<SSLImplementation>
Returns:
null means 'use SSLEngine's default.'

setEnabledProtocols

public void setEnabledProtocols(String[] enabledProtocols)
Sets the list of protocols to be enabled when SSLEngine is initialized.

Specified by:
setEnabledProtocols in interface SecureSelector<SSLImplementation>
Parameters:
protocols - null means 'use SSLEngine's default.'

isClientMode

public boolean isClientMode()
Returns true if the SSlEngine is set to use client mode when handshaking.

Specified by:
isClientMode in interface SecureSelector<SSLImplementation>

setClientMode

public void setClientMode(boolean clientMode)
Configures the engine to use client (or server) mode when handshaking.

Specified by:
setClientMode in interface SecureSelector<SSLImplementation>

isNeedClientAuth

public boolean isNeedClientAuth()
Returns true if the SSLEngine will require client authentication.

Specified by:
isNeedClientAuth in interface SecureSelector<SSLImplementation>

setNeedClientAuth

public void setNeedClientAuth(boolean needClientAuth)
Configures the engine to require client authentication.

Specified by:
setNeedClientAuth in interface SecureSelector<SSLImplementation>

isWantClientAuth

public boolean isWantClientAuth()
Returns true if the engine will request client authentication.

Specified by:
isWantClientAuth in interface SecureSelector<SSLImplementation>

setWantClientAuth

public void setWantClientAuth(boolean wantClientAuth)
Configures the engine to request client authentication.

Specified by:
setWantClientAuth in interface SecureSelector<SSLImplementation>

initFileCacheFactory

protected void initFileCacheFactory()
Initialize the fileCacheFactory associated with this instance

Overrides:
initFileCacheFactory in class SelectorThread

getServerSocketFactory

public ServerSocketFactory getServerSocketFactory()
Return the ServerSocketFactory used when a blocking IO is enabled.

Specified by:
getServerSocketFactory in interface SecureSelector<SSLImplementation>

setServerSocketFactory

public void setServerSocketFactory(ServerSocketFactory factory)
Set the ServerSocketFactory used when a blocking IO is enabled.

Specified by:
setServerSocketFactory in interface SecureSelector<SSLImplementation>

enableMonitoring

public void enableMonitoring()
Enable gathering of monitoring datas.

Overrides:
enableMonitoring in class SelectorThread

disableMonitoring

public void disableMonitoring()
Disable gathering of monitoring datas.

Overrides:
disableMonitoring in class SelectorThread


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