use of org.apache.camel.util.jsse.KeyManagersParameters in project camel by apache.
the class WssProducerTest method defineSSLContextServerParameters.
private static SSLContextParameters defineSSLContextServerParameters() {
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("jsse/localhost.ks");
ksp.setPassword(PW);
KeyManagersParameters kmp = new KeyManagersParameters();
kmp.setKeyPassword(PW);
kmp.setKeyStore(ksp);
TrustManagersParameters tmp = new TrustManagersParameters();
tmp.setKeyStore(ksp);
// NOTE: Needed since the client uses a loose trust configuration when no ssl context
// is provided. We turn on WANT client-auth to prefer using authentication
SSLContextServerParameters scsp = new SSLContextServerParameters();
scsp.setClientAuthentication(ClientAuthentication.WANT.name());
SSLContextParameters sslContextParameters = new SSLContextParameters();
sslContextParameters.setKeyManagers(kmp);
sslContextParameters.setTrustManagers(tmp);
sslContextParameters.setServerParameters(scsp);
return sslContextParameters;
}
use of org.apache.camel.util.jsse.KeyManagersParameters in project camel by apache.
the class ExplicitHttpsSslContextParametersRouteTest method createSslSocketConnector.
// START SNIPPET: e2
private Connector createSslSocketConnector(CamelContext context, int port) throws Exception {
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
ksp.setPassword(pwd);
KeyManagersParameters kmp = new KeyManagersParameters();
kmp.setKeyPassword(pwd);
kmp.setKeyStore(ksp);
SSLContextParameters sslContextParameters = new SSLContextParameters();
sslContextParameters.setKeyManagers(kmp);
//return sslSocketConnector;
return null;
}
use of org.apache.camel.util.jsse.KeyManagersParameters in project camel by apache.
the class HttpsRouteSslContextParametersInComponentTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws URISyntaxException {
JettyHttpComponent jetty = getContext().getComponent("jetty", JettyHttpComponent.class);
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
ksp.setPassword(pwd);
KeyManagersParameters kmp = new KeyManagersParameters();
kmp.setKeyPassword(pwd);
kmp.setKeyStore(ksp);
SSLContextParameters sslContextParameters = new SSLContextParameters();
sslContextParameters.setKeyManagers(kmp);
jetty.setSslContextParameters(sslContextParameters);
// NOTE: These are here to check that they are properly ignored.
setSSLProps(jetty, "", "asdfasdfasdfdasfs", "sadfasdfasdfas");
from("jetty:https://localhost:" + port1 + "/test").to("mock:a");
Processor proc = new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getOut().setBody("<b>Hello World</b>");
}
};
from("jetty:https://localhost:" + port1 + "/hello").process(proc);
from("jetty:https://localhost:" + port2 + "/test").to("mock:b");
}
};
}
use of org.apache.camel.util.jsse.KeyManagersParameters in project camel by apache.
the class HttpsRouteSslContextParametersInUriTest method createRegistry.
@Override
protected JndiRegistry createRegistry() throws Exception {
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
ksp.setPassword(pwd);
KeyManagersParameters kmp = new KeyManagersParameters();
kmp.setKeyPassword(pwd);
kmp.setKeyStore(ksp);
SSLContextParameters sslContextParameters = new SSLContextParameters();
sslContextParameters.setKeyManagers(kmp);
JndiRegistry registry = super.createRegistry();
registry.bind("sslContextParameters", sslContextParameters);
return registry;
}
use of org.apache.camel.util.jsse.KeyManagersParameters in project camel by apache.
the class KafkaConfiguration method applySslConfiguration.
/**
* Uses the standard camel {@link SSLContextParameters} object to fill the Kafka SSL properties
*
* @param props Kafka properties
* @param sslContextParameters SSL configuration
*/
private void applySslConfiguration(Properties props, SSLContextParameters sslContextParameters) {
if (sslContextParameters != null) {
addPropertyIfNotNull(props, SslConfigs.SSL_PROTOCOL_CONFIG, sslContextParameters.getSecureSocketProtocol());
addPropertyIfNotNull(props, SslConfigs.SSL_PROVIDER_CONFIG, sslContextParameters.getProvider());
CipherSuitesParameters cipherSuites = sslContextParameters.getCipherSuites();
if (cipherSuites != null) {
addCommaSeparatedList(props, SslConfigs.SSL_CIPHER_SUITES_CONFIG, cipherSuites.getCipherSuite());
}
SecureSocketProtocolsParameters secureSocketProtocols = sslContextParameters.getSecureSocketProtocols();
if (secureSocketProtocols != null) {
addCommaSeparatedList(props, SslConfigs.SSL_ENABLED_PROTOCOLS_CONFIG, secureSocketProtocols.getSecureSocketProtocol());
}
KeyManagersParameters keyManagers = sslContextParameters.getKeyManagers();
if (keyManagers != null) {
addPropertyIfNotNull(props, SslConfigs.SSL_KEYMANAGER_ALGORITHM_CONFIG, keyManagers.getAlgorithm());
addPropertyIfNotNull(props, SslConfigs.SSL_KEY_PASSWORD_CONFIG, keyManagers.getKeyPassword());
KeyStoreParameters keyStore = keyManagers.getKeyStore();
if (keyStore != null) {
addPropertyIfNotNull(props, SslConfigs.SSL_KEYSTORE_TYPE_CONFIG, keyStore.getType());
addPropertyIfNotNull(props, SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, keyStore.getResource());
addPropertyIfNotNull(props, SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, keyStore.getPassword());
}
}
TrustManagersParameters trustManagers = sslContextParameters.getTrustManagers();
if (trustManagers != null) {
addPropertyIfNotNull(props, SslConfigs.SSL_TRUSTMANAGER_ALGORITHM_CONFIG, trustManagers.getAlgorithm());
KeyStoreParameters keyStore = trustManagers.getKeyStore();
if (keyStore != null) {
addPropertyIfNotNull(props, SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG, keyStore.getType());
addPropertyIfNotNull(props, SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, keyStore.getResource());
addPropertyIfNotNull(props, SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, keyStore.getPassword());
}
}
}
}
Aggregations