Package io.grpc.alts.internal
Class AltsTsiHandshaker
java.lang.Object
io.grpc.alts.internal.AltsTsiHandshaker
- All Implemented Interfaces:
TsiHandshaker
Negotiates a grpc channel key to be used by the TsiFrameProtector, using ALTs handshaker service.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AltsHandshakerClient
private final boolean
private final io.grpc.ChannelLogger
private ByteBuffer
static final String
-
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
AltsTsiHandshaker
(boolean isClient, AltsHandshakerClient handshaker, io.grpc.ChannelLogger logger) private
AltsTsiHandshaker
(boolean isClient, HandshakerServiceGrpc.HandshakerServiceStub stub, AltsHandshakerOptions options, io.grpc.ChannelLogger logger) Starts a new TSI handshaker with client options. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes resources.createFrameProtector
(int maxFrameSize, io.netty.buffer.ByteBufAllocator alloc) Creates a frame protector from a completed handshake.createFrameProtector
(io.netty.buffer.ByteBufAllocator alloc) Creates a frame protector from a completed handshake.Returns the peer extracted from a completed handshake.Returns the peer extracted from a completed handshake.void
getBytesToSendToPeer
(ByteBuffer bytes) Gets bytes that need to be sent to the peer.boolean
Returns true if and only if the handshake is still in progress.static TsiHandshaker
newClient
(HandshakerServiceGrpc.HandshakerServiceStub stub, AltsHandshakerOptions options, io.grpc.ChannelLogger logger) Creates a new TsiHandshaker for use by the client.static TsiHandshaker
newServer
(HandshakerServiceGrpc.HandshakerServiceStub stub, AltsHandshakerOptions options, io.grpc.ChannelLogger logger) Creates a new TsiHandshaker for use by the server.boolean
processBytesFromPeer
(ByteBuffer bytes) Process the bytes received from the peer.
-
Field Details
-
logger
private final io.grpc.ChannelLogger logger -
TSI_SERVICE_ACCOUNT_PEER_PROPERTY
- See Also:
-
isClient
private final boolean isClient -
handshaker
-
outputFrame
-
-
Constructor Details
-
AltsTsiHandshaker
private AltsTsiHandshaker(boolean isClient, HandshakerServiceGrpc.HandshakerServiceStub stub, AltsHandshakerOptions options, io.grpc.ChannelLogger logger) Starts a new TSI handshaker with client options. -
AltsTsiHandshaker
AltsTsiHandshaker(boolean isClient, AltsHandshakerClient handshaker, io.grpc.ChannelLogger logger)
-
-
Method Details
-
processBytesFromPeer
Process the bytes received from the peer.- Specified by:
processBytesFromPeer
in interfaceTsiHandshaker
- Parameters:
bytes
- The buffer containing the handshake bytes from the peer.- Returns:
- true, if the handshake has all the data it needs to process and false, if the method must be called again to complete processing.
- Throws:
GeneralSecurityException
-
extractPeer
Returns the peer extracted from a completed handshake.- Specified by:
extractPeer
in interfaceTsiHandshaker
- Returns:
- the extracted peer.
- Throws:
GeneralSecurityException
-
extractPeerObject
Returns the peer extracted from a completed handshake.- Specified by:
extractPeerObject
in interfaceTsiHandshaker
- Returns:
- the extracted peer.
- Throws:
GeneralSecurityException
-
newClient
public static TsiHandshaker newClient(HandshakerServiceGrpc.HandshakerServiceStub stub, AltsHandshakerOptions options, io.grpc.ChannelLogger logger) Creates a new TsiHandshaker for use by the client. -
newServer
public static TsiHandshaker newServer(HandshakerServiceGrpc.HandshakerServiceStub stub, AltsHandshakerOptions options, io.grpc.ChannelLogger logger) Creates a new TsiHandshaker for use by the server. -
getBytesToSendToPeer
Gets bytes that need to be sent to the peer.- Specified by:
getBytesToSendToPeer
in interfaceTsiHandshaker
- Parameters:
bytes
- The buffer to put handshake bytes.- Throws:
GeneralSecurityException
-
isInProgress
public boolean isInProgress()Returns true if and only if the handshake is still in progress.- Specified by:
isInProgress
in interfaceTsiHandshaker
- Returns:
- true, if the handshake is still in progress, false otherwise.
-
createFrameProtector
public TsiFrameProtector createFrameProtector(int maxFrameSize, io.netty.buffer.ByteBufAllocator alloc) Creates a frame protector from a completed handshake. No other methods may be called after the frame protector is created.- Specified by:
createFrameProtector
in interfaceTsiHandshaker
- Parameters:
maxFrameSize
- the requested max frame size, the callee is free to ignore.alloc
- used for allocating ByteBufs.- Returns:
- a new TsiFrameProtector.
-
createFrameProtector
Creates a frame protector from a completed handshake. No other methods may be called after the frame protector is created.- Specified by:
createFrameProtector
in interfaceTsiHandshaker
- Parameters:
alloc
- used for allocating ByteBufs.- Returns:
- a new TsiFrameProtector.
-
close
public void close()Description copied from interface:TsiHandshaker
Closes resources.- Specified by:
close
in interfaceTsiHandshaker
-