Search in sources :

Example 1 with CipherSuitesParameters

use of org.apache.camel.util.jsse.CipherSuitesParameters 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());
            }
        }
    }
}
Also used : KeyManagersParameters(org.apache.camel.util.jsse.KeyManagersParameters) SecureSocketProtocolsParameters(org.apache.camel.util.jsse.SecureSocketProtocolsParameters) TrustManagersParameters(org.apache.camel.util.jsse.TrustManagersParameters) CipherSuitesParameters(org.apache.camel.util.jsse.CipherSuitesParameters) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters)

Example 2 with CipherSuitesParameters

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

the class AbstractBaseSSLContextParametersFactoryBean method createInstanceInternal.

private T createInstanceInternal() throws Exception {
    T newInstance = createInstance();
    newInstance.setCamelContext(getCamelContext());
    if (cipherSuites != null) {
        CipherSuitesParameters cipherSuitesInstance = new CipherSuitesParameters();
        cipherSuitesInstance.setCipherSuite(cipherSuites.getCipherSuite());
        newInstance.setCipherSuites(cipherSuitesInstance);
    }
    if (cipherSuitesFilter != null) {
        newInstance.setCipherSuitesFilter(createFilterParameters(cipherSuitesFilter));
    }
    if (secureSocketProtocols != null) {
        SecureSocketProtocolsParameters secureSocketProtocolsInstance = new SecureSocketProtocolsParameters();
        secureSocketProtocolsInstance.setSecureSocketProtocol(secureSocketProtocols.getSecureSocketProtocol());
        newInstance.setSecureSocketProtocols(secureSocketProtocolsInstance);
    }
    if (secureSocketProtocolsFilter != null) {
        newInstance.setSecureSocketProtocolsFilter(createFilterParameters(secureSocketProtocolsFilter));
    }
    if (sessionTimeout != null) {
        newInstance.setSessionTimeout(sessionTimeout);
    }
    return newInstance;
}
Also used : SecureSocketProtocolsParameters(org.apache.camel.util.jsse.SecureSocketProtocolsParameters) CipherSuitesParameters(org.apache.camel.util.jsse.CipherSuitesParameters)

Aggregations

CipherSuitesParameters (org.apache.camel.util.jsse.CipherSuitesParameters)2 SecureSocketProtocolsParameters (org.apache.camel.util.jsse.SecureSocketProtocolsParameters)2 KeyManagersParameters (org.apache.camel.util.jsse.KeyManagersParameters)1 KeyStoreParameters (org.apache.camel.util.jsse.KeyStoreParameters)1 TrustManagersParameters (org.apache.camel.util.jsse.TrustManagersParameters)1