Class 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 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
      • outputFrame

        private java.nio.ByteBuffer outputFrame
    • Method Detail

      • processBytesFromPeer

        public boolean processBytesFromPeer​(java.nio.ByteBuffer bytes)
                                     throws java.security.GeneralSecurityException
        Process the bytes received from the peer.
        Specified by:
        processBytesFromPeer in interface TsiHandshaker
        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:
        extractPeer in interface TsiHandshaker
        Returns:
        the extracted peer.
        Throws:
        java.security.GeneralSecurityException
      • extractPeerObject

        public java.lang.Object extractPeerObject()
                                           throws java.security.GeneralSecurityException
        Returns the peer extracted from a completed handshake.
        Specified by:
        extractPeerObject in interface TsiHandshaker
        Returns:
        the extracted peer.
        Throws:
        java.security.GeneralSecurityException
      • getBytesToSendToPeer

        public void getBytesToSendToPeer​(java.nio.ByteBuffer bytes)
                                  throws java.security.GeneralSecurityException
        Gets bytes that need to be sent to the peer.
        Specified by:
        getBytesToSendToPeer in interface TsiHandshaker
        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:
        isInProgress in interface TsiHandshaker
        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 interface TsiHandshaker
        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:
        createFrameProtector in interface TsiHandshaker
        Parameters:
        alloc - used for allocating ByteBufs.
        Returns:
        a new TsiFrameProtector.