Search in sources :

Example 1 with SSLEngineFactory

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;
}
Also used : SSLContext(javax.net.ssl.SSLContext) SSLEngineFactory(org.apache.camel.component.netty.ssl.SSLEngineFactory)

Example 2 with SSLEngineFactory

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;
}
Also used : SSLContext(javax.net.ssl.SSLContext) SSLEngineFactory(org.apache.camel.component.netty.ssl.SSLEngineFactory)

Example 3 with SSLEngineFactory

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;
}
Also used : NettyConfiguration(org.apache.camel.component.netty.NettyConfiguration) SSLContext(javax.net.ssl.SSLContext) SSLEngineFactory(org.apache.camel.component.netty.ssl.SSLEngineFactory)

Example 4 with SSLEngineFactory

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;
}
Also used : SSLContext(javax.net.ssl.SSLContext) SSLEngineFactory(org.apache.camel.component.netty.ssl.SSLEngineFactory)

Example 5 with SSLEngineFactory

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;
}
Also used : SSLContext(javax.net.ssl.SSLContext) SSLEngineFactory(org.apache.camel.component.netty.ssl.SSLEngineFactory)

Aggregations

SSLContext (javax.net.ssl.SSLContext)5 SSLEngineFactory (org.apache.camel.component.netty.ssl.SSLEngineFactory)5 NettyConfiguration (org.apache.camel.component.netty.NettyConfiguration)1