Top Description Fields Constructors Methods
io.netty5.handler.ssl

public Class OptionalSslHandler

extends ByteToMessageDecoder
Class Inheritance
Imports
io.netty5.buffer.Buffer, .BufferAllocator, io.netty5.channel.ChannelHandler, .ChannelHandlerContext, io.netty5.handler.codec.ByteToMessageDecoder, io.netty5.util.internal.SilentDispose, io.netty5.util.internal.logging.InternalLogger, .InternalLoggerFactory, javax.net.ssl.SSLContext, .SSLParameters

OptionalSslHandler is a utility decoder to support both SSL and non-SSL handlers based on the first message received.

Field Summary

Modifier and TypeField and Description
private static final InternalLogger
private final SslContext
Inherited from io.netty5.handler.codec.ByteToMessageDecoder:
COMPOSITE_CUMULATORMERGE_CUMULATOR

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
decode(ChannelHandlerContext context, Buffer
the Buffer from which to read data
in
)

Implements abstract io.netty5.handler.codec.ByteToMessageDecoder.decode.

Decode the from one Buffer to another.
private void
private void
protected ChannelHandler

Returns:

the ChannelHandler which will replace the OptionalSslHandler in the pipeline or null to simply remove the OptionalSslHandler if the traffic is non-SSL.
newNonSslHandler
(ChannelHandlerContext context)

Override to configure the ChannelHandler.

protected String

Returns:

the name of the non-SSL handler.
newNonSslHandlerName
()

Optionally specify the non-SSL handler name, this method may return null.

protected SslHandler

Returns:

the SslHandler which will replace the OptionalSslHandler in the pipeline if the traffic is SSL.
newSslHandler
(ChannelHandlerContext context, SslContext
the SSLContext to use.
sslContext
)

Override to configure the SslHandler eg.

protected String

Returns:

the name of the SSL handler.
newSslHandlerName
()

Optionally specify the SSL handler name, this method may return null.

Inherited from io.netty5.handler.codec.ByteToMessageDecoder:
actualReadableByteschannelInactivechannelReadchannelReadCompletechannelShutdowndecodeLastdiscardSomeReadByteshandlerAddedhandlerAdded0handlerRemovedhandlerRemoved0internalBufferisSharableisSingleDecodesetSingleDecode

Field Detail

loggerback to summary
private static final InternalLogger logger
sslContextback to summary
private final SslContext sslContext

Constructor Detail

OptionalSslHandlerback to summary
public OptionalSslHandler(SslContext sslContext)

Method Detail

decodeback to summary
protected void decode(ChannelHandlerContext context, Buffer in) throws Exception

Implements abstract io.netty5.handler.codec.ByteToMessageDecoder.decode.

Doc from io.netty5.handler.codec.ByteToMessageDecoder.decode.

Decode the from one Buffer to another. This method will be called till either the input Buffer has nothing to read when return from this method or till nothing was read from the input Buffer.

Parameters
context:ChannelHandlerContext

the ChannelHandlerContext which this ByteToMessageDecoder belongs to

in:Buffer

the Buffer from which to read data

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs
handleNonSslback to summary
private void handleNonSsl(ChannelHandlerContext context)
handleSslback to summary
private void handleSsl(ChannelHandlerContext context)
newNonSslHandlerback to summary
protected ChannelHandler newNonSslHandler(ChannelHandlerContext context)

Override to configure the ChannelHandler.

Parameters
context:ChannelHandlerContext

the ChannelHandlerContext to use.

Returns:ChannelHandler

the ChannelHandler which will replace the OptionalSslHandler in the pipeline or null to simply remove the OptionalSslHandler if the traffic is non-SSL.

newNonSslHandlerNameback to summary
protected String newNonSslHandlerName()

Optionally specify the non-SSL handler name, this method may return null.

Returns:String

the name of the non-SSL handler.

newSslHandlerback to summary
protected SslHandler newSslHandler(ChannelHandlerContext context, SslContext sslContext)

Override to configure the SslHandler eg. 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(BufferAllocator, String, int) variant.

Parameters
context:ChannelHandlerContext

the ChannelHandlerContext to use.

sslContext:SslContext

the SSLContext to use.

Returns:SslHandler

the SslHandler which will replace the OptionalSslHandler in the pipeline if the traffic is SSL.

newSslHandlerNameback to summary
protected String newSslHandlerName()

Optionally specify the SSL handler name, this method may return null.

Returns:String

the name of the SSL handler.