- java.lang.Object
-
- org.xnio.Connection
-
- org.xnio.StreamConnection
-
- org.xnio.ssl.SslConnection
-
- org.xnio.ssl.JsseSslStreamConnection
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.nio.channels.Channel
,java.nio.channels.InterruptibleChannel
,BoundChannel
,CloseableChannel
,CloseListenerSettable<StreamConnection>
,Configurable
,ConnectedChannel
,SslChannel
public final class JsseSslStreamConnection extends SslConnection
StreamConnection with SSL support.- Author:
- Flavia Rainone
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.xnio.channels.CloseListenerSettable
CloseListenerSettable.Setter<C extends java.nio.channels.Channel>
-
-
Field Summary
-
Fields inherited from class org.xnio.Connection
thread
-
Fields inherited from interface org.xnio.channels.Configurable
EMPTY
-
-
Constructor Summary
Constructors Constructor Description JsseSslStreamConnection(StreamConnection connection, javax.net.ssl.SSLEngine sslEngine, boolean startTls)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeAction()
The close action to perform on this connection.ChannelListener.Setter<? extends SslConnection>
getHandshakeSetter()
Get the setter which can be used to change the handshake listener for this channel.java.net.SocketAddress
getLocalAddress()
Get the local address that this channel is bound to.<T> T
getOption(Option<T> option)
Get the value of a channel option.java.net.SocketAddress
getPeerAddress()
Get the peer address of this channel.javax.net.ssl.SSLSession
getSslSession()
Get the currentSSLSession
for this channel.protected void
handleHandshakeFinished()
Callback method for notification of handshake finished.protected void
notifyReadClosed()
Indicate to conduit handlers that reads have been closed.protected void
notifyWriteClosed()
Indicate to conduit handlers that writes have been closed.protected boolean
readClosed()
Indicate that reads have been closed on this connection.<T> T
setOption(Option<T> option, T value)
Set an option for this channel.void
startHandshake()
Start or restart the SSL/TLS handshake.boolean
supportsOption(Option<?> option)
Determine whether an option is supported on this channel.protected boolean
writeClosed()
Indicate that writes have been closed on this connection.-
Methods inherited from class org.xnio.ssl.SslConnection
getCloseSetter
-
Methods inherited from class org.xnio.StreamConnection
getCloseListener, getSinkChannel, getSourceChannel, setCloseListener, setSinkConduit, setSourceConduit
-
Methods inherited from class org.xnio.Connection
close, getIoThread, getLocalAddress, getPeerAddress, getWorker, isOpen, isReadShutdown, isWriteShutdown
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.xnio.channels.BoundChannel
getLocalAddress
-
Methods inherited from interface org.xnio.channels.CloseableChannel
close, getIoThread, getWorker
-
Methods inherited from interface org.xnio.channels.ConnectedChannel
getPeerAddress
-
-
-
-
Constructor Detail
-
JsseSslStreamConnection
public JsseSslStreamConnection(StreamConnection connection, javax.net.ssl.SSLEngine sslEngine, boolean startTls)
-
-
Method Detail
-
startHandshake
public void startHandshake() throws java.io.IOException
Start or restart the SSL/TLS handshake. To force a complete SSL/TLS session renegotiation, the current session should be invalidated prior to calling this method. This method is not needed for the initial handshake unless theOptions.SSL_STARTTLS
option is set as sending or receiving over the channel will automatically initiate it. This method must not be called while a read or write operation is taking place.- Specified by:
startHandshake
in interfaceSslChannel
- Specified by:
startHandshake
in classSslConnection
- Throws:
java.io.IOException
- if an I/O error occurs
-
getPeerAddress
public java.net.SocketAddress getPeerAddress()
Get the peer address of this channel.- Returns:
- the peer address
-
getLocalAddress
public java.net.SocketAddress getLocalAddress()
Get the local address that this channel is bound to.- Returns:
- the local address
-
closeAction
protected void closeAction() throws java.io.IOException
The close action to perform on this connection.- Overrides:
closeAction
in classConnection
- Throws:
java.io.IOException
- if close fails
-
notifyWriteClosed
protected void notifyWriteClosed()
Indicate to conduit handlers that writes have been closed.- Specified by:
notifyWriteClosed
in classConnection
-
notifyReadClosed
protected void notifyReadClosed()
Indicate to conduit handlers that reads have been closed.- Specified by:
notifyReadClosed
in classConnection
-
setOption
public <T> T setOption(Option<T> option, T value) throws java.lang.IllegalArgumentException, java.io.IOException
Set an option for this channel. Unsupported options are ignored.- Specified by:
setOption
in interfaceConfigurable
- Overrides:
setOption
in classConnection
- Type Parameters:
T
- the type of the option value- Parameters:
option
- the option to setvalue
- the value of the option to set- Returns:
- the previous option value, if any
- Throws:
java.lang.IllegalArgumentException
- if the value is not acceptable for this optionjava.io.IOException
- if an I/O error occurred when modifying the option
-
getOption
public <T> T getOption(Option<T> option) throws java.io.IOException
Get the value of a channel option.- Specified by:
getOption
in interfaceConfigurable
- Overrides:
getOption
in classConnection
- Type Parameters:
T
- the type of the option value- Parameters:
option
- the option to get- Returns:
- the value of the option, or
null
if it is not set - Throws:
java.io.IOException
- if an I/O error occurred when reading the option
-
supportsOption
public boolean supportsOption(Option<?> option)
Determine whether an option is supported on this channel.- Specified by:
supportsOption
in interfaceConfigurable
- Overrides:
supportsOption
in classConnection
- Parameters:
option
- the option- Returns:
true
if it is supported
-
getSslSession
public javax.net.ssl.SSLSession getSslSession()
Get the currentSSLSession
for this channel.- Specified by:
getSslSession
in interfaceSslChannel
- Specified by:
getSslSession
in classSslConnection
- Returns:
- the current
SSLSession
-
getHandshakeSetter
public ChannelListener.Setter<? extends SslConnection> getHandshakeSetter()
Description copied from class:SslConnection
Get the setter which can be used to change the handshake listener for this channel.- Specified by:
getHandshakeSetter
in interfaceSslChannel
- Specified by:
getHandshakeSetter
in classSslConnection
- Returns:
- the setter
-
readClosed
protected boolean readClosed()
Description copied from class:Connection
Indicate that reads have been closed on this connection.- Overrides:
readClosed
in classConnection
- Returns:
true
if read closure was successfully indicated;false
if this method has already been called
-
writeClosed
protected boolean writeClosed()
Description copied from class:Connection
Indicate that writes have been closed on this connection.- Overrides:
writeClosed
in classConnection
- Returns:
true
if write closure was successfully indicated;false
if this method has already been called
-
handleHandshakeFinished
protected void handleHandshakeFinished()
Callback method for notification of handshake finished.
-
-