@Test public void receiveFromParams() { when(transactionManager.receive(any(com.quorum.tessera.transaction.ReceiveRequest.class))).thenReturn(mock(ReceiveResponse.class)); Response result = transactionResource.receive("", ""); assertThat(result.getStatus()).isEqualTo(200); verify(transactionManager).receive(any(com.quorum.tessera.transaction.ReceiveRequest.class)); }
@ApiOperation(value = "Returns decrypted payload back to Quorum") @ApiResponses({@ApiResponse(code = 200, response = ReceiveResponse.class, message = "Receive Response object")}) @GET @Path("/transaction/{hash}") @Produces(APPLICATION_JSON) public Response receive( @ApiParam("Encoded hash used to decrypt the payload") @NotNull @Valid @PathParam("hash") final String hash, @ApiParam("Encoded recipient key") @Valid @QueryParam("to") final String toStr) { Base64.Decoder base64Decoder = Base64.getDecoder(); PublicKey recipient = Optional.ofNullable(toStr) .filter(Predicate.not(String::isEmpty)) .map(base64Decoder::decode) .map(PublicKey::from).orElse(null); MessageHash transactionHash = Optional.of(hash) .map(base64Decoder::decode) .map(MessageHash::new).get(); com.quorum.tessera.transaction.ReceiveRequest request = com.quorum.tessera.transaction.ReceiveRequest.Builder.create() .withRecipient(recipient) .withTransactionHash(transactionHash) .build(); com.quorum.tessera.transaction.ReceiveResponse response = transactionManager.receive(request); ReceiveResponse receiveResponse = new ReceiveResponse(); receiveResponse.setPayload(response.getUnencryptedTransactionData()); return Response .status(Status.OK) .type(APPLICATION_JSON) .entity(receiveResponse) .build(); }
TransactionResource { @ApiOperation(value = "Returns decrypted payload back to Quorum") @ApiResponses({@ApiResponse(code = 200, response = ReceiveResponse.class, message = "Receive Response object")}) @GET @Path("/transaction/{hash}") @Produces(APPLICATION_JSON) public Response receive( @ApiParam("Encoded hash used to decrypt the payload") @NotNull @Valid @PathParam("hash") final String hash, @ApiParam("Encoded recipient key") @Valid @QueryParam("to") final String toStr) { Base64.Decoder base64Decoder = Base64.getDecoder(); PublicKey recipient = Optional.ofNullable(toStr) .filter(Predicate.not(String::isEmpty)) .map(base64Decoder::decode) .map(PublicKey::from).orElse(null); MessageHash transactionHash = Optional.of(hash) .map(base64Decoder::decode) .map(MessageHash::new).get(); com.quorum.tessera.transaction.ReceiveRequest request = com.quorum.tessera.transaction.ReceiveRequest.Builder.create() .withRecipient(recipient) .withTransactionHash(transactionHash) .build(); com.quorum.tessera.transaction.ReceiveResponse response = transactionManager.receive(request); ReceiveResponse receiveResponse = new ReceiveResponse(); receiveResponse.setPayload(response.getUnencryptedTransactionData()); return Response .status(Status.OK) .type(APPLICATION_JSON) .entity(receiveResponse) .build(); } }
TransactionResource { @ApiOperation(value = "Returns decrypted payload back to Quorum") @ApiResponses({@ApiResponse(code = 200, response = ReceiveResponse.class, message = "Receive Response object")}) @GET @Path("/transaction/{hash}") @Produces(APPLICATION_JSON) public Response receive( @ApiParam("Encoded hash used to decrypt the payload") @NotNull @Valid @PathParam("hash") final String hash, @ApiParam("Encoded recipient key") @Valid @QueryParam("to") final String toStr) { Base64.Decoder base64Decoder = Base64.getDecoder(); PublicKey recipient = Optional.ofNullable(toStr) .filter(Predicate.not(String::isEmpty)) .map(base64Decoder::decode) .map(PublicKey::from).orElse(null); MessageHash transactionHash = Optional.of(hash) .map(base64Decoder::decode) .map(MessageHash::new).get(); com.quorum.tessera.transaction.ReceiveRequest request = com.quorum.tessera.transaction.ReceiveRequest.Builder.create() .withRecipient(recipient) .withTransactionHash(transactionHash) .build(); com.quorum.tessera.transaction.ReceiveResponse response = transactionManager.receive(request); ReceiveResponse receiveResponse = new ReceiveResponse(); receiveResponse.setPayload(response.getUnencryptedTransactionData()); return Response .status(Status.OK) .type(APPLICATION_JSON) .entity(receiveResponse) .build(); } TransactionResource(TransactionManager transactionManager); }
TransactionResource { @ApiOperation(value = "Returns decrypted payload back to Quorum") @ApiResponses({@ApiResponse(code = 200, response = ReceiveResponse.class, message = "Receive Response object")}) @GET @Path("/transaction/{hash}") @Produces(APPLICATION_JSON) public Response receive( @ApiParam("Encoded hash used to decrypt the payload") @NotNull @Valid @PathParam("hash") final String hash, @ApiParam("Encoded recipient key") @Valid @QueryParam("to") final String toStr) { Base64.Decoder base64Decoder = Base64.getDecoder(); PublicKey recipient = Optional.ofNullable(toStr) .filter(Predicate.not(String::isEmpty)) .map(base64Decoder::decode) .map(PublicKey::from).orElse(null); MessageHash transactionHash = Optional.of(hash) .map(base64Decoder::decode) .map(MessageHash::new).get(); com.quorum.tessera.transaction.ReceiveRequest request = com.quorum.tessera.transaction.ReceiveRequest.Builder.create() .withRecipient(recipient) .withTransactionHash(transactionHash) .build(); com.quorum.tessera.transaction.ReceiveResponse response = transactionManager.receive(request); ReceiveResponse receiveResponse = new ReceiveResponse(); receiveResponse.setPayload(response.getUnencryptedTransactionData()); return Response .status(Status.OK) .type(APPLICATION_JSON) .entity(receiveResponse) .build(); } TransactionResource(TransactionManager transactionManager); @ApiOperation(value = "Send private transaction payload") @ApiResponses({ @ApiResponse(code = 200, response = SendResponse.class, message = "Send response"), @ApiResponse(code = 400, message = "For unknown and unknown keys") }) @POST @Path("send") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) Response send(
            @ApiParam(name = "sendRequest", required = true) @NotNull @Valid
                    final SendRequest sendRequest); @ApiOperation(value = "Send private raw transaction payload") @ApiResponses({ @ApiResponse(code = 200, response = SendResponse.class, message = "Send response"), @ApiResponse(code = 400, message = "For unknown and unknown keys") }) @POST @Path("sendsignedtx") @Consumes(APPLICATION_OCTET_STREAM) @Produces(TEXT_PLAIN) Response sendSignedTransaction(
            @HeaderParam("c11n-to") final String recipientKeys, @NotNull @Size(min = 1) final byte[] signedTransaction); @ApiOperation(value = "Send private transaction payload") @ApiResponses({ @ApiResponse(code = 200, message = "Encoded Key", response = String.class), @ApiResponse(code = 500, message = "Unknown server error") }) @POST @Path("sendraw") @Consumes(APPLICATION_OCTET_STREAM) @Produces(TEXT_PLAIN) Response sendRaw(
            @HeaderParam("c11n-from") final String sender,
            @HeaderParam("c11n-to") final String recipientKeys,
            @NotNull @Size(min = 1) final byte[] payload); @ApiOperation(value = "Returns decrypted payload back to Quorum") @ApiResponses({@ApiResponse(code = 200, response = ReceiveResponse.class, message = "Receive Response object")}) @GET @Path("/transaction/{hash}") @Produces(APPLICATION_JSON) Response receive(
            @ApiParam("Encoded hash used to decrypt the payload") @NotNull @Valid @PathParam("hash") final String hash,
            @ApiParam("Encoded recipient key") @Valid @QueryParam("to") final String toStr); @GET @Path("/receive") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) Response receive(@Valid final ReceiveRequest request); @ApiOperation(value = "Submit keys to retrieve payload and decrypt it") @ApiResponses({@ApiResponse(code = 200, message = "Raw payload", response = byte[].class)}) @GET @Path("receiveraw") @Consumes(APPLICATION_OCTET_STREAM) @Produces(APPLICATION_OCTET_STREAM) Response receiveRaw(
            @ApiParam("Encoded transaction hash") @NotNull @HeaderParam(value = "c11n-key") String hash,
            @ApiParam("Encoded Recipient Public Key") @HeaderParam(value = "c11n-to") String recipientKey); @Deprecated @ApiOperation("Deprecated: Replaced by /transaction/{key} DELETE HTTP method") @ApiResponses({ @ApiResponse(code = 200, message = "Status message", response = String.class), @ApiResponse(code = 404, message = "If the entity doesn't exist") }) @POST @Path("delete") @Consumes(APPLICATION_JSON) @Produces(TEXT_PLAIN) Response delete(
            @ApiParam(name = "deleteRequest", required = true, value = "Key data to be deleted") @Valid
                    final DeleteRequest deleteRequest); @ApiOperation("Delete single transaction from P2PRestApp node") @ApiResponses({ @ApiResponse(code = 204, message = "Successful deletion"), @ApiResponse(code = 404, message = "If the entity doesn't exist") }) @DELETE @Path("/transaction/{key}") Response deleteKey(@ApiParam("Encoded hash") @PathParam("key") final String key); @GET @Path("/transaction/{key}/isSender") Response isSender(@ApiParam("Encoded hash") @PathParam("key") final String ptmHash); @GET @Path("/transaction/{key}/participants") Response getParticipants(@ApiParam("Encoded hash") @PathParam("key") final String ptmHash); }
