Search in sources :

Example 1 with SSLEngineFactory

use of org.apache.camel.component.netty4.ssl.SSLEngineFactory in project camel by apache.

the class DefaultClientInitializerFactory 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.netty4.ssl.SSLEngineFactory)

Example 2 with SSLEngineFactory

use of org.apache.camel.component.netty4.ssl.SSLEngineFactory in project camel by apache.

the class DefaultServerInitializerFactory 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.netty4.ssl.SSLEngineFactory)

Example 3 with SSLEngineFactory

use of org.apache.camel.component.netty4.ssl.SSLEngineFactory in project camel by apache.

the class HttpClientInitializerFactory 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.netty4.NettyConfiguration) SSLContext(javax.net.ssl.SSLContext) SSLEngineFactory(org.apache.camel.component.netty4.ssl.SSLEngineFactory)

Example 4 with SSLEngineFactory

use of org.apache.camel.component.netty4.ssl.SSLEngineFactory in project camel by apache.

the class HttpServerInitializerFactory 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.netty4.ssl.SSLEngineFactory)

Example 5 with SSLEngineFactory

use of org.apache.camel.component.netty4.ssl.SSLEngineFactory in project camel by apache.

the class HttpServerSharedInitializerFactory 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.netty4.ssl.SSLEngineFactory)

Aggregations

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