Package io.grpc.alts.internal
Class TsiHandshakeHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.handler.codec.ByteToMessageDecoder
-
- io.grpc.alts.internal.TsiHandshakeHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
public final class TsiHandshakeHandler extends io.netty.handler.codec.ByteToMessageDecoderPerforms The TSI Handshake.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTsiHandshakeHandler.HandshakeValidatorValidates a Tsi Peer object.
-
Field Summary
Fields Modifier and Type Field Description private static intHANDSHAKE_FRAME_SIZEprivate NettyTsiHandshakerhandshakerprivate TsiHandshakeHandler.HandshakeValidatorhandshakeValidatorprivate io.grpc.ChannelLoggernegotiationLoggerprivate io.netty.channel.ChannelHandlernextprivate io.grpc.netty.ProtocolNegotiationEventpneprivate AsyncSemaphoresemaphoreprivate booleansemaphoreAcquired
-
Constructor Summary
Constructors Constructor Description TsiHandshakeHandler(io.netty.channel.ChannelHandler next, NettyTsiHandshaker handshaker, TsiHandshakeHandler.HandshakeValidator handshakeValidator, AsyncSemaphore semaphore, io.grpc.ChannelLogger negotiationLogger)Constructs a TsHandshakeHandler.TsiHandshakeHandler(io.netty.channel.ChannelHandler next, NettyTsiHandshaker handshaker, TsiHandshakeHandler.HandshakeValidator handshakeValidator, io.grpc.ChannelLogger negotiationLogger)Constructs a TsiHandshakeHandler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddecode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, java.util.List<java.lang.Object> out)protected voiddecodeLast(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, java.util.List<java.lang.Object> out)private voidfireProtocolNegotiationEvent(io.netty.channel.ChannelHandlerContext ctx, TsiPeer peer, java.lang.Object authContext, TsiHandshakeHandler.HandshakeValidator.SecurityDetails details)protected voidhandlerRemoved0(io.netty.channel.ChannelHandlerContext ctx)private io.netty.channel.ChannelFuturesemaphoreAcquire(io.netty.channel.ChannelHandlerContext ctx)private voidsemaphoreRelease()private voidsendHandshake(io.netty.channel.ChannelHandlerContext ctx)Sends as many bytes as are available from the handshaker to the remote peer.voiduserEventTriggered(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object evt)-
Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharable
-
-
-
-
Field Detail
-
HANDSHAKE_FRAME_SIZE
private static final int HANDSHAKE_FRAME_SIZE
- See Also:
- Constant Field Values
-
handshaker
private final NettyTsiHandshaker handshaker
-
handshakeValidator
private final TsiHandshakeHandler.HandshakeValidator handshakeValidator
-
next
private final io.netty.channel.ChannelHandler next
-
semaphore
private final AsyncSemaphore semaphore
-
pne
private io.grpc.netty.ProtocolNegotiationEvent pne
-
semaphoreAcquired
private boolean semaphoreAcquired
-
negotiationLogger
private final io.grpc.ChannelLogger negotiationLogger
-
-
Constructor Detail
-
TsiHandshakeHandler
public TsiHandshakeHandler(io.netty.channel.ChannelHandler next, NettyTsiHandshaker handshaker, TsiHandshakeHandler.HandshakeValidator handshakeValidator, io.grpc.ChannelLogger negotiationLogger)Constructs a TsiHandshakeHandler.
-
TsiHandshakeHandler
public TsiHandshakeHandler(io.netty.channel.ChannelHandler next, NettyTsiHandshaker handshaker, TsiHandshakeHandler.HandshakeValidator handshakeValidator, AsyncSemaphore semaphore, io.grpc.ChannelLogger negotiationLogger)Constructs a TsHandshakeHandler. If a semaphore is provided, a permit from the semaphore is required to start the handshake and is returned when the handshake ends.
-
-
Method Detail
-
decodeLast
protected void decodeLast(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception- Overrides:
decodeLastin classio.netty.handler.codec.ByteToMessageDecoder- Throws:
java.lang.Exception
-
decode
protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception- Specified by:
decodein classio.netty.handler.codec.ByteToMessageDecoder- Throws:
java.lang.Exception
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object evt) throws java.lang.Exception- Specified by:
userEventTriggeredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
userEventTriggeredin classio.netty.handler.codec.ByteToMessageDecoder- Throws:
java.lang.Exception
-
fireProtocolNegotiationEvent
private void fireProtocolNegotiationEvent(io.netty.channel.ChannelHandlerContext ctx, TsiPeer peer, java.lang.Object authContext, TsiHandshakeHandler.HandshakeValidator.SecurityDetails details)
-
sendHandshake
private void sendHandshake(io.netty.channel.ChannelHandlerContext ctx) throws java.security.GeneralSecurityExceptionSends as many bytes as are available from the handshaker to the remote peer.- Throws:
java.security.GeneralSecurityException
-
handlerRemoved0
protected void handlerRemoved0(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception- Overrides:
handlerRemoved0in classio.netty.handler.codec.ByteToMessageDecoder- Throws:
java.lang.Exception
-
semaphoreAcquire
private io.netty.channel.ChannelFuture semaphoreAcquire(io.netty.channel.ChannelHandlerContext ctx)
-
semaphoreRelease
private void semaphoreRelease()
-
-