|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.netty.channel.SimpleChannelUpstreamHandler
org.jboss.netty.handler.codec.frame.FrameDecoder
org.jboss.netty.handler.ssl.SslHandler
public class SslHandler
Adds SSL
· TLS and StartTLS support to a Channel. Please refer
to the "SecureChat" example in the distribution or the web
site for the detailed usage.
You must make sure not to write a message while the
handshake is in progress unless you are
renegotiating. You will be notified by the ChannelFuture which is
returned by the handshake() method when the handshake
process succeeds or fails.
TLS renegotiation has been disabled by default due to a known security issue,
CVE-2009-3555.
You can re-enable renegotiation by calling setEnableRenegotiation(boolean)
with true at your own risk.
If enableRenegotiation is true and
the initial handshake has been done successfully, you can call
handshake() to trigger the renegotiation.
If enableRenegotiation is false,
an attempt to trigger renegotiation will result in the connection closure.
To close the SSL session, the close() method should be
called to send the close_notify message to the remote peer. One
exception is when you close the Channel - SslHandler
intercepts the close request and send the close_notify message
before the channel closure automatically. Once the SSL session is closed,
it is not reusable, and consequently you should create a new
SslHandler with a new SSLEngine as explained in the
following section.
To restart the SSL session, you must remove the existing closed
SslHandler from the ChannelPipeline, insert a new
SslHandler with a new SSLEngine into the pipeline,
and start the handshake process as described in the first section.
StartTLS is the communication pattern that secures the wire in the middle of the plaintext connection. Please note that it is different from SSL · TLS, that secures the wire from the beginning of the connection. Typically, StartTLS is composed of three steps:
SslHandler instance with startTls flag set
to true,SslHandler to the ChannelPipeline, andSslHandler before sending
the StartTLS response. Otherwise the client can send begin SSL handshake
before SslHandler is inserted to the ChannelPipeline, causing
data corruption.
The client-side implementation is much simpler.
SslHandler instance with startTls flag set
to false,SslHandler to the ChannelPipeline, andhandshake().
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler |
|---|
ChannelHandler.Sharable |
| Constructor Summary | |
|---|---|
SslHandler(javax.net.ssl.SSLEngine engine)
Creates a new instance. |
|
SslHandler(javax.net.ssl.SSLEngine engine,
boolean startTls)
Creates a new instance. |
|
SslHandler(javax.net.ssl.SSLEngine engine,
boolean startTls,
java.util.concurrent.Executor delegatedTaskExecutor)
Creates a new instance. |
|
SslHandler(javax.net.ssl.SSLEngine engine,
java.util.concurrent.Executor delegatedTaskExecutor)
Creates a new instance. |
|
SslHandler(javax.net.ssl.SSLEngine engine,
SslBufferPool bufferPool)
Creates a new instance. |
|
SslHandler(javax.net.ssl.SSLEngine engine,
SslBufferPool bufferPool,
boolean startTls)
Creates a new instance. |
|
SslHandler(javax.net.ssl.SSLEngine engine,
SslBufferPool bufferPool,
boolean startTls,
java.util.concurrent.Executor delegatedTaskExecutor)
Creates a new instance. |
|
SslHandler(javax.net.ssl.SSLEngine engine,
SslBufferPool bufferPool,
java.util.concurrent.Executor delegatedTaskExecutor)
Creates a new instance. |
|
| Method Summary | |
|---|---|
void |
afterAdd(ChannelHandlerContext ctx)
|
void |
afterRemove(ChannelHandlerContext ctx)
|
void |
beforeAdd(ChannelHandlerContext ctx)
|
void |
beforeRemove(ChannelHandlerContext ctx)
|
void |
channelDisconnected(ChannelHandlerContext ctx,
ChannelStateEvent e)
Invoked when a Channel was disconnected from its remote peer. |
ChannelFuture |
close()
Sends an SSL close_notify message to the specified channel and
destroys the underlying SSLEngine. |
ChannelFuture |
close(Channel channel)
Deprecated. Use close() instead. |
protected java.lang.Object |
decode(ChannelHandlerContext ctx,
Channel channel,
ChannelBuffer buffer)
Decodes the received packets so far into a frame. |
void |
exceptionCaught(ChannelHandlerContext ctx,
ExceptionEvent e)
Invoked when an exception was raised by an I/O thread or a ChannelHandler. |
static SslBufferPool |
getDefaultBufferPool()
Returns the default SslBufferPool used when no pool is
specified in the constructor. |
javax.net.ssl.SSLEngine |
getEngine()
Returns the SSLEngine which is used by this handler. |
void |
handleDownstream(ChannelHandlerContext context,
ChannelEvent evt)
Handles the specified downstream event. |
ChannelFuture |
handshake()
Starts an SSL / TLS handshake for the specified channel. |
ChannelFuture |
handshake(Channel channel)
Deprecated. Use handshake() instead. |
boolean |
isEnableRenegotiation()
Returns true if and only if TLS renegotiation is enabled. |
void |
setEnableRenegotiation(boolean enableRenegotiation)
Enables or disables TLS renegotiation. |
| Methods inherited from class org.jboss.netty.handler.codec.frame.FrameDecoder |
|---|
channelClosed, decodeLast, messageReceived |
| Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler |
|---|
channelBound, channelConnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SslHandler(javax.net.ssl.SSLEngine engine)
engine - the SSLEngine this handler will use
public SslHandler(javax.net.ssl.SSLEngine engine,
SslBufferPool bufferPool)
engine - the SSLEngine this handler will usebufferPool - the SslBufferPool where this handler will
acquire the buffers required by the SSLEngine
public SslHandler(javax.net.ssl.SSLEngine engine,
boolean startTls)
engine - the SSLEngine this handler will usestartTls - true if the first write request shouldn't be
encrypted by the SSLEngine
public SslHandler(javax.net.ssl.SSLEngine engine,
SslBufferPool bufferPool,
boolean startTls)
engine - the SSLEngine this handler will usebufferPool - the SslBufferPool where this handler will
acquire the buffers required by the SSLEnginestartTls - true if the first write request shouldn't be
encrypted by the SSLEngine
public SslHandler(javax.net.ssl.SSLEngine engine,
java.util.concurrent.Executor delegatedTaskExecutor)
engine - the SSLEngine this handler will usedelegatedTaskExecutor - the Executor which will execute the delegated task
that SSLEngine.getDelegatedTask() will return
public SslHandler(javax.net.ssl.SSLEngine engine,
SslBufferPool bufferPool,
java.util.concurrent.Executor delegatedTaskExecutor)
engine - the SSLEngine this handler will usebufferPool - the SslBufferPool where this handler will acquire
the buffers required by the SSLEnginedelegatedTaskExecutor - the Executor which will execute the delegated task
that SSLEngine.getDelegatedTask() will return
public SslHandler(javax.net.ssl.SSLEngine engine,
boolean startTls,
java.util.concurrent.Executor delegatedTaskExecutor)
engine - the SSLEngine this handler will usestartTls - true if the first write request shouldn't be encrypted
by the SSLEnginedelegatedTaskExecutor - the Executor which will execute the delegated task
that SSLEngine.getDelegatedTask() will return
public SslHandler(javax.net.ssl.SSLEngine engine,
SslBufferPool bufferPool,
boolean startTls,
java.util.concurrent.Executor delegatedTaskExecutor)
engine - the SSLEngine this handler will usebufferPool - the SslBufferPool where this handler will acquire
the buffers required by the SSLEnginestartTls - true if the first write request shouldn't be encrypted
by the SSLEnginedelegatedTaskExecutor - the Executor which will execute the delegated task
that SSLEngine.getDelegatedTask() will return| Method Detail |
|---|
public static SslBufferPool getDefaultBufferPool()
SslBufferPool used when no pool is
specified in the constructor.
public javax.net.ssl.SSLEngine getEngine()
SSLEngine which is used by this handler.
public ChannelFuture handshake()
ChannelFuture which is notified when the handshake
succeeds or fails.@Deprecated public ChannelFuture handshake(Channel channel)
handshake() instead.
public ChannelFuture close()
close_notify message to the specified channel and
destroys the underlying SSLEngine.
@Deprecated public ChannelFuture close(Channel channel)
close() instead.
public boolean isEnableRenegotiation()
true if and only if TLS renegotiation is enabled.
public void setEnableRenegotiation(boolean enableRenegotiation)
public void handleDownstream(ChannelHandlerContext context,
ChannelEvent evt)
throws java.lang.Exception
ChannelDownstreamHandler
handleDownstream in interface ChannelDownstreamHandlercontext - the context object for this handlerevt - the downstream event to process or intercept
java.lang.Exception
public void channelDisconnected(ChannelHandlerContext ctx,
ChannelStateEvent e)
throws java.lang.Exception
SimpleChannelUpstreamHandlerChannel was disconnected from its remote peer.
channelDisconnected in class FrameDecoderjava.lang.Exception
public void exceptionCaught(ChannelHandlerContext ctx,
ExceptionEvent e)
throws java.lang.Exception
SimpleChannelUpstreamHandlerChannelHandler.
exceptionCaught in class FrameDecoderjava.lang.Exception
protected java.lang.Object decode(ChannelHandlerContext ctx,
Channel channel,
ChannelBuffer buffer)
throws java.lang.Exception
FrameDecoder
decode in class FrameDecoderctx - the context of this handlerchannel - the current channelbuffer - the cumulative buffer of received packets so far.
Note that the buffer might be empty, which means you
should not make an assumption that the buffer contains
at least one byte in your decoder implementation.
null if there's not enough data in the buffer to decode a frame.
java.lang.Exception
public void beforeAdd(ChannelHandlerContext ctx)
throws java.lang.Exception
beforeAdd in interface LifeCycleAwareChannelHandlerjava.lang.Exception
public void afterAdd(ChannelHandlerContext ctx)
throws java.lang.Exception
afterAdd in interface LifeCycleAwareChannelHandlerjava.lang.Exception
public void beforeRemove(ChannelHandlerContext ctx)
throws java.lang.Exception
beforeRemove in interface LifeCycleAwareChannelHandlerjava.lang.Exception
public void afterRemove(ChannelHandlerContext ctx)
throws java.lang.Exception
afterRemove in interface LifeCycleAwareChannelHandlerjava.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||