Package io.netty.handler.ssl
Class SslClientHelloHandler<T>
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.ssl.SslClientHelloHandler<T>
- All Implemented Interfaces:
ChannelHandler
,ChannelInboundHandler
,ChannelOutboundHandler
- Direct Known Subclasses:
AbstractSniHandler
public abstract class SslClientHelloHandler<T>
extends ByteToMessageDecoder
implements ChannelOutboundHandler
ByteToMessageDecoder
which allows to be notified once a full ClientHello
was received.-
Nested Class Summary
Nested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder
ByteToMessageDecoder.Cumulator
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ByteBuf
private boolean
private static final InternalLogger
static final int
The maximum length of client hello message as defined by RFC5246.private final int
private boolean
private boolean
Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
bind
(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) Called once a bind operation is made.void
close
(ChannelHandlerContext ctx, ChannelPromise promise) Called once a close operation is made.void
connect
(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) Called once a connect operation is made.protected void
decode
(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) Decode the from oneByteBuf
to an other.void
deregister
(ChannelHandlerContext ctx, ChannelPromise promise) Called once a deregister operation is made from the current registeredEventLoop
.void
disconnect
(ChannelHandlerContext ctx, ChannelPromise promise) Called once a disconnect operation is made.void
Called once a flush operation is made.protected void
Gets called after theByteToMessageDecoder
was removed from the actual context and it doesn't handle events anymore.lookup
(ChannelHandlerContext ctx, ByteBuf clientHello) Kicks off a lookup for the givenClientHello
and returns aFuture
which in turn will notify theonLookupComplete(ChannelHandlerContext, Future)
on completion.protected abstract void
onLookupComplete
(ChannelHandlerContext ctx, Future<T> future) Called upon completion of thelookup(ChannelHandlerContext, ByteBuf)
Future
.void
InterceptsChannelHandlerContext.read()
.private void
private static void
releaseIfNotNull
(ByteBuf buffer) private void
select
(ChannelHandlerContext ctx, ByteBuf clientHello) void
write
(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) Called once a write operation is made.Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
MAX_CLIENT_HELLO_LENGTH
public static final int MAX_CLIENT_HELLO_LENGTHThe maximum length of client hello message as defined by RFC5246.- See Also:
-
logger
-
maxClientHelloLength
private final int maxClientHelloLength -
handshakeFailed
private boolean handshakeFailed -
suppressRead
private boolean suppressRead -
readPending
private boolean readPending -
handshakeBuffer
-
-
Constructor Details
-
SslClientHelloHandler
public SslClientHelloHandler() -
SslClientHelloHandler
protected SslClientHelloHandler(int maxClientHelloLength)
-
-
Method Details
-
decode
Description copied from class:ByteToMessageDecoder
Decode the from oneByteBuf
to an other. This method will be called till either the inputByteBuf
has nothing to read when return from this method or till nothing was read from the inputByteBuf
.- Specified by:
decode
in classByteToMessageDecoder
- Parameters:
ctx
- theChannelHandlerContext
which thisByteToMessageDecoder
belongs toin
- theByteBuf
from which to read dataout
- theList
to which decoded messages should be added- Throws:
Exception
- is thrown if an error occurs
-
releaseHandshakeBuffer
private void releaseHandshakeBuffer() -
releaseIfNotNull
-
select
- Throws:
Exception
-
handlerRemoved0
Description copied from class:ByteToMessageDecoder
Gets called after theByteToMessageDecoder
was removed from the actual context and it doesn't handle events anymore.- Overrides:
handlerRemoved0
in classByteToMessageDecoder
- Throws:
Exception
-
lookup
protected abstract Future<T> lookup(ChannelHandlerContext ctx, ByteBuf clientHello) throws Exception Kicks off a lookup for the givenClientHello
and returns aFuture
which in turn will notify theonLookupComplete(ChannelHandlerContext, Future)
on completion. See https://tools.ietf.org/html/rfc5246#section-7.4.1.2struct { ProtocolVersion client_version; Random random; SessionID session_id; CipherSuite cipher_suitesinvalid input: '<'2..2^16-2>; CompressionMethod compression_methodsinvalid input: '<'1..2^8-1>; select (extensions_present) { case false: struct {}; case true: Extension extensionsinvalid input: '<'0..2^16-1>; }; } ClientHello;
- Throws:
Exception
- See Also:
-
onLookupComplete
protected abstract void onLookupComplete(ChannelHandlerContext ctx, Future<T> future) throws Exception Called upon completion of thelookup(ChannelHandlerContext, ByteBuf)
Future
.- Throws:
Exception
- See Also:
-
read
Description copied from interface:ChannelOutboundHandler
InterceptsChannelHandlerContext.read()
.- Specified by:
read
in interfaceChannelOutboundHandler
- Throws:
Exception
-
bind
public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception Description copied from interface:ChannelOutboundHandler
Called once a bind operation is made.- Specified by:
bind
in interfaceChannelOutboundHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the bind operation is madelocalAddress
- theSocketAddress
to which it should boundpromise
- theChannelPromise
to notify once the operation completes- Throws:
Exception
- thrown if an error occurs
-
connect
public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception Description copied from interface:ChannelOutboundHandler
Called once a connect operation is made.- Specified by:
connect
in interfaceChannelOutboundHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the connect operation is maderemoteAddress
- theSocketAddress
to which it should connectlocalAddress
- theSocketAddress
which is used as source on connectpromise
- theChannelPromise
to notify once the operation completes- Throws:
Exception
- thrown if an error occurs
-
disconnect
Description copied from interface:ChannelOutboundHandler
Called once a disconnect operation is made.- Specified by:
disconnect
in interfaceChannelOutboundHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the disconnect operation is madepromise
- theChannelPromise
to notify once the operation completes- Throws:
Exception
- thrown if an error occurs
-
close
Description copied from interface:ChannelOutboundHandler
Called once a close operation is made.- Specified by:
close
in interfaceChannelOutboundHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the close operation is madepromise
- theChannelPromise
to notify once the operation completes- Throws:
Exception
- thrown if an error occurs
-
deregister
Description copied from interface:ChannelOutboundHandler
Called once a deregister operation is made from the current registeredEventLoop
.- Specified by:
deregister
in interfaceChannelOutboundHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the close operation is madepromise
- theChannelPromise
to notify once the operation completes- Throws:
Exception
- thrown if an error occurs
-
write
Description copied from interface:ChannelOutboundHandler
Called once a write operation is made. The write operation will write the messages through theChannelPipeline
. Those are then ready to be flushed to the actualChannel
onceChannel.flush()
is called- Specified by:
write
in interfaceChannelOutboundHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the write operation is mademsg
- the message to writepromise
- theChannelPromise
to notify once the operation completes- Throws:
Exception
- thrown if an error occurs
-
flush
Description copied from interface:ChannelOutboundHandler
Called once a flush operation is made. The flush operation will try to flush out all previous written messages that are pending.- Specified by:
flush
in interfaceChannelOutboundHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the flush operation is made- Throws:
Exception
- thrown if an error occurs
-