net.officefloor.plugin.socket.server.ssl.protocol
Class SslCommunicationProtocol<CH extends ConnectionHandler>

java.lang.Object
  extended by net.officefloor.plugin.socket.server.ssl.protocol.SslCommunicationProtocol<CH>
All Implemented Interfaces:
CommunicationProtocol<SslConnectionHandler<CH>>, Server<SslConnectionHandler<CH>>, ServerSocketHandler<SslConnectionHandler<CH>>, SslEngineConfigurator, SslTaskExecutor

public class SslCommunicationProtocol<CH extends ConnectionHandler>
extends Object
implements CommunicationProtocol<SslConnectionHandler<CH>>, ServerSocketHandler<SslConnectionHandler<CH>>, Server<SslConnectionHandler<CH>>, SslTaskExecutor, SslEngineConfigurator

SSL CommunicationProtocol that wraps another CommunicationProtocol.

Author:
Daniel Sagenschneider

Field Summary
static String PROPERTY_SSL_ENGINE_CONFIGURATOR
          Property to obtain the optional SslEngineConfigurator to configure the SSLEngine instances for use.
static String PROPERTY_SSL_PROTOCOL
          Property to specify the SSL protocol to use.
static String PROPERTY_SSL_PROVIDER
          Property to specify the SSL provider to use.
 
Constructor Summary
SslCommunicationProtocol(CommunicationProtocol<CH> wrappedCommunicationProtocol)
          Initiate.
 
Method Summary
 void beginTask(Runnable task)
           Begins executing the SSL task.
 void configureSslEngine(SSLEngine engine)
           Configures the SSLEngine.
 SslConnectionHandler<CH> createConnectionHandler(Connection connection)
          Creates a ConnectionHandler for a new Connection.
 Server<SslConnectionHandler<CH>> createServer()
          Creates the Server to handle requests.
 ServerSocketHandler<SslConnectionHandler<CH>> createServerSocketHandler(AbstractAsyncManagedObjectSource.MetaDataContext<None,Indexed> context, BufferSquirtFactory bufferSquirtFactory)
          Creates the ServerSocketHandler.
 void init(SSLContext context)
          Invoked to have this SslEngineConfigurator initialise itself.
 void loadSpecification(AbstractAsyncManagedObjectSource.SpecificationContext context)
          Loads any specifications for this communication protocol.
 void processRequest(SslConnectionHandler<CH> connectionHandler, Object attachment)
           Starts the processing the request identified by the ConnectionHandler with the Server.
 void setManagedObjectExecuteContext(ManagedObjectExecuteContext<Indexed> executeContext)
          Provides the Server the ManagedObjectExecuteContext to enable it to invoke ProcessState instances to process input.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_SSL_PROTOCOL

public static final String PROPERTY_SSL_PROTOCOL
Property to specify the SSL protocol to use.

See Also:
Constant Field Values

PROPERTY_SSL_PROVIDER

public static final String PROPERTY_SSL_PROVIDER
Property to specify the SSL provider to use.

See Also:
Constant Field Values

PROPERTY_SSL_ENGINE_CONFIGURATOR

public static final String PROPERTY_SSL_ENGINE_CONFIGURATOR
Property to obtain the optional SslEngineConfigurator to configure the SSLEngine instances for use.

See Also:
Constant Field Values
Constructor Detail

SslCommunicationProtocol

public SslCommunicationProtocol(CommunicationProtocol<CH> wrappedCommunicationProtocol)
Initiate.

Parameters:
wrappedCommunicationProtocol - CommunicationProtocol to be wrapped with this SSL CommunicationProtocol.
Method Detail

loadSpecification

public void loadSpecification(AbstractAsyncManagedObjectSource.SpecificationContext context)
Description copied from interface: CommunicationProtocol
Loads any specifications for this communication protocol.

Specified by:
loadSpecification in interface CommunicationProtocol<SslConnectionHandler<CH extends ConnectionHandler>>
Parameters:
context - AbstractAsyncManagedObjectSource.SpecificationContext.

createServerSocketHandler

public ServerSocketHandler<SslConnectionHandler<CH>> createServerSocketHandler(AbstractAsyncManagedObjectSource.MetaDataContext<None,Indexed> context,
                                                                               BufferSquirtFactory bufferSquirtFactory)
                                                                                                  throws Exception
Description copied from interface: CommunicationProtocol
Creates the ServerSocketHandler.

Specified by:
createServerSocketHandler in interface CommunicationProtocol<SslConnectionHandler<CH extends ConnectionHandler>>
Parameters:
context - AbstractAsyncManagedObjectSource.MetaDataContext.
bufferSquirtFactory - BufferSquirtFactory.
Throws:
Exception - If fails to create the ServerSocketHandler.

createServer

public Server<SslConnectionHandler<CH>> createServer()
Description copied from interface: ServerSocketHandler
Creates the Server to handle requests.

Specified by:
createServer in interface ServerSocketHandler<SslConnectionHandler<CH extends ConnectionHandler>>
Returns:
Server to handle requests.

createConnectionHandler

public SslConnectionHandler<CH> createConnectionHandler(Connection connection)
Description copied from interface: ServerSocketHandler
Creates a ConnectionHandler for a new Connection.

Specified by:
createConnectionHandler in interface ServerSocketHandler<SslConnectionHandler<CH extends ConnectionHandler>>
Parameters:
connection - A new Connection requiring handling.
Returns:
ConnectionHandler to handle the new Connection.

setManagedObjectExecuteContext

public void setManagedObjectExecuteContext(ManagedObjectExecuteContext<Indexed> executeContext)
Description copied from interface: Server
Provides the Server the ManagedObjectExecuteContext to enable it to invoke ProcessState instances to process input.

Specified by:
setManagedObjectExecuteContext in interface Server<SslConnectionHandler<CH extends ConnectionHandler>>
Parameters:
executeContext - ManagedObjectExecuteContext.

processRequest

public void processRequest(SslConnectionHandler<CH> connectionHandler,
                           Object attachment)
                    throws IOException
Description copied from interface: Server

Starts the processing the request identified by the ConnectionHandler with the Server.

To process a stream of input have the ConnectionHandler complete the Request with zero size and use the Connection passed to the ConnectionHandler.

Specified by:
processRequest in interface Server<SslConnectionHandler<CH extends ConnectionHandler>>
Parameters:
connectionHandler - ConnectionHandler for the Connection.
attachment - Optional attachment provided by the ConnectionHandler specific to this request. May be null.
Throws:
IOException - If fails to start processing the request.

beginTask

public void beginTask(Runnable task)
Description copied from interface: SslTaskExecutor

Begins executing the SSL task.

As this method likely passes the Runnable to another Thread this method will generally return before the Runnable is complete.

Specified by:
beginTask in interface SslTaskExecutor
Parameters:
task - Runnable SSL task to complete.

init

public void init(SSLContext context)
          throws Exception
Description copied from interface: SslEngineConfigurator
Invoked to have this SslEngineConfigurator initialise itself.

Specified by:
init in interface SslEngineConfigurator
Parameters:
context - SSLContext that will be used to create the SSLEngine instances.
Throws:
Exception - If fails to initialise (possibly because a protocol or cipher is not supported).

configureSslEngine

public void configureSslEngine(SSLEngine engine)
Description copied from interface: SslEngineConfigurator

Configures the SSLEngine.

It is anticipated that only a single instance will be create and therefore this method will be thread safe.

Specified by:
configureSslEngine in interface SslEngineConfigurator
Parameters:
engine - SSLEngine to configure.


Copyright © 2005-2011. All Rights Reserved.