use of org.apache.camel.component.netty.ssl.SSLEngineFactory in project camel by apache.
the class DefaultClientPipelineFactory method createSSLContext.
private SSLContext createSSLContext(NettyProducer producer) throws Exception {
NettyConfiguration configuration = producer.getConfiguration();
if (!configuration.isSsl()) {
return null;
}
SSLContext answer;
// create ssl context once
if (configuration.getSslContextParameters() != null) {
answer = configuration.getSslContextParameters().createSSLContext(producer.getContext());
} else {
if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
LOG.debug("keystorefile is null");
}
if (configuration.getTrustStoreFile() == null && configuration.getTrustStoreResource() == null) {
LOG.debug("truststorefile is null");
}
if (configuration.getPassphrase().toCharArray() == null) {
LOG.debug("passphrase is null");
}
SSLEngineFactory sslEngineFactory;
if (configuration.getKeyStoreFile() != null || configuration.getTrustStoreFile() != null) {
sslEngineFactory = new SSLEngineFactory();
answer = sslEngineFactory.createSSLContext(producer.getContext().getClassResolver(), configuration.getKeyStoreFormat(), configuration.getSecurityProvider(), "file:" + configuration.getKeyStoreFile().getPath(), "file:" + configuration.getTrustStoreFile().getPath(), configuration.getPassphrase().toCharArray());
} else {
sslEngineFactory = new SSLEngineFactory();
answer = sslEngineFactory.createSSLContext(producer.getContext().getClassResolver(), configuration.getKeyStoreFormat(), configuration.getSecurityProvider(), configuration.getKeyStoreResource(), configuration.getTrustStoreResource(), configuration.getPassphrase().toCharArray());
}
}
return answer;
}
use of org.apache.camel.component.netty.ssl.SSLEngineFactory in project camel by apache.
the class DefaultServerPipelineFactory method createSSLContext.
private SSLContext createSSLContext(CamelContext camelContext, NettyServerBootstrapConfiguration configuration) throws Exception {
if (!configuration.isSsl()) {
return null;
}
SSLContext answer;
// create ssl context once
if (configuration.getSslContextParameters() != null) {
answer = configuration.getSslContextParameters().createSSLContext(camelContext);
} else {
if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
LOG.debug("keystorefile is null");
}
if (configuration.getTrustStoreFile() == null && configuration.getTrustStoreResource() == null) {
LOG.debug("truststorefile is null");
}
if (configuration.getPassphrase().toCharArray() == null) {
LOG.debug("passphrase is null");
}
SSLEngineFactory sslEngineFactory;
if (configuration.getKeyStoreFile() != null || configuration.getTrustStoreFile() != null) {
sslEngineFactory = new SSLEngineFactory();
answer = sslEngineFactory.createSSLContext(camelContext.getClassResolver(), configuration.getKeyStoreFormat(), configuration.getSecurityProvider(), "file:" + configuration.getKeyStoreFile().getPath(), "file:" + configuration.getTrustStoreFile().getPath(), configuration.getPassphrase().toCharArray());
} else {
sslEngineFactory = new SSLEngineFactory();
answer = sslEngineFactory.createSSLContext(camelContext.getClassResolver(), configuration.getKeyStoreFormat(), configuration.getSecurityProvider(), configuration.getKeyStoreResource(), configuration.getTrustStoreResource(), configuration.getPassphrase().toCharArray());
}
}
return answer;
}
use of org.apache.camel.component.netty.ssl.SSLEngineFactory in project camel by apache.
the class HttpClientPipelineFactory method createSSLContext.
private SSLContext createSSLContext(NettyProducer producer) throws Exception {
NettyConfiguration configuration = producer.getConfiguration();
if (!configuration.isSsl()) {
return null;
}
SSLContext answer;
// create ssl context once
if (configuration.getSslContextParameters() != null) {
answer = configuration.getSslContextParameters().createSSLContext(producer.getContext());
} else {
if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
LOG.debug("keystorefile is null");
}
if (configuration.getTrustStoreFile() == null && configuration.getTrustStoreResource() == null) {
LOG.debug("truststorefile is null");
}
if (configuration.getPassphrase().toCharArray() == null) {
LOG.debug("passphrase is null");
}
SSLEngineFactory sslEngineFactory;
if (configuration.getKeyStoreFile() != null || configuration.getTrustStoreFile() != null) {
sslEngineFactory = new SSLEngineFactory();
answer = sslEngineFactory.createSSLContext(producer.getContext().getClassResolver(), configuration.getKeyStoreFormat(), configuration.getSecurityProvider(), "file:" + configuration.getKeyStoreFile().getPath(), "file:" + configuration.getTrustStoreFile().getPath(), configuration.getPassphrase().toCharArray());
} else {
sslEngineFactory = new SSLEngineFactory();
answer = sslEngineFactory.createSSLContext(producer.getContext().getClassResolver(), configuration.getKeyStoreFormat(), configuration.getSecurityProvider(), configuration.getKeyStoreResource(), configuration.getTrustStoreResource(), configuration.getPassphrase().toCharArray());
}
}
return answer;
}
use of org.apache.camel.component.netty.ssl.SSLEngineFactory in project camel by apache.
the class HttpServerPipelineFactory method createSSLContext.
private SSLContext createSSLContext(CamelContext camelContext, NettyServerBootstrapConfiguration configuration) throws Exception {
if (!configuration.isSsl()) {
return null;
}
SSLContext answer;
// create ssl context once
if (configuration.getSslContextParameters() != null) {
answer = configuration.getSslContextParameters().createSSLContext(camelContext);
} else {
if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
LOG.debug("keystorefile is null");
}
if (configuration.getTrustStoreFile() == null && configuration.getTrustStoreResource() == null) {
LOG.debug("truststorefile is null");
}
if (configuration.getPassphrase().toCharArray() == null) {
LOG.debug("passphrase is null");
}
SSLEngineFactory sslEngineFactory;
if (configuration.getKeyStoreFile() != null || configuration.getTrustStoreFile() != null) {
sslEngineFactory = new SSLEngineFactory();
answer = sslEngineFactory.createSSLContext(camelContext.getClassResolver(), configuration.getKeyStoreFormat(), configuration.getSecurityProvider(), "file:" + configuration.getKeyStoreFile().getPath(), "file:" + configuration.getTrustStoreFile().getPath(), configuration.getPassphrase().toCharArray());
} else {
sslEngineFactory = new SSLEngineFactory();
answer = sslEngineFactory.createSSLContext(camelContext.getClassResolver(), configuration.getKeyStoreFormat(), configuration.getSecurityProvider(), configuration.getKeyStoreResource(), configuration.getTrustStoreResource(), configuration.getPassphrase().toCharArray());
}
}
return answer;
}
use of org.apache.camel.component.netty.ssl.SSLEngineFactory in project camel by apache.
the class HttpServerSharedPipelineFactory method createSSLContext.
private SSLContext createSSLContext() throws Exception {
if (!configuration.isSsl()) {
return null;
}
SSLContext answer;
// create ssl context once
if (configuration.getSslContextParameters() != null) {
answer = configuration.getSslContextParameters().createSSLContext();
} else {
if (configuration.getKeyStoreFile() == null && configuration.getKeyStoreResource() == null) {
LOG.debug("keystorefile is null");
}
if (configuration.getTrustStoreFile() == null && configuration.getTrustStoreResource() == null) {
LOG.debug("truststorefile is null");
}
if (configuration.getPassphrase().toCharArray() == null) {
LOG.debug("passphrase is null");
}
SSLEngineFactory sslEngineFactory;
if (configuration.getKeyStoreFile() != null || configuration.getTrustStoreFile() != null) {
sslEngineFactory = new SSLEngineFactory();
answer = sslEngineFactory.createSSLContext(classResolver, configuration.getKeyStoreFormat(), configuration.getSecurityProvider(), "file:" + configuration.getKeyStoreFile().getPath(), "file:" + configuration.getTrustStoreFile().getPath(), configuration.getPassphrase().toCharArray());
} else {
sslEngineFactory = new SSLEngineFactory();
answer = sslEngineFactory.createSSLContext(classResolver, configuration.getKeyStoreFormat(), configuration.getSecurityProvider(), configuration.getKeyStoreResource(), configuration.getTrustStoreResource(), configuration.getPassphrase().toCharArray());
}
}
return answer;
}
Aggregations