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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations