PGPPipe extends StreamingPipe { @Override public PipeRunResult doPipe(Message message, IPipeLineSession session) throws PipeRunException { try (MessageOutputStream target=getTargetStream(session)) { try (OutputStream out = target.asStream()) { pgpAction.run(message.asInputStream(), out); } return target.getPipeRunResult(); } catch (Exception e) { throw new PipeRunException(this, "Exception was thrown during PGPPipe execution.", e); } }  @Override void configure(); @Override PipeRunResult doPipe(Message message, IPipeLineSession session); @IbisDoc({"Action to be taken when pipe is executed. It can be one of the followed: Encrypt (encrypts the input), Sign (Encrypts and Signs the input), Decrypt (Decrypts the input), Verify (Decrypts and verifies the input)"}) void setAction(String action); @IbisDoc({"Recipients to be used during encryption stage. If multiple, separate with ';' (semicolon)"}) void setRecipients(String recipients); @IbisDoc({"Emails of the senders. This will be used to verify that all the senders have signed the given message. " + "If not set, and the action is verify; this pipe will validate that at least one person has signed. " + "For signing action, it needs to be set to the email that was used to generate the private key " + "that is being used for this process."}) void setVerificationAddresses(String verificationAddresses); @IbisDoc({"Path to the private key. It will be used when signing or decrypting."}) void setSecretKey(String secretKey); @IbisDoc({"Password for the private key."}) void setSecretPassword(String secretPassword); @IbisDoc({"Path to the recipient's key. It will be used for encryption and verification."}) void setPublicKeys(String publicKeys);  }
@Test public void dotest() throws Throwable { try { configurePipe(encryptPipe, encryptParams); configurePipe(decryptPipe, decryptParams); Message encryptMessage = new Message(MESSAGE); PipeRunResult encryptionResult = encryptPipe.doPipe(encryptMessage, session); String mid = new String((byte[]) encryptionResult.getResult().asObject()); assertMessage(mid, MESSAGE); Message decryptMessage = Message.asMessage(encryptionResult.getResult()); PipeRunResult decryptionResult = decryptPipe.doPipe(decryptMessage, session); byte[] result = (byte[]) decryptionResult.getResult().asObject(); Assert.assertEquals(MESSAGE, new String(result)); Assert.assertEquals("success", expectation); } catch (Exception e) { if (checkExceptionClass(e, expectation)) { Assert.assertTrue(true); } else { throw e; } } }