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;
}
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;
}
Aggregations