Search in sources :

Example 1 with SSLClientConfigurator

use of org.glassfish.admin.mbeanserver.ssl.SSLClientConfigurator in project Payara by payara.

the class RMIConnectorStarter method getClientSocketFactory.

/**
 * This method sets up an environment based on passed in SSL configuration
 *
 * @param sslConfig
 * @return SslRMIClientSocketFactory
 */
private SslRMIClientSocketFactory getClientSocketFactory(Ssl sslConfig) {
    // create SSLParams
    SSLParams sslParams = convertToSSLParams(sslConfig);
    // configure the context using these params
    SSLClientConfigurator sslCC = SSLClientConfigurator.getInstance();
    sslCC.setSSLParams(sslParams);
    SSLContext sslContext = sslCC.configure(sslParams);
    // Now pass this context to the ClientSocketFactory
    Security.setProperty("ssl.SocketFactory.provider", sslContext.getClass().getName());
    String enabledProtocols = sslCC.getEnabledProtocolsAsString();
    if (enabledProtocols != null) {
        System.setProperty("javax.rmi.ssl.client.enabledProtocols", enabledProtocols);
    }
    String enabledCipherSuites = sslCC.getEnabledCipherSuitesAsString();
    if (enabledCipherSuites != null) {
        System.setProperty("javax.rmi.ssl.client.enabledCipherSuites", enabledCipherSuites);
    }
    // The keystore and truststore locations are already available as System properties
    // Hence we just add the passwords
    System.setProperty("javax.net.ssl.keyStorePassword", sslParams.getKeyStorePassword() == null ? "changeit" : sslParams.getKeyStorePassword());
    System.setProperty("javax.net.ssl.trustStorePassword", sslParams.getTrustStorePassword() == null ? "changeit" : sslParams.getTrustStorePassword());
    SslRMIClientSocketFactory sslRMICsf = new SslRMIClientSocketFactory();
    return sslRMICsf;
}
Also used : SslRMIClientSocketFactory(javax.rmi.ssl.SslRMIClientSocketFactory) SSLParams(org.glassfish.admin.mbeanserver.ssl.SSLParams) SSLContext(javax.net.ssl.SSLContext) SSLClientConfigurator(org.glassfish.admin.mbeanserver.ssl.SSLClientConfigurator)

Aggregations

SSLContext (javax.net.ssl.SSLContext)1 SslRMIClientSocketFactory (javax.rmi.ssl.SslRMIClientSocketFactory)1 SSLClientConfigurator (org.glassfish.admin.mbeanserver.ssl.SSLClientConfigurator)1 SSLParams (org.glassfish.admin.mbeanserver.ssl.SSLParams)1