Search in sources :

Example 36 with KeyStoreParameters

use of org.apache.camel.util.jsse.KeyStoreParameters in project camel by apache.

the class LumberjackComponentSSLTest method createServerSSLContextParameters.

/**
     * Creates the {@link SSLContextParameters} Camel object for the Lumberjack component
     *
     * @return The {@link SSLContextParameters} Camel object for the Lumberjack component
     */
private SSLContextParameters createServerSSLContextParameters() {
    SSLContextParameters sslContextParameters = new SSLContextParameters();
    KeyManagersParameters keyManagersParameters = new KeyManagersParameters();
    KeyStoreParameters keyStore = new KeyStoreParameters();
    keyStore.setPassword("changeit");
    keyStore.setResource("org/apache/camel/component/lumberjack/keystore.jks");
    keyManagersParameters.setKeyPassword("changeit");
    keyManagersParameters.setKeyStore(keyStore);
    sslContextParameters.setKeyManagers(keyManagersParameters);
    return sslContextParameters;
}
Also used : KeyManagersParameters(org.apache.camel.util.jsse.KeyManagersParameters) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 37 with KeyStoreParameters

use of org.apache.camel.util.jsse.KeyStoreParameters in project camel by apache.

the class XMLSecurityDataFormatTest method testFullPayloadAsymmetricKeyDecryptionWithKeyPassword.

@Test
public void testFullPayloadAsymmetricKeyDecryptionWithKeyPassword() 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-with-key-pass.ks");
    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_v1dot5, ksParameters, "keyPassword").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 38 with KeyStoreParameters

use of org.apache.camel.util.jsse.KeyStoreParameters in project camel by apache.

the class EncryptionAlgorithmTest method testRSAv15KW.

@Test
public void testRSAv15KW() throws Exception {
    final XMLSecurityDataFormat sendingDataFormat = new XMLSecurityDataFormat();
    sendingDataFormat.setSecureTagContents(true);
    sendingDataFormat.setSecureTag("//cheesesites/italy/cheese");
    sendingDataFormat.setXmlCipherAlgorithm(XMLCipher.AES_128);
    sendingDataFormat.setKeyCipherAlgorithm(XMLCipher.RSA_v1dot5);
    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_v1dot5);
    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)

Example 39 with KeyStoreParameters

use of org.apache.camel.util.jsse.KeyStoreParameters in project camel by apache.

the class XMLEncryption11Test method testFullPayloadAsymmetricKeyEncryptionMGF256.

@Test
public void testFullPayloadAsymmetricKeyEncryptionMGF256() throws Exception {
    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");
    context.addRoutes(new RouteBuilder() {

        public void configure() {
            from("direct:start").marshal(xmlEncDataFormat).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 40 with KeyStoreParameters

use of org.apache.camel.util.jsse.KeyStoreParameters in project camel by apache.

the class XMLSecurityDataFormatTest method testFullPayloadAsymmetricKeyEncryption.

@Test
public void testFullPayloadAsymmetricKeyEncryption() throws Exception {
    KeyStoreParameters tsParameters = new KeyStoreParameters();
    tsParameters.setPassword("password");
    tsParameters.setResource("sender.ts");
    final XMLSecurityDataFormat xmlEncDataFormat = new XMLSecurityDataFormat();
    xmlEncDataFormat.setKeyCipherAlgorithm(XMLCipher.RSA_v1dot5);
    xmlEncDataFormat.setKeyOrTrustStoreParameters(tsParameters);
    xmlEncDataFormat.setXmlCipherAlgorithm(testCypherAlgorithm);
    xmlEncDataFormat.setRecipientKeyAlias("recipient");
    context.addRoutes(new RouteBuilder() {

        public void configure() {
            from("direct:start").marshal(xmlEncDataFormat).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)

Aggregations

KeyStoreParameters (org.apache.camel.util.jsse.KeyStoreParameters)57 SSLContextParameters (org.apache.camel.util.jsse.SSLContextParameters)31 KeyManagersParameters (org.apache.camel.util.jsse.KeyManagersParameters)25 RouteBuilder (org.apache.camel.builder.RouteBuilder)24 TrustManagersParameters (org.apache.camel.util.jsse.TrustManagersParameters)24 Test (org.junit.Test)21 JndiRegistry (org.apache.camel.impl.JndiRegistry)17 SSLContextServerParameters (org.apache.camel.util.jsse.SSLContextServerParameters)7 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)4 HashMap (java.util.HashMap)3 Exchange (org.apache.camel.Exchange)3 Processor (org.apache.camel.Processor)3 IOException (java.io.IOException)2 GeneralSecurityException (java.security.GeneralSecurityException)2 KeyStore (java.security.KeyStore)2 Document (org.w3c.dom.Document)2 NodeList (org.w3c.dom.NodeList)2 PrivateKey (java.security.PrivateKey)1 Signature (java.security.Signature)1 Certificate (java.security.cert.Certificate)1