Class TcpNioSSLConnection
java.lang.Object
org.springframework.integration.ip.tcp.connection.TcpConnectionSupport
org.springframework.integration.ip.tcp.connection.TcpNioConnection
org.springframework.integration.ip.tcp.connection.TcpNioSSLConnection
- All Implemented Interfaces:
- Runnable,- TcpConnection
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, Artem Bilan, Christian Tzolov
- 
Field SummaryFields inherited from class org.springframework.integration.ip.tcp.connection.TcpConnectionSupportlogger
- 
Constructor SummaryConstructorsConstructorDescriptionTcpNioSSLConnection(SocketChannel socketChannel, boolean server, boolean lookupHost, ApplicationEventPublisher applicationEventPublisher, String connectionFactoryName, SSLEngine sslEngine) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Close this connection.protected org.springframework.integration.ip.tcp.connection.TcpNioConnection.ChannelOutputStreamprotected org.springframework.integration.ip.tcp.connection.TcpNioSSLConnection.SSLChannelOutputStreamvoidinit()Initializes the SSLEngine and sets up the encryption/decryption buffers.protected voidsendToPipe(ByteBuffer networkBuffer) Overrides super class method to perform decryption and/or participate in handshaking.voidsetHandshakeTimeout(int handshakeTimeout) Set the timeout while waiting for handshake data (in seconds).Methods inherited from class org.springframework.integration.ip.tcp.connection.TcpNioConnectionallocate, getDeserializerStateKey, getLastRead, getLastSend, getPayload, getPort, inputStream, isOpen, isUsingDirectBuffers, readPacket, run, send, setLastRead, setPipeTimeout, setTaskExecutor, setUsingDirectBuffers, shutdownInput, shutdownOutputMethods inherited from class org.springframework.integration.ip.tcp.connection.TcpConnectionSupportcloseConnection, enableManualListenerRegistration, getConnectionFactoryName, getConnectionId, getDeserializer, getHostAddress, getHostName, getListener, getMapper, getSender, getSenders, getSerializer, getSocketInfo, incrementAndGetConnectionSequence, isNoReadErrorOnClose, isServer, publishConnectionCloseEvent, publishConnectionExceptionEvent, publishConnectionOpenEvent, publishEvent, registerListener, registerSender, registerSenders, registerTestListener, sendExceptionToListener, setDeserializer, setMapper, setNeedsTest, setNoReadErrorOnClose, setSerializer, setWrapped, setWrapper, toString
- 
Constructor Details- 
TcpNioSSLConnectionpublic TcpNioSSLConnection(SocketChannel socketChannel, boolean server, boolean lookupHost, @Nullable ApplicationEventPublisher applicationEventPublisher, @Nullable String connectionFactoryName, SSLEngine sslEngine) 
 
- 
- 
Method Details- 
setHandshakeTimeoutpublic void setHandshakeTimeout(int handshakeTimeout) Set the timeout while waiting for handshake data (in seconds). Default 30.- Parameters:
- handshakeTimeout- the timeout.
- Since:
- 4.3.6
 
- 
getSslSession- Specified by:
- getSslSessionin interface- TcpConnection
- Overrides:
- getSslSessionin class- TcpNioConnection
- Returns:
- the SSLSessionassociated with this connection, if SSL is in use, null otherwise.
 
- 
sendToPipeOverrides 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:
- sendToPipein class- TcpNioConnection
- Throws:
- IOException
 
- 
initpublic void init()Initializes the SSLEngine and sets up the encryption/decryption buffers.
- 
getChannelOutputStreamprotected org.springframework.integration.ip.tcp.connection.TcpNioConnection.ChannelOutputStream getChannelOutputStream()- Overrides:
- getChannelOutputStreamin class- TcpNioConnection
 
- 
getSSLChannelOutputStreamprotected org.springframework.integration.ip.tcp.connection.TcpNioSSLConnection.SSLChannelOutputStream getSSLChannelOutputStream()
- 
closepublic void close()Description copied from class:TcpConnectionSupportClose this connection.- Specified by:
- closein interface- TcpConnection
- Overrides:
- closein class- TcpNioConnection
 
 
-