Java Code Examples for org.eclipse.jetty.util.ssl.SslContextFactory#setSecureRandomAlgorithm()

The following examples show how to use org.eclipse.jetty.util.ssl.SslContextFactory#setSecureRandomAlgorithm() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SSLUtils.java    From kop with Apache License 2.0 5 votes vote down vote up
/**
 * Configures Protocol, Algorithm and Provider related settings in SslContextFactory.
 */
protected static void configureSslContextFactoryAlgorithms(SslContextFactory ssl,
                                                           Map<String, Object> sslConfigValues) {
    Set<String> sslEnabledProtocols =
        (Set<String>) getOrDefault(
            sslConfigValues,
            SslConfigs.SSL_ENABLED_PROTOCOLS_CONFIG,
            Arrays.asList(SslConfigs.DEFAULT_SSL_ENABLED_PROTOCOLS.split("\\s*,\\s*")));
    ssl.setIncludeProtocols(sslEnabledProtocols.toArray(new String[sslEnabledProtocols.size()]));

    String sslProvider = (String) sslConfigValues.get(SslConfigs.SSL_PROVIDER_CONFIG);
    if (sslProvider != null) {
        ssl.setProvider(sslProvider);
    }

    ssl.setProtocol(
        (String) getOrDefault(sslConfigValues, SslConfigs.SSL_PROTOCOL_CONFIG, SslConfigs.DEFAULT_SSL_PROTOCOL));

    Set<String> sslCipherSuites = (Set<String>) sslConfigValues.get(SslConfigs.SSL_CIPHER_SUITES_CONFIG);
    if (sslCipherSuites != null) {
        ssl.setIncludeCipherSuites(sslCipherSuites.toArray(new String[sslCipherSuites.size()]));
    }

    ssl.setKeyManagerFactoryAlgorithm((String) getOrDefault(
        sslConfigValues,
        SslConfigs.SSL_KEYMANAGER_ALGORITHM_CONFIG,
        SslConfigs.DEFAULT_SSL_KEYMANGER_ALGORITHM));

    String sslSecureRandomImpl = (String) sslConfigValues.get(SslConfigs.SSL_SECURE_RANDOM_IMPLEMENTATION_CONFIG);
    if (sslSecureRandomImpl != null) {
        ssl.setSecureRandomAlgorithm(sslSecureRandomImpl);
    }

    ssl.setTrustManagerFactoryAlgorithm((String) getOrDefault(
        sslConfigValues,
        SslConfigs.SSL_TRUSTMANAGER_ALGORITHM_CONFIG,
        SslConfigs.DEFAULT_SSL_TRUSTMANAGER_ALGORITHM));
}