public class OptionalSslHandler extends ByteToMessageDecoder
OptionalSslHandler
is a utility decoder to support both SSL and non-SSL handlers
based on the first message received.ByteToMessageDecoder.Cumulator
ChannelHandler.Sharable
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
Constructor and Description |
---|
OptionalSslHandler(SslContext sslContext) |
Modifier and Type | Method and Description |
---|---|
protected void |
decode(ChannelHandlerContext context,
ByteBuf in,
List<Object> out)
Decode the from one
ByteBuf to an other. |
protected ChannelHandler |
newNonSslHandler(ChannelHandlerContext context)
Override to configure the ChannelHandler.
|
protected String |
newNonSslHandlerName()
Optionally specify the non-SSL handler name, this method may return
null . |
protected SslHandler |
newSslHandler(ChannelHandlerContext context,
SslContext sslContext)
Override to configure the SslHandler eg.
|
protected String |
newSslHandlerName()
Optionally specify the SSL handler name, this method may return
null . |
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
ensureNotSharable, handlerAdded, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handlerAdded
public OptionalSslHandler(SslContext sslContext)
protected void decode(ChannelHandlerContext context, ByteBuf in, List<Object> out) throws Exception
ByteToMessageDecoder
ByteBuf
to an other. This method will be called till either the input
ByteBuf
has nothing to read when return from this method or till nothing was read from the input
ByteBuf
.decode
in class ByteToMessageDecoder
context
- the ChannelHandlerContext
which this ByteToMessageDecoder
belongs toin
- the ByteBuf
from which to read dataout
- the List
to which decoded messages should be addedException
- is thrown if an error occursprotected String newSslHandlerName()
null
.protected SslHandler newSslHandler(ChannelHandlerContext context, SslContext sslContext)
SSLParameters.setEndpointIdentificationAlgorithm(String)
.
The hostname and port is not known by this method so servers may want to override this method and use the
SslContext.newHandler(ByteBufAllocator, String, int)
variant.context
- the ChannelHandlerContext
to use.sslContext
- the SSLContext
to use.SslHandler
which will replace the OptionalSslHandler
in the pipeline if the
traffic is SSL.protected String newNonSslHandlerName()
null
.protected ChannelHandler newNonSslHandler(ChannelHandlerContext context)
context
- the ChannelHandlerContext
to use.ChannelHandler
which will replace the OptionalSslHandler
in the pipeline
or null
to simply remove the OptionalSslHandler
if the traffic is non-SSL.Copyright © 2008–2017 The Netty Project. All rights reserved.