@Test public void extractPeerFailure() throws Exception { when(mockClient.isFinished()).thenReturn(false); try { handshakerClient.extractPeer(); fail("Expected IllegalStateException"); } catch (IllegalStateException expected) { assertEquals("Handshake is not complete.", expected.getMessage()); } }
@Override public TsiPeer extractPeer() throws GeneralSecurityException { Preconditions.checkState(!isInProgress(), "Handshake is not complete."); List<TsiPeer.Property<?>> peerProperties = new ArrayList<TsiPeer.Property<?>>(); peerProperties.add( new TsiPeer.StringProperty( TSI_SERVICE_ACCOUNT_PEER_PROPERTY, handshaker.getResult().getPeerIdentity().getServiceAccount())); return new TsiPeer(peerProperties); }
AltsTsiHandshaker implements TsiHandshaker { @Override public TsiPeer extractPeer() throws GeneralSecurityException { Preconditions.checkState(!isInProgress(), "Handshake is not complete."); List<TsiPeer.Property<?>> peerProperties = new ArrayList<TsiPeer.Property<?>>(); peerProperties.add( new TsiPeer.StringProperty( TSI_SERVICE_ACCOUNT_PEER_PROPERTY, handshaker.getResult().getPeerIdentity().getServiceAccount())); return new TsiPeer(peerProperties); } }
AltsTsiHandshaker implements TsiHandshaker { @Override public TsiPeer extractPeer() throws GeneralSecurityException { Preconditions.checkState(!isInProgress(), "Handshake is not complete."); List<TsiPeer.Property<?>> peerProperties = new ArrayList<TsiPeer.Property<?>>(); peerProperties.add( new TsiPeer.StringProperty( TSI_SERVICE_ACCOUNT_PEER_PROPERTY, handshaker.getResult().getPeerIdentity().getServiceAccount())); return new TsiPeer(peerProperties); } private  AltsTsiHandshaker(
      boolean isClient, HandshakerServiceStub stub, AltsHandshakerOptions options); @VisibleForTesting  AltsTsiHandshaker(boolean isClient, AltsHandshakerClient handshaker); }
AltsTsiHandshaker implements TsiHandshaker { @Override public TsiPeer extractPeer() throws GeneralSecurityException { Preconditions.checkState(!isInProgress(), "Handshake is not complete."); List<TsiPeer.Property<?>> peerProperties = new ArrayList<TsiPeer.Property<?>>(); peerProperties.add( new TsiPeer.StringProperty( TSI_SERVICE_ACCOUNT_PEER_PROPERTY, handshaker.getResult().getPeerIdentity().getServiceAccount())); return new TsiPeer(peerProperties); } private  AltsTsiHandshaker(
      boolean isClient, HandshakerServiceStub stub, AltsHandshakerOptions options); @VisibleForTesting  AltsTsiHandshaker(boolean isClient, AltsHandshakerClient handshaker); @Override boolean processBytesFromPeer(ByteBuffer bytes); @Override TsiPeer extractPeer(); @Override Object extractPeerObject(); static TsiHandshaker newClient(HandshakerServiceStub stub, AltsHandshakerOptions options); static TsiHandshaker newServer(HandshakerServiceStub stub, AltsHandshakerOptions options); @Override void getBytesToSendToPeer(ByteBuffer bytes); @Override boolean isInProgress(); @Override TsiFrameProtector createFrameProtector(int maxFrameSize, ByteBufAllocator alloc); @Override TsiFrameProtector createFrameProtector(ByteBufAllocator alloc); }
AltsTsiHandshaker implements TsiHandshaker { @Override public TsiPeer extractPeer() throws GeneralSecurityException { Preconditions.checkState(!isInProgress(), "Handshake is not complete."); List<TsiPeer.Property<?>> peerProperties = new ArrayList<TsiPeer.Property<?>>(); peerProperties.add( new TsiPeer.StringProperty( TSI_SERVICE_ACCOUNT_PEER_PROPERTY, handshaker.getResult().getPeerIdentity().getServiceAccount())); return new TsiPeer(peerProperties); } private  AltsTsiHandshaker(
      boolean isClient, HandshakerServiceStub stub, AltsHandshakerOptions options); @VisibleForTesting  AltsTsiHandshaker(boolean isClient, AltsHandshakerClient handshaker); @Override boolean processBytesFromPeer(ByteBuffer bytes); @Override TsiPeer extractPeer(); @Override Object extractPeerObject(); static TsiHandshaker newClient(HandshakerServiceStub stub, AltsHandshakerOptions options); static TsiHandshaker newServer(HandshakerServiceStub stub, AltsHandshakerOptions options); @Override void getBytesToSendToPeer(ByteBuffer bytes); @Override boolean isInProgress(); @Override TsiFrameProtector createFrameProtector(int maxFrameSize, ByteBufAllocator alloc); @Override TsiFrameProtector createFrameProtector(ByteBufAllocator alloc); static final String TSI_SERVICE_ACCOUNT_PEER_PROPERTY; }