TransactionResource { @ApiOperation(value = "Returns decrypted payload back to Quorum") @ApiResponses({@ApiResponse(code = 200, response = ReceiveResponse.class, message = "Receive Response object")}) @GET @Path("/transaction/{hash}") @Produces(APPLICATION_JSON) public Response receive( @ApiParam("Encoded hash used to decrypt the payload") @NotNull @Valid @PathParam("hash") final String hash, @ApiParam("Encoded recipient key") @Valid @QueryParam("to") final String toStr) { Base64.Decoder base64Decoder = Base64.getDecoder(); PublicKey recipient = Optional.ofNullable(toStr) .filter(Predicate.not(String::isEmpty)) .map(base64Decoder::decode) .map(PublicKey::from).orElse(null); MessageHash transactionHash = Optional.of(hash) .map(base64Decoder::decode) .map(MessageHash::new).get(); com.quorum.tessera.transaction.ReceiveRequest request = com.quorum.tessera.transaction.ReceiveRequest.Builder.create() .withRecipient(recipient) .withTransactionHash(transactionHash) .build(); com.quorum.tessera.transaction.ReceiveResponse response = transactionManager.receive(request); ReceiveResponse receiveResponse = new ReceiveResponse(); receiveResponse.setPayload(response.getUnencryptedTransactionData()); return Response .status(Status.OK) .type(APPLICATION_JSON) .entity(receiveResponse) .build(); } TransactionResource(TransactionManager transactionManager); @ApiOperation(value = "Send private transaction payload") @ApiResponses({ @ApiResponse(code = 200, response = SendResponse.class, message = "Send response"), @ApiResponse(code = 400, message = "For unknown and unknown keys") }) @POST @Path("send") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) Response send(
            @ApiParam(name = "sendRequest", required = true) @NotNull @Valid
                    final SendRequest sendRequest); @ApiOperation(value = "Send private raw transaction payload") @ApiResponses({ @ApiResponse(code = 200, response = SendResponse.class, message = "Send response"), @ApiResponse(code = 400, message = "For unknown and unknown keys") }) @POST @Path("sendsignedtx") @Consumes(APPLICATION_OCTET_STREAM) @Produces(TEXT_PLAIN) Response sendSignedTransaction(
            @HeaderParam("c11n-to") final String recipientKeys, @NotNull @Size(min = 1) final byte[] signedTransaction); @ApiOperation(value = "Send private transaction payload") @ApiResponses({ @ApiResponse(code = 200, message = "Encoded Key", response = String.class), @ApiResponse(code = 500, message = "Unknown server error") }) @POST @Path("sendraw") @Consumes(APPLICATION_OCTET_STREAM) @Produces(TEXT_PLAIN) Response sendRaw(
            @HeaderParam("c11n-from") final String sender,
            @HeaderParam("c11n-to") final String recipientKeys,
            @NotNull @Size(min = 1) final byte[] payload); @ApiOperation(value = "Returns decrypted payload back to Quorum") @ApiResponses({@ApiResponse(code = 200, response = ReceiveResponse.class, message = "Receive Response object")}) @GET @Path("/transaction/{hash}") @Produces(APPLICATION_JSON) Response receive(
            @ApiParam("Encoded hash used to decrypt the payload") @NotNull @Valid @PathParam("hash") final String hash,
            @ApiParam("Encoded recipient key") @Valid @QueryParam("to") final String toStr); @GET @Path("/receive") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) Response receive(@Valid final ReceiveRequest request); @ApiOperation(value = "Submit keys to retrieve payload and decrypt it") @ApiResponses({@ApiResponse(code = 200, message = "Raw payload", response = byte[].class)}) @GET @Path("receiveraw") @Consumes(APPLICATION_OCTET_STREAM) @Produces(APPLICATION_OCTET_STREAM) Response receiveRaw(
            @ApiParam("Encoded transaction hash") @NotNull @HeaderParam(value = "c11n-key") String hash,
            @ApiParam("Encoded Recipient Public Key") @HeaderParam(value = "c11n-to") String recipientKey); @Deprecated @ApiOperation("Deprecated: Replaced by /transaction/{key} DELETE HTTP method") @ApiResponses({ @ApiResponse(code = 200, message = "Status message", response = String.class), @ApiResponse(code = 404, message = "If the entity doesn't exist") }) @POST @Path("delete") @Consumes(APPLICATION_JSON) @Produces(TEXT_PLAIN) Response delete(
            @ApiParam(name = "deleteRequest", required = true, value = "Key data to be deleted") @Valid
                    final DeleteRequest deleteRequest); @ApiOperation("Delete single transaction from P2PRestApp node") @ApiResponses({ @ApiResponse(code = 204, message = "Successful deletion"), @ApiResponse(code = 404, message = "If the entity doesn't exist") }) @DELETE @Path("/transaction/{key}") Response deleteKey(@ApiParam("Encoded hash") @PathParam("key") final String key); @GET @Path("/transaction/{key}/isSender") Response isSender(@ApiParam("Encoded hash") @PathParam("key") final String ptmHash); @GET @Path("/transaction/{key}/participants") Response getParticipants(@ApiParam("Encoded hash") @PathParam("key") final String ptmHash);  }