public KeyManager[] getKeyManagers() throws Exception{ return getKeyManagers(null); } public KeyManager[] getKeyManagers(String algorithm) throws IOException,
public KeyManager[] getKeyManagers() throws Exception{ return getKeyManagers(null); } public KeyManager[] getKeyManagers(String algorithm) throws IOException,
public CustomSocketFactory() { Habitat habitat = Globals.getDefaultHabitat(); SSLUtils sslUtils = habitat.getComponent(SSLUtils.class); SSLContext sc = null; try { sc = SSLContext.getInstance(SSL); sc.init(sslUtils.getKeyManagers(), sslUtils.getTrustManagers(), new SecureRandom()); } catch (Exception ex) { _logger.log(Level.WARNING, "security.exception", ex); } socketFactory = sc.getSocketFactory(); }
public SSLContext getAdminSSLContext(String alias, String protocol) { try { if (protocol == null) { protocol = "TLS"; } SSLContext cntxt = SSLContext.getInstance(protocol); KeyManager[] kMgrs = getKeyManagers(); if (alias != null && alias.length() > 0 && kMgrs != null) { for (int i = 0; i < kMgrs.length; i++) { kMgrs[i] = new J2EEKeyManager((X509KeyManager)kMgrs[i], alias); } } cntxt.init(kMgrs, getTrustManagers(), null); return cntxt; } catch (Exception e) { throw new RuntimeException(e); } }
@Override protected KeyManager[] getKeyManagers(String algorithm, String keyAlias) throws Exception { if (sslUtils == null) { initSSLUtils(); } String keystoreFile = (String) attributes.get("keystore"); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Keystore file= {0}", keystoreFile); } String keystoreType = (String) attributes.get("keystoreType"); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Keystore type= {0}", keystoreType); } KeyManager[] kMgrs = sslUtils.getKeyManagers(algorithm); if (keyAlias != null && keyAlias.length() > 0 && kMgrs != null) { for (int i = 0; i < kMgrs.length; i++) { kMgrs[i] = new J2EEKeyManager((X509KeyManager) kMgrs[i], keyAlias); } } return kMgrs; }
public SSLContext getAdminSSLContext(String alias, String protocol) { try { if (protocol == null) { protocol = "TLS"; } SSLContext cntxt = SSLContext.getInstance(protocol); KeyManager[] kMgrs = getKeyManagers(); if (alias != null && alias.length() > 0 && kMgrs != null) { for (int i = 0; i < kMgrs.length; i++) { kMgrs[i] = new J2EEKeyManager((X509KeyManager)kMgrs[i], alias); } } cntxt.init(kMgrs, getTrustManagers(), null); return cntxt; } catch (Exception e) { throw new RuntimeException(e); } }
@Override protected KeyManager[] getKeyManagers(String algorithm, String keyAlias) throws Exception { if (sslUtils == null) { initSSLUtils(); } String keystoreFile = (String) attributes.get("keystore"); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Keystore file= {0}", keystoreFile); } String keystoreType = (String) attributes.get("keystoreType"); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Keystore type= {0}", keystoreType); } KeyManager[] kMgrs = sslUtils.getKeyManagers(algorithm); if (keyAlias != null && keyAlias.length() > 0 && kMgrs != null) { for (int i = 0; i < kMgrs.length; i++) { kMgrs[i] = new J2EEKeyManager((X509KeyManager) kMgrs[i], keyAlias); } } return kMgrs; }
public CustomSocketFactory() { SSLUtils sslUtils = Globals.getDefaultHabitat().getService(SSLUtils.class); SSLContext sc = null; try { sc = SSLContext.getInstance(SSL); sc.init(sslUtils.getKeyManagers(), sslUtils.getTrustManagers(), SharedSecureRandom.get()); socketFactory = sc.getSocketFactory(); } catch (Exception ex) { _logger.log(Level.WARNING, SecurityLoggerInfo.securityExceptionError, ex); } }
public CustomSocketFactory() { Habitat habitat = Globals.getDefaultHabitat(); SSLUtils sslUtils = habitat.getComponent(SSLUtils.class); SSLContext sc = null; try { sc = SSLContext.getInstance(SSL); sc.init(sslUtils.getKeyManagers(), sslUtils.getTrustManagers(), SharedSecureRandom.get()); } catch (Exception ex) { _logger.log(Level.WARNING, "security.exception", ex); } socketFactory = sc.getSocketFactory(); }
SSLContext getSSLContext(String protocol, String algorithm, String trustAlgorithm) { try { //V3:Commented to break dependency on WebTier. //The SSLSocketFactory CTOR will now take care of setting the kmgr and tmgr //SSLSocketFactory.setManagers(getKeyManagers(), getTrustManagers()); // Creating a default SSLContext and HttpsURLConnection for clients // that use Https if (protocol == null) { protocol = DEFAULT_SSL_PROTOCOL; } ctx = SSLContext.getInstance(protocol); String keyAlias = System.getProperty(HTTPS_OUTBOUND_KEY_ALIAS); KeyManager[] kMgrs = getKeyManagers(algorithm); 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, getTrustManagers(trustAlgorithm), null); HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory()); //refer issue :http://java.net/jira/browse/GLASSFISH-15369 SSLContext.setDefault(ctx); } catch (Exception e) { throw new Error(e); } return ctx; }
SSLContext getSSLContext(String protocol, String algorithm, String trustAlgorithm) { try { //V3:Commented to break dependency on WebTier. //The SSLSocketFactory CTOR will now take care of setting the kmgr and tmgr //SSLSocketFactory.setManagers(getKeyManagers(), getTrustManagers()); // Creating a default SSLContext and HttpsURLConnection for clients // that use Https if (protocol == null) { protocol = DEFAULT_SSL_PROTOCOL; } ctx = SSLContext.getInstance(protocol); String keyAlias = System.getProperty(HTTPS_OUTBOUND_KEY_ALIAS); KeyManager[] kMgrs = getKeyManagers(algorithm); 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, getTrustManagers(trustAlgorithm), null); HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory()); //refer issue :http://java.net/jira/browse/GLASSFISH-15369 SSLContext.setDefault(ctx); } catch (Exception e) { throw new Error(e); } return ctx; }
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; } public TrustManager[] getTrustManagers() {
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; } }
KeyManager[] kMgrs = getKeyManagers(); if (keyAlias != null && keyAlias.length() > 0 && kMgrs != null) { for (int i = 0; i < kMgrs.length; i++) {