Java Code Examples for org.glassfish.jersey.SslConfigurator#securityProtocol()

The following examples show how to use org.glassfish.jersey.SslConfigurator#securityProtocol() . 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: AbstractRestClient.java    From hugegraph-common with Apache License 2.0 7 votes vote down vote up
private static Client wrapTrustConfig(String url, ClientConfig config) {
    SslConfigurator sslConfig = SslConfigurator.newInstance();
    String trustStoreFile = config.getProperty("trustStoreFile").toString();
    String trustStorePassword = config.getProperty("trustStorePassword")
                                      .toString();
    sslConfig.trustStoreFile(trustStoreFile)
             .trustStorePassword(trustStorePassword);
    sslConfig.securityProtocol("SSL");
    SSLContext context = sslConfig.createSSLContext();
    TrustManager[] trustAllManager = NoCheckTrustManager.create();
    try {
        context.init(null, trustAllManager, new SecureRandom());
    } catch (KeyManagementException e) {
        throw new ClientException("Failed to init security management", e);
    }
    return ClientBuilder.newBuilder()
                        .hostnameVerifier(new HostNameVerifier(url))
                        .sslContext(context)
                        .build();
}
 
Example 2
Source File: SchemaRegistryClient.java    From registry with Apache License 2.0 6 votes vote down vote up
protected SSLContext createSSLContext(Map<String, String> sslConfigurations) {
    SslConfigurator sslConfigurator = SslConfigurator.newInstance();
    if (sslConfigurations.containsKey(SSL_KEY_STORE_PATH)) {
        sslConfigurator.keyStoreType(sslConfigurations.get("keyStoreType"))
                       .keyStoreFile(sslConfigurations.get(SSL_KEY_STORE_PATH))
                       .keyStorePassword(sslConfigurations.get("keyStorePassword"))
                       .keyStoreProvider(sslConfigurations.get("keyStoreProvider"))
                       .keyManagerFactoryAlgorithm(sslConfigurations.get("keyManagerFactoryAlgorithm"))
                       .keyManagerFactoryProvider(sslConfigurations.get("keyManagerFactoryProvider"));
        if (sslConfigurations.containsKey(SSL_KEY_PASSWORD)) {
            sslConfigurator.keyPassword(sslConfigurations.get(SSL_KEY_PASSWORD));
        }
    }


    sslConfigurator.trustStoreType(sslConfigurations.get("trustStoreType"))
                   .trustStoreFile(sslConfigurations.get("trustStorePath"))
                   .trustStorePassword(sslConfigurations.get("trustStorePassword"))
                   .trustStoreProvider(sslConfigurations.get("trustStoreProvider"))
                   .trustManagerFactoryAlgorithm(sslConfigurations.get("trustManagerFactoryAlgorithm"))
                   .trustManagerFactoryProvider(sslConfigurations.get("trustManagerFactoryProvider"));

    sslConfigurator.securityProtocol(sslConfigurations.get("protocol"));

    return sslConfigurator.createSSLContext();
}
 
Example 3
Source File: SchemaRegistryClient.java    From nifi with Apache License 2.0 6 votes vote down vote up
protected SSLContext createSSLContext(Map<String, String> sslConfigurations) {
    SslConfigurator sslConfigurator = SslConfigurator.newInstance();
    if (sslConfigurations.containsKey(SSL_KEY_STORE_PATH)) {
        sslConfigurator.keyStoreType(sslConfigurations.get("keyStoreType"))
                .keyStoreFile(sslConfigurations.get(SSL_KEY_STORE_PATH))
                .keyStorePassword(sslConfigurations.get("keyStorePassword"))
                .keyStoreProvider(sslConfigurations.get("keyStoreProvider"))
                .keyManagerFactoryAlgorithm(sslConfigurations.get("keyManagerFactoryAlgorithm"))
                .keyManagerFactoryProvider(sslConfigurations.get("keyManagerFactoryProvider"));
        if (sslConfigurations.containsKey(SSL_KEY_PASSWORD)) {
            sslConfigurator.keyPassword(sslConfigurations.get(SSL_KEY_PASSWORD));
        }
    }


    sslConfigurator.trustStoreType(sslConfigurations.get("trustStoreType"))
            .trustStoreFile(sslConfigurations.get("trustStorePath"))
            .trustStorePassword(sslConfigurations.get("trustStorePassword"))
            .trustStoreProvider(sslConfigurations.get("trustStoreProvider"))
            .trustManagerFactoryAlgorithm(sslConfigurations.get("trustManagerFactoryAlgorithm"))
            .trustManagerFactoryProvider(sslConfigurations.get("trustManagerFactoryProvider"));

    sslConfigurator.securityProtocol(sslConfigurations.get("protocol"));

    return sslConfigurator.createSSLContext();
}