Search in sources :

Example 1 with J2EEKeyManager

use of com.sun.enterprise.security.ssl.J2EEKeyManager in project Payara by payara.

the class IIOPSSLUtilImpl method getKeyManagers.

@Override
public KeyManager[] getKeyManagers(String alias) {
    KeyManager[] mgrs = null;
    try {
        if (alias != null && !sslUtils.isTokenKeyAlias(alias)) {
            throw new IllegalStateException(getFormatMessage("iiop.cannot_find_keyalias", new Object[] { alias }));
        }
        mgrs = sslUtils.getKeyManagers();
        if (alias != null && mgrs != null && mgrs.length > 0) {
            KeyManager[] newMgrs = new KeyManager[mgrs.length];
            for (int i = 0; i < mgrs.length; i++) {
                if (_logger.isLoggable(Level.FINE)) {
                    StringBuffer msg = new StringBuffer("Setting J2EEKeyManager for ");
                    msg.append(" alias : " + alias);
                    _logger.log(Level.FINE, msg.toString());
                }
                newMgrs[i] = new J2EEKeyManager((X509KeyManager) mgrs[i], alias);
            }
            mgrs = newMgrs;
        }
    } catch (Exception e) {
        // TODO: log here
        throw new RuntimeException(e);
    }
    return mgrs;
}
Also used : X509KeyManager(javax.net.ssl.X509KeyManager) J2EEKeyManager(com.sun.enterprise.security.ssl.J2EEKeyManager) X509KeyManager(javax.net.ssl.X509KeyManager) KeyManager(javax.net.ssl.KeyManager) J2EEKeyManager(com.sun.enterprise.security.ssl.J2EEKeyManager)

Example 2 with J2EEKeyManager

use of com.sun.enterprise.security.ssl.J2EEKeyManager in project Payara by payara.

the class SSLSocketFactory method initStoresAtStartup.

// V3: to break dependency of SSLUtils on this class
// public static void setManagers(KeyManager[] kmgrs, TrustManager[] tmgrs) {
// keyManagers = kmgrs;
// trustManagers = tmgrs;
// }
// V3: Copied from SSLUtils to break dependency of SSLUtils on this class
public static synchronized void initStoresAtStartup() throws Exception {
    if (initialized) {
        return;
    }
    ServiceLocator habitat = Globals.getDefaultHabitat();
    SSLUtils sslUtils = habitat.getService(SSLUtils.class);
    keyManagers = sslUtils.getKeyManagers();
    trustManagers = sslUtils.getTrustManagers();
    // Creating a default SSLContext and HttpsURLConnection for clients
    // that use Https
    SSLContext ctx = SSLContext.getInstance("TLS");
    String keyAlias = System.getProperty(SSLUtils.HTTPS_OUTBOUND_KEY_ALIAS);
    KeyManager[] kMgrs = sslUtils.getKeyManagers();
    if (keyAlias != null && keyAlias.length() > 0 && kMgrs != null) {
        for (int i = 0; i < kMgrs.length; i++) {
            kMgrs[i] = new J2EEKeyManager((X509KeyManager) kMgrs[i], keyAlias);
        }
    }
    ctx.init(kMgrs, sslUtils.getTrustManagers(), null);
    HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
    initialized = true;
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) X509KeyManager(javax.net.ssl.X509KeyManager) SSLContext(javax.net.ssl.SSLContext) J2EEKeyManager(com.sun.enterprise.security.ssl.J2EEKeyManager) X509KeyManager(javax.net.ssl.X509KeyManager) KeyManager(javax.net.ssl.KeyManager) J2EEKeyManager(com.sun.enterprise.security.ssl.J2EEKeyManager) SSLUtils(com.sun.enterprise.security.ssl.SSLUtils)

Aggregations

J2EEKeyManager (com.sun.enterprise.security.ssl.J2EEKeyManager)2 KeyManager (javax.net.ssl.KeyManager)2 X509KeyManager (javax.net.ssl.X509KeyManager)2 SSLUtils (com.sun.enterprise.security.ssl.SSLUtils)1 SSLContext (javax.net.ssl.SSLContext)1 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)1