@Test public void setRpcVersions() throws Exception { when(mockStub.send(Matchers.<HandshakerReq>any())) .thenReturn(MockAltsHandshakerResp.getOkResponse(0)); RpcProtocolVersions rpcVersions = RpcProtocolVersions.newBuilder() .setMinRpcVersion( RpcProtocolVersions.Version.newBuilder().setMajor(3).setMinor(4).build()) .setMaxRpcVersion( RpcProtocolVersions.Version.newBuilder().setMajor(5).setMinor(6).build()) .build(); clientOptions = new AltsClientOptions.Builder() .setTargetName(TEST_TARGET_NAME) .setTargetServiceAccounts(ImmutableList.of(TEST_TARGET_SERVICE_ACCOUNT)) .setRpcProtocolVersions(rpcVersions) .build(); handshaker = new AltsHandshakerClient(mockStub, clientOptions); handshaker.startClientHandshake(); ArgumentCaptor<HandshakerReq> reqCaptor = ArgumentCaptor.forClass(HandshakerReq.class); verify(mockStub).send(reqCaptor.capture()); assertEquals(rpcVersions, reqCaptor.getValue().getClientStart().getRpcVersions()); }
public ByteBuffer startClientHandshake() throws GeneralSecurityException { Preconditions.checkState(!isFinished(), "Handshake has already finished."); HandshakerReq.Builder req = HandshakerReq.newBuilder(); setStartClientFields(req); HandshakerResp resp; try { resp = handshakerStub.send(req.build()); } catch (IOException | InterruptedException e) { throw new GeneralSecurityException(e); } handleResponse(resp); return resp.getOutFrames().asReadOnlyByteBuffer(); }
AltsHandshakerClient { public ByteBuffer startClientHandshake() throws GeneralSecurityException { Preconditions.checkState(!isFinished(), "Handshake has already finished."); HandshakerReq.Builder req = HandshakerReq.newBuilder(); setStartClientFields(req); HandshakerResp resp; try { resp = handshakerStub.send(req.build()); } catch (IOException | InterruptedException e) { throw new GeneralSecurityException(e); } handleResponse(resp); return resp.getOutFrames().asReadOnlyByteBuffer(); } }
AltsHandshakerClient { public ByteBuffer startClientHandshake() throws GeneralSecurityException { Preconditions.checkState(!isFinished(), "Handshake has already finished."); HandshakerReq.Builder req = HandshakerReq.newBuilder(); setStartClientFields(req); HandshakerResp resp; try { resp = handshakerStub.send(req.build()); } catch (IOException | InterruptedException e) { throw new GeneralSecurityException(e); } handleResponse(resp); return resp.getOutFrames().asReadOnlyByteBuffer(); } AltsHandshakerClient(HandshakerServiceStub stub, AltsHandshakerOptions options); @VisibleForTesting  AltsHandshakerClient(AltsHandshakerStub handshakerStub, AltsHandshakerOptions options); }
AltsHandshakerClient { public ByteBuffer startClientHandshake() throws GeneralSecurityException { Preconditions.checkState(!isFinished(), "Handshake has already finished."); HandshakerReq.Builder req = HandshakerReq.newBuilder(); setStartClientFields(req); HandshakerResp resp; try { resp = handshakerStub.send(req.build()); } catch (IOException | InterruptedException e) { throw new GeneralSecurityException(e); } handleResponse(resp); return resp.getOutFrames().asReadOnlyByteBuffer(); } AltsHandshakerClient(HandshakerServiceStub stub, AltsHandshakerOptions options); @VisibleForTesting  AltsHandshakerClient(AltsHandshakerStub handshakerStub, AltsHandshakerOptions options); boolean isFinished(); HandshakerStatus getStatus(); HandshakerResult getResult(); byte[] getKey(); ByteBuffer startClientHandshake(); ByteBuffer startServerHandshake(ByteBuffer inBytes); ByteBuffer next(ByteBuffer inBytes); void close(); }
AltsHandshakerClient { public ByteBuffer startClientHandshake() throws GeneralSecurityException { Preconditions.checkState(!isFinished(), "Handshake has already finished."); HandshakerReq.Builder req = HandshakerReq.newBuilder(); setStartClientFields(req); HandshakerResp resp; try { resp = handshakerStub.send(req.build()); } catch (IOException | InterruptedException e) { throw new GeneralSecurityException(e); } handleResponse(resp); return resp.getOutFrames().asReadOnlyByteBuffer(); } AltsHandshakerClient(HandshakerServiceStub stub, AltsHandshakerOptions options); @VisibleForTesting  AltsHandshakerClient(AltsHandshakerStub handshakerStub, AltsHandshakerOptions options); boolean isFinished(); HandshakerStatus getStatus(); HandshakerResult getResult(); byte[] getKey(); ByteBuffer startClientHandshake(); ByteBuffer startServerHandshake(ByteBuffer inBytes); ByteBuffer next(ByteBuffer inBytes); void close();  }