Class AltsHandshakerClient

java.lang.Object
io.grpc.alts.internal.AltsHandshakerClient

class AltsHandshakerClient extends Object
An API for conducting handshakes via ALTS handshaker service.
  • Field Details

  • Constructor Details

  • Method Details

    • getApplicationProtocol

      static String getApplicationProtocol()
    • getRecordProtocol

      static String getRecordProtocol()
    • setStartClientFields

      private void setStartClientFields(HandshakerReq.Builder req)
      Sets the start client fields for the passed handshake request.
    • setStartServerFields

      private void setStartServerFields(HandshakerReq.Builder req, ByteBuffer inBytes)
      Sets the start server fields for the passed handshake request.
    • isFinished

      public boolean isFinished()
      Returns true if the handshake is complete.
    • getStatus

      public HandshakerStatus getStatus()
      Returns the handshake status.
    • getResult

      public HandshakerResult 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

      private void handleResponse(HandshakerResp resp) throws GeneralSecurityException
      Parses a handshake response, setting the status, result, and closing the handshaker, as needed.
      Throws:
      GeneralSecurityException
    • startClientHandshake

      public ByteBuffer startClientHandshake() throws GeneralSecurityException
      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

      public ByteBuffer startServerHandshake(ByteBuffer inBytes) throws GeneralSecurityException
      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

      public ByteBuffer next(ByteBuffer inBytes) throws GeneralSecurityException
      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.