Class SSLSocketConnection

java.lang.Object
com.sshtools.synergy.nio.SocketConnection
com.sshtools.synergy.nio.ssl.SSLSocketConnection
All Implemented Interfaces:
SelectionKeyAware, SelectorRegistrationListener, SocketHandler

public class SSLSocketConnection extends SocketConnection
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.
  • Constructor Details

    • SSLSocketConnection

      public SSLSocketConnection(SSLContext context)
      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:
      registrationCompleted in interface SelectorRegistrationListener
      Overrides:
      registrationCompleted in class SocketConnection
      Parameters:
      channel - SelectableChannel
      key - SelectionKey
      selectorThread - 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:
      isConnected in class SocketConnection
      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:
      processReadEvent in interface SocketHandler
      Overrides:
      processReadEvent in class SocketConnection
      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:
      processWriteEvent in interface SocketHandler
      Overrides:
      processWriteEvent in class SocketConnection
      Parameters:
      applicationData - ByteBuffer
      Returns:
      boolean
    • wantsWrite

      public boolean wantsWrite()
      Description copied from interface: SocketHandler
      Tell the selector that the handler wants to write.
      Specified by:
      wantsWrite in interface SocketHandler
      Overrides:
      wantsWrite in class SocketConnection
      Returns:
    • setEnabledProtocols

      public static void setEnabledProtocols(String[] aProtocols)
    • setEnabledCipherSuites

      public static void setEnabledCipherSuites(String[] aCipherSuites)