Package io.grpc.alts.internal
Class AltsHandshakerClient
java.lang.Object
io.grpc.alts.internal.AltsHandshakerClient
An API for conducting handshakes via ALTS handshaker service.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private boolean
private final AltsHandshakerOptions
private final AltsHandshakerStub
private static final int
private final io.grpc.ChannelLogger
private static final String
private HandshakerResult
private HandshakerStatus
-
Constructor Summary
ConstructorsConstructorDescriptionAltsHandshakerClient
(AltsHandshakerStub handshakerStub, AltsHandshakerOptions options, io.grpc.ChannelLogger logger) AltsHandshakerClient
(HandshakerServiceGrpc.HandshakerServiceStub stub, AltsHandshakerOptions options, io.grpc.ChannelLogger logger) Starts a new handshake interacting with the handshaker service. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the connection.(package private) static String
byte[]
getKey()
Returns the resulting key of the handshake, if the handshake is completed.(package private) static String
Returns the result data of the handshake, if the handshake is completed.Returns the handshake status.private void
handleResponse
(HandshakerResp resp) Parses a handshake response, setting the status, result, and closing the handshaker, as needed.boolean
Returns true if the handshake is complete.next
(ByteBuffer inBytes) Processes the next bytes in a handshake.private void
Sets the start client fields for the passed handshake request.private void
setStartServerFields
(HandshakerReq.Builder req, ByteBuffer inBytes) Sets the start server fields for the passed handshake request.Starts a client handshake.startServerHandshake
(ByteBuffer inBytes) Starts a server handshake.
-
Field Details
-
APPLICATION_PROTOCOL
- See Also:
-
RECORD_PROTOCOL
- See Also:
-
KEY_LENGTH
private static final int KEY_LENGTH -
handshakerStub
-
handshakerOptions
-
result
-
status
-
logger
private final io.grpc.ChannelLogger logger -
closed
private boolean closed
-
-
Constructor Details
-
AltsHandshakerClient
AltsHandshakerClient(HandshakerServiceGrpc.HandshakerServiceStub stub, AltsHandshakerOptions options, io.grpc.ChannelLogger logger) Starts a new handshake interacting with the handshaker service. -
AltsHandshakerClient
AltsHandshakerClient(AltsHandshakerStub handshakerStub, AltsHandshakerOptions options, io.grpc.ChannelLogger logger)
-
-
Method Details
-
getApplicationProtocol
-
getRecordProtocol
-
setStartClientFields
Sets the start client fields for the passed handshake request. -
setStartServerFields
Sets the start server fields for the passed handshake request. -
isFinished
public boolean isFinished()Returns true if the handshake is complete. -
getStatus
Returns the handshake status. -
getResult
Returns the result data of the handshake, if the handshake is completed. -
getKey
public byte[] getKey()Returns the resulting key of the handshake, if the handshake is completed. Note that the key data returned from the handshake may be more than the key length required for the record protocol, thus we need to truncate to the right size. -
handleResponse
Parses a handshake response, setting the status, result, and closing the handshaker, as needed.- Throws:
GeneralSecurityException
-
startClientHandshake
Starts a client handshake. A GeneralSecurityException is thrown if the handshaker service is interrupted or fails. Note that isFinished() must be false before this function is called.- Returns:
- the frame to give to the peer.
- Throws:
GeneralSecurityException
- or IllegalStateException
-
startServerHandshake
Starts a server handshake. A GeneralSecurityException is thrown if the handshaker service is interrupted or fails. Note that isFinished() must be false before this function is called.- Parameters:
inBytes
- the bytes received from the peer.- Returns:
- the frame to give to the peer.
- Throws:
GeneralSecurityException
- or IllegalStateException
-
next
Processes the next bytes in a handshake. A GeneralSecurityException is thrown if the handshaker service is interrupted or fails. Note that isFinished() must be false before this function is called.- Parameters:
inBytes
- the bytes received from the peer.- Returns:
- the frame to give to the peer.
- Throws:
GeneralSecurityException
- or IllegalStateException
-
close
public void close()Closes the connection.
-