Search in sources :

Example 1 with PayloadOutputStreamWrapper

use of com.adaptris.core.common.PayloadOutputStreamWrapper in project interlok by adaptris.

the class SymmetricKeyCryptographyServiceTest method testDoServiceEncrypt_WithSourceTarget.

@Test
public void testDoServiceEncrypt_WithSourceTarget() throws Exception {
    SymmetricKeyCryptographyService service = new SymmetricKeyCryptographyService();
    service.setAlgorithm(ALGORITHM);
    service.setCipherTransformation(CIPHER);
    service.setOperationMode(SymmetricKeyCryptographyService.OpMode.ENCRYPT);
    service.setKey(new ConstantDataInputParameter(Conversion.byteArrayToBase64String(key)));
    service.setInitialVector(new ConstantDataInputParameter(Conversion.byteArrayToBase64String(iv)));
    service.setSource(new PayloadInputStreamWrapper());
    service.setTarget(new PayloadOutputStreamWrapper());
    AdaptrisMessage message = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD);
    ServiceCase.execute(service, message);
    assertTrue(Arrays.equals(encryptedPayload, message.getPayload()));
}
Also used : PayloadOutputStreamWrapper(com.adaptris.core.common.PayloadOutputStreamWrapper) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) PayloadInputStreamWrapper(com.adaptris.core.common.PayloadInputStreamWrapper) Test(org.junit.Test)

Aggregations

AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 ConstantDataInputParameter (com.adaptris.core.common.ConstantDataInputParameter)1 PayloadInputStreamWrapper (com.adaptris.core.common.PayloadInputStreamWrapper)1 PayloadOutputStreamWrapper (com.adaptris.core.common.PayloadOutputStreamWrapper)1 Test (org.junit.Test)1