Search in sources :

Example 81 with RouteBuilder

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

the class XMLSecurityDataFormatTest method testPartialPayloadXMLElementDecryptionWithKey.

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

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

Example 82 with RouteBuilder

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

the class XMLSecurityDataFormatTest method testPartialPayloadAsymmetricKeyDecryptionCustomNS.

@Test
public void testPartialPayloadAsymmetricKeyDecryptionCustomNS() throws Exception {
    final KeyStoreParameters tsParameters = new KeyStoreParameters();
    tsParameters.setPassword("password");
    tsParameters.setResource("sender.ts");
    final KeyStoreParameters ksParameters = new KeyStoreParameters();
    ksParameters.setPassword("password");
    ksParameters.setResource("recipient.ks");
    final Map<String, String> namespaces = new HashMap<String, String>();
    namespaces.put("cust", "http://cheese.xmlsecurity.camel.apache.org/");
    context.addRoutes(new RouteBuilder() {

        public void configure() {
            from("direct:start").marshal().secureXML("//cust:cheesesites/italy", namespaces, true, "recipient", testCypherAlgorithm, XMLCipher.RSA_v1dot5, tsParameters).to("mock:encrypted").unmarshal().secureXML("//cust:cheesesites/italy", namespaces, true, "recipient", testCypherAlgorithm, XMLCipher.RSA_v1dot5, ksParameters).to("mock:decrypted");
        }
    });
    xmlsecTestHelper.testDecryption(TestHelper.NS_XML_FRAGMENT, context);
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) HashMap(java.util.HashMap) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) Test(org.junit.Test)

Example 83 with RouteBuilder

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

the class XMLSecurityDataFormatTest method testPartialPayloadXMLElementEncryptionWithKey.

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

        public void configure() {
            from("direct:start").marshal().secureXML("//cheesesites/france/cheese", false, "Just another 24 Byte key").to("mock:encrypted");
        }
    });
    xmlsecTestHelper.testEncryption(context);
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test)

Example 84 with RouteBuilder

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

the class XMLSecurityDataFormatTest method testPartialPayloadXMLElementEncryptionWithKeyAndAlgorithm.

@Test
public void testPartialPayloadXMLElementEncryptionWithKeyAndAlgorithm() 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/netherlands", false, passCode, XMLCipher.AES_128).to("mock:encrypted");
        }
    });
    xmlsecTestHelper.testEncryption(context);
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test)

Example 85 with RouteBuilder

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

the class EncryptionAlgorithmTest method testRSAOAEP11KW.

@Test
public void testRSAOAEP11KW() throws Exception {
    final XMLSecurityDataFormat sendingDataFormat = new XMLSecurityDataFormat();
    sendingDataFormat.setSecureTagContents(true);
    sendingDataFormat.setSecureTag("//cheesesites/italy/cheese");
    sendingDataFormat.setXmlCipherAlgorithm(XMLCipher.AES_128);
    sendingDataFormat.setKeyCipherAlgorithm(XMLCipher.RSA_OAEP_11);
    sendingDataFormat.setRecipientKeyAlias("recipient");
    KeyStoreParameters tsParameters = new KeyStoreParameters();
    tsParameters.setPassword("password");
    tsParameters.setResource("sender.ts");
    sendingDataFormat.setKeyOrTrustStoreParameters(tsParameters);
    final XMLSecurityDataFormat receivingDataFormat = new XMLSecurityDataFormat();
    receivingDataFormat.setKeyCipherAlgorithm(XMLCipher.RSA_OAEP_11);
    receivingDataFormat.setRecipientKeyAlias("recipient");
    receivingDataFormat.setSecureTag("//cheesesites/italy/cheese");
    KeyStoreParameters ksParameters = new KeyStoreParameters();
    ksParameters.setPassword("password");
    ksParameters.setResource("recipient.ks");
    receivingDataFormat.setKeyOrTrustStoreParameters(ksParameters);
    context.addRoutes(new RouteBuilder() {

        public void configure() {
            from("direct:start").marshal(sendingDataFormat).to("mock:encrypted").log("Body: + ${body}").unmarshal(receivingDataFormat).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)

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