Search in sources :

Example 6 with GridSslBasicContextFactory

use of org.apache.ignite.internal.client.ssl.GridSslBasicContextFactory in project ignite by apache.

the class CommandHandler method createSslSupportFactory.

/**
 * @param args Commond args.
 * @return Ssl support factory.
 */
@NotNull
private GridSslBasicContextFactory createSslSupportFactory(ConnectionAndSslParameters args) {
    GridSslBasicContextFactory factory = new GridSslBasicContextFactory();
    List<String> sslProtocols = split(args.sslProtocol(), ",");
    String sslProtocol = F.isEmpty(sslProtocols) ? DFLT_SSL_PROTOCOL : sslProtocols.get(0);
    factory.setProtocol(sslProtocol);
    factory.setKeyAlgorithm(args.sslKeyAlgorithm());
    if (sslProtocols.size() > 1)
        factory.setProtocols(sslProtocols);
    factory.setCipherSuites(split(args.getSslCipherSuites(), ","));
    factory.setKeyStoreFilePath(args.sslKeyStorePath());
    if (args.sslKeyStorePassword() != null)
        factory.setKeyStorePassword(args.sslKeyStorePassword());
    else {
        char[] keyStorePwd = requestPasswordFromConsole("SSL keystore password: ");
        args.sslKeyStorePassword(keyStorePwd);
        factory.setKeyStorePassword(keyStorePwd);
    }
    factory.setKeyStoreType(args.sslKeyStoreType());
    if (F.isEmpty(args.sslTrustStorePath()))
        factory.setTrustManagers(GridSslBasicContextFactory.getDisabledTrustManager());
    else {
        factory.setTrustStoreFilePath(args.sslTrustStorePath());
        if (args.sslTrustStorePassword() != null)
            factory.setTrustStorePassword(args.sslTrustStorePassword());
        else {
            char[] trustStorePwd = requestPasswordFromConsole("SSL truststore password: ");
            args.sslTrustStorePassword(trustStorePwd);
            factory.setTrustStorePassword(trustStorePwd);
        }
        factory.setTrustStoreType(args.sslTrustStoreType());
    }
    return factory;
}
Also used : GridSslBasicContextFactory(org.apache.ignite.internal.client.ssl.GridSslBasicContextFactory) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GridSslBasicContextFactory (org.apache.ignite.internal.client.ssl.GridSslBasicContextFactory)6 NotNull (org.jetbrains.annotations.NotNull)2 ArrayList (java.util.ArrayList)1 ConnectorConfiguration (org.apache.ignite.configuration.ConnectorConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 GridClientRoundRobinBalancer (org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer)1 GridClientImpl (org.apache.ignite.internal.client.impl.GridClientImpl)1 SecurityCredentials (org.apache.ignite.plugin.security.SecurityCredentials)1 SecurityCredentialsBasicProvider (org.apache.ignite.plugin.security.SecurityCredentialsBasicProvider)1