@ChannelHandler.Sharable
public final class TdsSslHandler
extends io.netty.channel.ChannelDuplexHandler
This handler wraps or passes thru read and write data depending on the SslState. Because TDS requires header
wrapping, we're not mounting the SslHandler directly into the pipeline but delegating read and write events
to it.
This ChannelHandler supports also full SSL mode and requires to be reordered once the handshake is done therefor it's marked as @Sharable.
SslHandler,
ConnectionState| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG_ENABLED |
| Constructor and Description |
|---|
TdsSslHandler(PacketIdProvider packetIdProvider,
SslConfiguration sslConfiguration,
io.r2dbc.mssql.client.ConnectionContext context)
Creates a new
TdsSslHandler. |
| Modifier and Type | Method and Description |
|---|---|
void |
channelInactive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
Route read events to the
SslHandler. |
void |
channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
SSL quirk: Make sure to flush the output buffer during SSL handshake.
|
void |
flush(io.netty.channel.ChannelHandlerContext ctx)
Wrap SSL handshake in prelogin
Headers. |
void |
handlerAdded(io.netty.channel.ChannelHandlerContext ctx) |
void |
handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) |
void |
userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt)
Lazily register
SslHandler if needed. |
void |
write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise)
Write data either directly (SSL disabled), to an intermediate buffer for
Header wrapping, or via
SslHandler for entire packet encryption without prepending a header. |
bind, close, connect, deregister, disconnect, readchannelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtpublic TdsSslHandler(PacketIdProvider packetIdProvider, SslConfiguration sslConfiguration, io.r2dbc.mssql.client.ConnectionContext context)
TdsSslHandler.packetIdProvider - the PacketIdProvider to create Headers to wrap the SSL handshake.sslConfiguration - SSL config.context - Value object capturing diagnostic connection context.public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt)
throws Exception
SslHandler if needed.userEventTriggered in interface io.netty.channel.ChannelInboundHandleruserEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapterctx - the ChannelHandlerContext for which the event is made.evt - the user event.Exception - thrown if an error occurspublic void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
handlerAdded in interface io.netty.channel.ChannelHandlerhandlerAdded in class io.netty.channel.ChannelHandlerAdapterpublic void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx)
handlerRemoved in interface io.netty.channel.ChannelHandlerhandlerRemoved in class io.netty.channel.ChannelHandlerAdapterpublic void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelInactive in interface io.netty.channel.ChannelInboundHandlerchannelInactive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise)
throws Exception
Header wrapping, or via
SslHandler for entire packet encryption without prepending a header. Note that SslState.LOGIN_ONLY
is swapped to SslState.AFTER_LOGIN_ONLY once login payload is written. We don't check actually whether the
payload is a login packet but rely on higher level layers to send the appropriate data.write in interface io.netty.channel.ChannelOutboundHandlerwrite in class io.netty.channel.ChannelDuplexHandlerctx - the ChannelHandlerContext for which the write operation is mademsg - the message to writepromise - the ChannelPromise to notify once the operation completesException - thrown if an error occurspublic void flush(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
Headers. Delaying write to flush instead of writing each packet in a single
header.flush in interface io.netty.channel.ChannelOutboundHandlerflush in class io.netty.channel.ChannelDuplexHandlerctx - the ChannelHandlerContext for which the flush operation is made.Exception - thrown if an error occurs.public void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelReadComplete in interface io.netty.channel.ChannelInboundHandlerchannelReadComplete in class io.netty.channel.ChannelInboundHandlerAdapterctx - the ChannelHandlerContext for which the read complete operation is made.Exception - thrown if an error occurs.public void channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
throws Exception
SslHandler. Strip off Header during handshake.channelRead in interface io.netty.channel.ChannelInboundHandlerchannelRead in class io.netty.channel.ChannelInboundHandlerAdapterctx - the ChannelHandlerContext for which the read operation is made.msg - the message to read.Exception - thrown if an error occurs.Copyright © 2023. All rights reserved.