Package com.sshtools.synergy.nio.ssl
Class SSLSocketConnection
java.lang.Object
com.sshtools.synergy.nio.SocketConnection
com.sshtools.synergy.nio.ssl.SSLSocketConnection
- All Implemented Interfaces:
SelectionKeyAware,SelectorRegistrationListener,SocketHandler
This class implements an SSL socket connection for the custom server.
Using the Java 1.5 SSLEngine class this implementation wraps all protocol
traffic into SSL records.
-
Field Summary
Fields inherited from class com.sshtools.synergy.nio.SocketConnection
closed, daemon, daemonContext, key, protocolEngine, selectorThread, socketChannel, socketDataIn, socketDataOut -
Constructor Summary
ConstructorsConstructorDescriptionSSLSocketConnection(SSLContext context) Default constructor.SSLSocketConnection(SSLContext context, boolean allowClientCertificate, boolean requireClientCertificate) -
Method Summary
Modifier and TypeMethodDescriptionbooleanIs the socket still connected? During the initial handshake check the raw socket status, otherwise check the protocol status.booleanThis method is called when new network data arrives on the socket.booleanWrite any application data to the socket by wrapping it up into the SSL protocol.voidregistrationCompleted(SelectableChannel channel, SelectionKey key, SelectorThread selectorThread) This method is called once the socket is registered with a SelectorThread.static voidsetEnabledCipherSuites(String[] aCipherSuites) static voidsetEnabledProtocols(String[] aProtocols) booleanTell the selector that the handler wants to write.Methods inherited from class com.sshtools.synergy.nio.SocketConnection
addTask, closeConnection, closeConnection, flagWrite, getConnection, getContext, getDaemonContext, getIdleStates, getInitialOps, getLocalAddress, getLocalPort, getName, getPort, getProtocolEngine, getRemoteAddress, getSelectorThread, getSocketChannel, getThread, initialize, isSelectorThread, setProtocolEngine, setSelectionKey, setThread, wantsRead
-
Constructor Details
-
SSLSocketConnection
Default constructor. We need one of these so we can dynamically create a SocketConnection on demand. -
SSLSocketConnection
public SSLSocketConnection(SSLContext context, boolean allowClientCertificate, boolean requireClientCertificate)
-
-
Method Details
-
registrationCompleted
public void registrationCompleted(SelectableChannel channel, SelectionKey key, SelectorThread selectorThread) This method is called once the socket is registered with a SelectorThread. At this point we're ready to start transfering data.- Specified by:
registrationCompletedin interfaceSelectorRegistrationListener- Overrides:
registrationCompletedin classSocketConnection- Parameters:
channel- SelectableChannelkey- SelectionKeyselectorThread- SelectorThread
-
isConnected
public boolean isConnected()Is the socket still connected? During the initial handshake check the raw socket status, otherwise check the protocol status.- Overrides:
isConnectedin classSocketConnection- Returns:
- boolean
-
processReadEvent
public boolean processReadEvent()This method is called when new network data arrives on the socket. We have to unwrap any SSL traffic into raw application data- Specified by:
processReadEventin interfaceSocketHandler- Overrides:
processReadEventin classSocketConnection- Parameters:
applicationData- ByteBuffer- Returns:
- boolean
-
processWriteEvent
public boolean processWriteEvent()Write any application data to the socket by wrapping it up into the SSL protocol.- Specified by:
processWriteEventin interfaceSocketHandler- Overrides:
processWriteEventin classSocketConnection- Parameters:
applicationData- ByteBuffer- Returns:
- boolean
-
wantsWrite
public boolean wantsWrite()Description copied from interface:SocketHandlerTell the selector that the handler wants to write.- Specified by:
wantsWritein interfaceSocketHandler- Overrides:
wantsWritein classSocketConnection- Returns:
-
setEnabledProtocols
-
setEnabledCipherSuites
-