@Test public void unencryptTransaction() throws Exception { EncodedPayload payload = Fixtures.createSample(); PublicKey providedKey = PublicKey.from("ProvidedKey".getBytes()); byte[] outcome = "SUCCESS".getBytes(); when(enclave.unencryptTransaction(any(EncodedPayload.class), any(PublicKey.class))).thenReturn(outcome); byte[] result = enclaveClient.unencryptTransaction(payload, providedKey); assertThat(result).isEqualTo(outcome); verify(enclave).unencryptTransaction(any(EncodedPayload.class), any(PublicKey.class)); }
@Override public byte[] unencryptTransaction(EncodedPayload payload, PublicKey providedKey) { return ClientCallback.execute( () -> { EnclaveUnencryptPayload dto = new EnclaveUnencryptPayload(); byte[] body = PayloadEncoder.create().encode(payload); dto.setData(body); if (providedKey != null) { dto.setProvidedKey(providedKey.getKeyBytes()); } Response response = client.target(uri).path("unencrypt").request().post(Entity.json(dto)); validateResponseIsOk(response); return response.readEntity(byte[].class); }); }
RestfulEnclaveClient implements EnclaveClient { @Override public byte[] unencryptTransaction(EncodedPayload payload, PublicKey providedKey) { return ClientCallback.execute( () -> { EnclaveUnencryptPayload dto = new EnclaveUnencryptPayload(); byte[] body = PayloadEncoder.create().encode(payload); dto.setData(body); if (providedKey != null) { dto.setProvidedKey(providedKey.getKeyBytes()); } Response response = client.target(uri).path("unencrypt").request().post(Entity.json(dto)); validateResponseIsOk(response); return response.readEntity(byte[].class); }); } }
RestfulEnclaveClient implements EnclaveClient { @Override public byte[] unencryptTransaction(EncodedPayload payload, PublicKey providedKey) { return ClientCallback.execute( () -> { EnclaveUnencryptPayload dto = new EnclaveUnencryptPayload(); byte[] body = PayloadEncoder.create().encode(payload); dto.setData(body); if (providedKey != null) { dto.setProvidedKey(providedKey.getKeyBytes()); } Response response = client.target(uri).path("unencrypt").request().post(Entity.json(dto)); validateResponseIsOk(response); return response.readEntity(byte[].class); }); } RestfulEnclaveClient(Client client, URI uri);  RestfulEnclaveClient(Client client, URI uri, ExecutorService executorService); }
RestfulEnclaveClient implements EnclaveClient { @Override public byte[] unencryptTransaction(EncodedPayload payload, PublicKey providedKey) { return ClientCallback.execute( () -> { EnclaveUnencryptPayload dto = new EnclaveUnencryptPayload(); byte[] body = PayloadEncoder.create().encode(payload); dto.setData(body); if (providedKey != null) { dto.setProvidedKey(providedKey.getKeyBytes()); } Response response = client.target(uri).path("unencrypt").request().post(Entity.json(dto)); validateResponseIsOk(response); return response.readEntity(byte[].class); }); } RestfulEnclaveClient(Client client, URI uri);  RestfulEnclaveClient(Client client, URI uri, ExecutorService executorService); @Override PublicKey defaultPublicKey(); @Override Set<PublicKey> getForwardingKeys(); @Override Set<PublicKey> getPublicKeys(); @Override EncodedPayload encryptPayload(
            byte[] message, PublicKey senderPublicKey, List<PublicKey> recipientPublicKeys); @Override EncodedPayload encryptPayload(RawTransaction rawTransaction, List<PublicKey> recipientPublicKeys); @Override RawTransaction encryptRawPayload(byte[] message, PublicKey sender); @Override byte[] unencryptTransaction(EncodedPayload payload, PublicKey providedKey); @Override byte[] createNewRecipientBox(final EncodedPayload payload, final PublicKey recipientKey); @Override Service.Status status(); }
RestfulEnclaveClient implements EnclaveClient { @Override public byte[] unencryptTransaction(EncodedPayload payload, PublicKey providedKey) { return ClientCallback.execute( () -> { EnclaveUnencryptPayload dto = new EnclaveUnencryptPayload(); byte[] body = PayloadEncoder.create().encode(payload); dto.setData(body); if (providedKey != null) { dto.setProvidedKey(providedKey.getKeyBytes()); } Response response = client.target(uri).path("unencrypt").request().post(Entity.json(dto)); validateResponseIsOk(response); return response.readEntity(byte[].class); }); } RestfulEnclaveClient(Client client, URI uri);  RestfulEnclaveClient(Client client, URI uri, ExecutorService executorService); @Override PublicKey defaultPublicKey(); @Override Set<PublicKey> getForwardingKeys(); @Override Set<PublicKey> getPublicKeys(); @Override EncodedPayload encryptPayload(
            byte[] message, PublicKey senderPublicKey, List<PublicKey> recipientPublicKeys); @Override EncodedPayload encryptPayload(RawTransaction rawTransaction, List<PublicKey> recipientPublicKeys); @Override RawTransaction encryptRawPayload(byte[] message, PublicKey sender); @Override byte[] unencryptTransaction(EncodedPayload payload, PublicKey providedKey); @Override byte[] createNewRecipientBox(final EncodedPayload payload, final PublicKey recipientKey); @Override Service.Status status();  }