Spring Integration

org.springframework.integration.ip.tcp.connection
Class TcpNioSSLConnection

java.lang.Object
  extended by org.springframework.integration.ip.tcp.connection.AbstractTcpConnection
      extended by org.springframework.integration.ip.tcp.connection.TcpNioConnection
          extended by org.springframework.integration.ip.tcp.connection.TcpNioSSLConnection
All Implemented Interfaces:
java.lang.Runnable, TcpConnection

public class TcpNioSSLConnection
extends TcpNioConnection

Implementation of TcpConnection supporting SSL/TLS over NIO. Unlike TcpNetConnection, which uses Sockets, the JVM does not directly support SSL for SocketChannels, used by NIO. Instead, the SSLEngine is provided whereby the SSL encryption is performed by passing in a plain text buffer, and receiving an encrypted buffer to transmit over the network. Similarly, encrypted data read from the network is decrypted.

However, before this can be done, certain handshaking operations are required, involving the creation of data buffers which must be exchanged by the peers. A number of such transfers are required; once the handshake is finished, it is relatively simple to encrypt/decrypt the data.

Also, it may be deemed necessary to re-perform handshaking.

This class supports the management of handshaking as necessary, both from the initiating and receiving peers.

Since:
2.2
Author:
Gary Russell

Field Summary
 
Fields inherited from class org.springframework.integration.ip.tcp.connection.AbstractTcpConnection
logger
 
Constructor Summary
TcpNioSSLConnection(java.nio.channels.SocketChannel socketChannel, boolean server, boolean lookupHost, javax.net.ssl.SSLEngine sslEngine)
           
 
Method Summary
protected  org.springframework.integration.ip.tcp.connection.TcpNioConnection.ChannelOutputStream getChannelOutputStream()
           
protected  org.springframework.integration.ip.tcp.connection.TcpNioSSLConnection.SSLChannelOutputStream getSSLChannelOutputStream()
           
 void init()
          Initializes the SSLEngine and sets up the encryption/decryption buffers.
protected  void sendToPipe(java.nio.ByteBuffer networkBuffer)
          Overrides super class method to perform decryption and/or participate in handshaking.
 
Methods inherited from class org.springframework.integration.ip.tcp.connection.TcpNioConnection
allocate, close, getLastRead, getPayload, getPort, isOpen, isUsingDirectBuffers, readPacket, run, send, setLastRead, setPipeTimeout, setTaskExecutor, setUsingDirectBuffers
 
Methods inherited from class org.springframework.integration.ip.tcp.connection.AbstractTcpConnection
afterSend, closeConnection, getConnectionId, getDeserializer, getHostAddress, getHostName, getListener, getMapper, getSender, getSerializer, incrementAndGetConnectionSequence, isServer, isSingleUse, registerListener, registerSender, setDeserializer, setMapper, setSerializer, setSingleUse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TcpNioSSLConnection

public TcpNioSSLConnection(java.nio.channels.SocketChannel socketChannel,
                           boolean server,
                           boolean lookupHost,
                           javax.net.ssl.SSLEngine sslEngine)
                    throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

sendToPipe

protected void sendToPipe(java.nio.ByteBuffer networkBuffer)
                   throws java.io.IOException
Overrides super class method to perform decryption and/or participate in handshaking. Decrypted data is sent to the super class to be assembled into a Message. Data received from the network may constitute multiple SSL packets, and may end with a partial packet. In that case, the buffer is compacted, ready to receive the remainder of the packet.

Overrides:
sendToPipe in class TcpNioConnection
Throws:
java.io.IOException

init

public void init()
          throws java.io.IOException
Initializes the SSLEngine and sets up the encryption/decryption buffers.

Throws:
java.io.IOException

getChannelOutputStream

protected org.springframework.integration.ip.tcp.connection.TcpNioConnection.ChannelOutputStream getChannelOutputStream()
Overrides:
getChannelOutputStream in class TcpNioConnection

getSSLChannelOutputStream

protected org.springframework.integration.ip.tcp.connection.TcpNioSSLConnection.SSLChannelOutputStream getSSLChannelOutputStream()

Spring Integration