Package io.grpc.alts.internal
Class AltsTsiHandshaker
- java.lang.Object
-
- io.grpc.alts.internal.AltsTsiHandshaker
-
- All Implemented Interfaces:
TsiHandshaker
public final class AltsTsiHandshaker extends java.lang.Object implements TsiHandshaker
Negotiates a grpc channel key to be used by the TsiFrameProtector, using ALTs handshaker service.
-
-
Field Summary
Fields Modifier and Type Field Description private AltsHandshakerClienthandshakerprivate booleanisClientprivate io.grpc.ChannelLoggerloggerprivate java.nio.ByteBufferoutputFramestatic java.lang.StringTSI_SERVICE_ACCOUNT_PEER_PROPERTY
-
Constructor Summary
Constructors Modifier Constructor Description (package private)AltsTsiHandshaker(boolean isClient, AltsHandshakerClient handshaker, io.grpc.ChannelLogger logger)privateAltsTsiHandshaker(boolean isClient, HandshakerServiceGrpc.HandshakerServiceStub stub, AltsHandshakerOptions options, io.grpc.ChannelLogger logger)Starts a new TSI handshaker with client options.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes resources.TsiFrameProtectorcreateFrameProtector(int maxFrameSize, io.netty.buffer.ByteBufAllocator alloc)Creates a frame protector from a completed handshake.TsiFrameProtectorcreateFrameProtector(io.netty.buffer.ByteBufAllocator alloc)Creates a frame protector from a completed handshake.TsiPeerextractPeer()Returns the peer extracted from a completed handshake.java.lang.ObjectextractPeerObject()Returns the peer extracted from a completed handshake.voidgetBytesToSendToPeer(java.nio.ByteBuffer bytes)Gets bytes that need to be sent to the peer.booleanisInProgress()Returns true if and only if the handshake is still in progress.static TsiHandshakernewClient(HandshakerServiceGrpc.HandshakerServiceStub stub, AltsHandshakerOptions options, io.grpc.ChannelLogger logger)Creates a new TsiHandshaker for use by the client.static TsiHandshakernewServer(HandshakerServiceGrpc.HandshakerServiceStub stub, AltsHandshakerOptions options, io.grpc.ChannelLogger logger)Creates a new TsiHandshaker for use by the server.booleanprocessBytesFromPeer(java.nio.ByteBuffer bytes)Process the bytes received from the peer.
-
-
-
Field Detail
-
logger
private final io.grpc.ChannelLogger logger
-
TSI_SERVICE_ACCOUNT_PEER_PROPERTY
public static final java.lang.String TSI_SERVICE_ACCOUNT_PEER_PROPERTY
- See Also:
- Constant Field Values
-
isClient
private final boolean isClient
-
handshaker
private final AltsHandshakerClient handshaker
-
outputFrame
private java.nio.ByteBuffer outputFrame
-
-
Constructor Detail
-
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 Detail
-
processBytesFromPeer
public boolean processBytesFromPeer(java.nio.ByteBuffer bytes) throws java.security.GeneralSecurityExceptionProcess the bytes received from the peer.- Specified by:
processBytesFromPeerin 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:
java.security.GeneralSecurityException
-
extractPeer
public TsiPeer extractPeer() throws java.security.GeneralSecurityException
Returns the peer extracted from a completed handshake.- Specified by:
extractPeerin interfaceTsiHandshaker- Returns:
- the extracted peer.
- Throws:
java.security.GeneralSecurityException
-
extractPeerObject
public java.lang.Object extractPeerObject() throws java.security.GeneralSecurityExceptionReturns the peer extracted from a completed handshake.- Specified by:
extractPeerObjectin interfaceTsiHandshaker- Returns:
- the extracted peer.
- Throws:
java.security.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
public void getBytesToSendToPeer(java.nio.ByteBuffer bytes) throws java.security.GeneralSecurityExceptionGets bytes that need to be sent to the peer.- Specified by:
getBytesToSendToPeerin interfaceTsiHandshaker- Parameters:
bytes- The buffer to put handshake bytes.- Throws:
java.security.GeneralSecurityException
-
isInProgress
public boolean isInProgress()
Returns true if and only if the handshake is still in progress.- Specified by:
isInProgressin 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:
createFrameProtectorin interfaceTsiHandshaker- Parameters:
maxFrameSize- the requested max frame size, the callee is free to ignore.alloc- used for allocating ByteBufs.- Returns:
- a new TsiFrameProtector.
-
createFrameProtector
public TsiFrameProtector createFrameProtector(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:
createFrameProtectorin interfaceTsiHandshaker- Parameters:
alloc- used for allocating ByteBufs.- Returns:
- a new TsiFrameProtector.
-
close
public void close()
Description copied from interface:TsiHandshakerCloses resources.- Specified by:
closein interfaceTsiHandshaker
-
-