use of org.apache.camel.util.jsse.KeyStoreParameters in project camel by apache.
the class XMLSecurityDataFormatTest method testAsymmetricEncryptionAlgorithmFullPayload.
@Test
public void testAsymmetricEncryptionAlgorithmFullPayload() 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");
// RSA v1.5 is not allowed unless explicitly configured
context.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start").marshal().secureXML("", true, "recipient", testCypherAlgorithm, XMLCipher.RSA_v1dot5, tsParameters).to("mock:encrypted").unmarshal().secureXML("", true, "recipient", testCypherAlgorithm, XMLCipher.RSA_OAEP, ksParameters).to("mock:decrypted");
}
});
MockEndpoint resultEndpoint = context.getEndpoint("mock:decrypted", MockEndpoint.class);
resultEndpoint.setExpectedMessageCount(0);
// verify that the message was encrypted before checking that it is decrypted
xmlsecTestHelper.testEncryption(TestHelper.XML_FRAGMENT, context);
resultEndpoint.assertIsSatisfied(100);
}
use of org.apache.camel.util.jsse.KeyStoreParameters in project camel by apache.
the class XMLSecurityDataFormatTest method testPartialPayloadAsymmetricKeyEncryptionWithExchangeRecipientAlias.
@Test
@SuppressWarnings("deprecation")
public void testPartialPayloadAsymmetricKeyEncryptionWithExchangeRecipientAlias() throws Exception {
MockEndpoint resultEndpoint = context.getEndpoint("mock:foo", MockEndpoint.class);
resultEndpoint.setExpectedMessageCount(1);
final KeyStoreParameters tsParameters = new KeyStoreParameters();
tsParameters.setPassword("password");
tsParameters.setResource("sender.ts");
context.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start").process(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(XMLSecurityDataFormat.XML_ENC_RECIPIENT_ALIAS, "recipient");
}
}).marshal().secureXML("//cheesesites/italy/cheese", true, null, testCypherAlgorithm, XMLCipher.RSA_v1dot5, tsParameters).to("mock:encrypted");
}
});
xmlsecTestHelper.testEncryption(context);
}
use of org.apache.camel.util.jsse.KeyStoreParameters 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.util.jsse.KeyStoreParameters 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);
}
use of org.apache.camel.util.jsse.KeyStoreParameters in project camel by apache.
the class EncryptionAlgorithmTest method testRSAOAEPKW.
@Test
public void testRSAOAEPKW() 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);
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);
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