Search in sources :

Example 71 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class XMLEncryption11Test method testFullPayloadAsymmetricKeyDecryptionMGF256.

@Test
public void testFullPayloadAsymmetricKeyDecryptionMGF256() throws Exception {
    final KeyStoreParameters tsParameters = new KeyStoreParameters();
    tsParameters.setPassword("password");
    tsParameters.setResource("sender.ts");
    final XMLSecurityDataFormat xmlEncDataFormat = new XMLSecurityDataFormat();
    xmlEncDataFormat.setKeyCipherAlgorithm(XMLCipher.RSA_OAEP_11);
    xmlEncDataFormat.setKeyOrTrustStoreParameters(tsParameters);
    xmlEncDataFormat.setXmlCipherAlgorithm(XMLCipher.AES_128);
    xmlEncDataFormat.setMgfAlgorithm(EncryptionConstants.MGF1_SHA256);
    xmlEncDataFormat.setRecipientKeyAlias("recipient");
    final KeyStoreParameters ksParameters = new KeyStoreParameters();
    ksParameters.setPassword("password");
    ksParameters.setResource("recipient.ks");
    context.addRoutes(new RouteBuilder() {

        public void configure() {
            from("direct:start").marshal(xmlEncDataFormat).to("mock:encrypted").unmarshal().secureXML("", new HashMap<String, String>(), true, "recipient", XMLCipher.AES_128, XMLCipher.RSA_OAEP, ksParameters).to("mock:decrypted");
        }
    });
    xmlsecTestHelper.testDecryption(context);
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) Test(org.junit.Test)

Example 72 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class XMLSecurityDataFormatTest method testPartialPayloadAsymmetricKeyEncryptionWithContextTruststoreProperties.

@SuppressWarnings("deprecation")
@Test
public void testPartialPayloadAsymmetricKeyEncryptionWithContextTruststoreProperties() throws Exception {
    final KeyStoreParameters tsParameters = new KeyStoreParameters();
    tsParameters.setPassword("password");
    tsParameters.setResource("sender.ts");
    Map<String, String> contextProps = context.getProperties();
    contextProps.put(XMLSecurityDataFormat.XML_ENC_TRUST_STORE_PASSWORD, "password");
    context.addRoutes(new RouteBuilder() {

        public void configure() {
            from("direct:start").marshal().secureXML("//cheesesites/italy/cheese", true, "recipient", testCypherAlgorithm, XMLCipher.RSA_v1dot5, tsParameters).to("mock:encrypted");
        }
    });
    xmlsecTestHelper.testEncryption(context);
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) Test(org.junit.Test)

Example 73 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class XMLSecurityDataFormatTest method testPartialPayloadXMLContentDecryption.

@Test
public void testPartialPayloadXMLContentDecryption() throws Exception {
    if (!TestHelper.HAS_3DES) {
        return;
    }
    context.addRoutes(new RouteBuilder() {

        public void configure() {
            from("direct:start").marshal().secureXML("//cheesesites/italy/cheese", true).to("mock:encrypted").unmarshal().secureXML("//cheesesites/italy/cheese", true).to("mock:decrypted");
        }
    });
    xmlsecTestHelper.testDecryption(context);
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test)

Example 74 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class XMLSecurityDataFormatTest method testPartialPayloadXMLContentDecryptionWithKeyAndAlgorithm.

@Test
public void testPartialPayloadXMLContentDecryptionWithKeyAndAlgorithm() throws Exception {
    final byte[] bits128 = { (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F, (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17 };
    final String passCode = new String(bits128);
    context.addRoutes(new RouteBuilder() {

        public void configure() {
            from("direct:start").marshal().secureXML("//cheesesites/italy", true, passCode, XMLCipher.AES_128).to("mock:encrypted").unmarshal().secureXML("//cheesesites/italy", true, passCode, XMLCipher.AES_128).to("mock:decrypted");
        }
    });
    xmlsecTestHelper.testDecryption(context);
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test)

Example 75 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class XMLSecurityDataFormatTest method testPartialPayloadXMLContentEncryption.

@Test
public void testPartialPayloadXMLContentEncryption() throws Exception {
    if (!TestHelper.HAS_3DES) {
        return;
    }
    context.addRoutes(new RouteBuilder() {

        public void configure() {
            from("direct:start").marshal().secureXML("//cheesesites/italy/cheese", true).to("mock:encrypted");
        }
    });
    xmlsecTestHelper.testEncryption(context);
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test)

Aggregations

RouteBuilder (org.apache.camel.builder.RouteBuilder)1759 Exchange (org.apache.camel.Exchange)628 Processor (org.apache.camel.Processor)545 Test (org.junit.Test)476 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)341 CamelExecutionException (org.apache.camel.CamelExecutionException)135 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)119 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)104 File (java.io.File)68 CamelContext (org.apache.camel.CamelContext)64 IOException (java.io.IOException)61 ResolveEndpointFailedException (org.apache.camel.ResolveEndpointFailedException)42 HashMap (java.util.HashMap)35 Path (org.apache.hadoop.fs.Path)34 CountDownLatch (java.util.concurrent.CountDownLatch)32 Configuration (org.apache.hadoop.conf.Configuration)32 Endpoint (org.apache.camel.Endpoint)30 ArrayFile (org.apache.hadoop.io.ArrayFile)30 SequenceFile (org.apache.hadoop.io.SequenceFile)30 RuntimeCamelException (org.apache.camel.RuntimeCamelException)26