Search in sources :

Example 11 with SslContextFactory

use of org.apache.ignite.ssl.SslContextFactory in project cas by apereo.

the class IgniteTicketRegistryConfiguration method buildSecureTransportForIgniteConfiguration.

protected static SslContextFactory buildSecureTransportForIgniteConfiguration(final CasConfigurationProperties casProperties) {
    val properties = casProperties.getTicket().getRegistry().getIgnite();
    val nullKey = "NULL";
    if (StringUtils.hasText(properties.getKeyStoreFilePath()) && StringUtils.hasText(properties.getKeyStorePassword()) && StringUtils.hasText(properties.getTrustStoreFilePath()) && StringUtils.hasText(properties.getTrustStorePassword())) {
        val sslContextFactory = new SslContextFactory();
        sslContextFactory.setKeyStoreFilePath(properties.getKeyStoreFilePath());
        sslContextFactory.setKeyStorePassword(properties.getKeyStorePassword().toCharArray());
        if (nullKey.equals(properties.getTrustStoreFilePath()) && nullKey.equals(properties.getTrustStorePassword())) {
            sslContextFactory.setTrustManagers(SslContextFactory.getDisabledTrustManager());
        } else {
            sslContextFactory.setTrustStoreFilePath(properties.getTrustStoreFilePath());
            sslContextFactory.setTrustStorePassword(properties.getTrustStorePassword().toCharArray());
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(properties.getKeyAlgorithm())) {
            sslContextFactory.setKeyAlgorithm(properties.getKeyAlgorithm());
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(properties.getProtocol())) {
            sslContextFactory.setProtocol(properties.getProtocol());
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(properties.getTrustStoreType())) {
            sslContextFactory.setTrustStoreType(properties.getTrustStoreType());
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(properties.getKeyStoreType())) {
            sslContextFactory.setKeyStoreType(properties.getKeyStoreType());
        }
        return sslContextFactory;
    }
    return null;
}
Also used : lombok.val(lombok.val) SslContextFactory(org.apache.ignite.ssl.SslContextFactory)

Example 12 with SslContextFactory

use of org.apache.ignite.ssl.SslContextFactory in project ignite by apache.

the class NodeSslConnectionMetricTest method sslContextFactory.

/**
 * Creates {@link SslContextFactory} with specified options.
 */
private SslContextFactory sslContextFactory(String keyStore, String trustStore, String cipherSuite, String protocol) {
    SslContextFactory res = (SslContextFactory) sslTrustedFactory(keyStore, trustStore);
    if (cipherSuite != null)
        res.setCipherSuites(cipherSuite);
    res.setProtocols(protocol);
    return res;
}
Also used : SslContextFactory(org.apache.ignite.ssl.SslContextFactory)

Example 13 with SslContextFactory

use of org.apache.ignite.ssl.SslContextFactory in project ignite by apache.

the class ClientSslParametersTest method createSslFactory.

/**
 * @return SSL factory.
 */
@NotNull
private SslContextFactory createSslFactory() {
    SslContextFactory factory = (SslContextFactory) GridTestUtils.sslFactory();
    factory.setCipherSuites(cipherSuites);
    factory.setProtocols(protocols);
    return factory;
}
Also used : SslContextFactory(org.apache.ignite.ssl.SslContextFactory) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with SslContextFactory

use of org.apache.ignite.ssl.SslContextFactory in project ignite by apache.

the class Security method ssl.

@Test
void ssl() {
    // tag::ssl-context-factory[]
    IgniteConfiguration igniteCfg = new IgniteConfiguration();
    SslContextFactory factory = new SslContextFactory();
    factory.setKeyStoreFilePath("keystore/node.jks");
    factory.setKeyStorePassword("123456".toCharArray());
    factory.setTrustStoreFilePath("keystore/trust.jks");
    factory.setTrustStorePassword("123456".toCharArray());
    factory.setProtocol("TLSv1.3");
    igniteCfg.setSslContextFactory(factory);
    // end::ssl-context-factory[]
    Ignition.start(igniteCfg).close();
}
Also used : SslContextFactory(org.apache.ignite.ssl.SslContextFactory) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Test(org.junit.jupiter.api.Test)

Example 15 with SslContextFactory

use of org.apache.ignite.ssl.SslContextFactory in project ignite by apache.

the class JdbcThinConnectionAdditionalSecurityTest method getTestSslContextFactory.

/**
 * @return Test SSL context factory.
 */
private static Factory<SSLContext> getTestSslContextFactory() {
    SslContextFactory factory = new SslContextFactory();
    factory.setKeyStoreFilePath(SRV_KEY_STORE_PATH);
    factory.setKeyStorePassword("123456".toCharArray());
    factory.setTrustStoreFilePath(TRUST_KEY_STORE_PATH);
    factory.setTrustStorePassword("123456".toCharArray());
    return factory;
}
Also used : SslContextFactory(org.apache.ignite.ssl.SslContextFactory)

Aggregations

SslContextFactory (org.apache.ignite.ssl.SslContextFactory)21 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)6 NotNull (org.jetbrains.annotations.NotNull)4 ClientConnectorConfiguration (org.apache.ignite.configuration.ClientConnectorConfiguration)3 SSLContext (javax.net.ssl.SSLContext)2 GridSslContextFactory (org.apache.ignite.internal.client.ssl.GridSslContextFactory)2 Before (org.junit.Before)2 Test (org.junit.jupiter.api.Test)2 Paths (java.nio.file.Paths)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 SQLException (java.sql.SQLException)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 ExecutionException (java.util.concurrent.ExecutionException)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Factory (javax.cache.configuration.Factory)1 SSLException (javax.net.ssl.SSLException)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1 ToString (lombok.ToString)1 lombok.val (lombok.val)1