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); } }
/** * Return the certificate chain for the specified alias. * @param the alias. * @return the chain of X509 Certificates. */ public X509Certificate[] getCertificateChain(String alias) { if(_logger.isLoggable(Level.FINE)){ _logger.log(Level.FINE,"Getting certificate chain"); } X509KeyManager keyMgr = getManagerFromToken(alias); if (keyMgr != null) { String aliasName = alias.substring(alias.indexOf(':') + 1); return keyMgr.getCertificateChain(aliasName); } else { return mgr.getCertificateChain(alias); } }
if(!isAppClientContainer()) { doClientLogin(SecurityConstants.APPCONTAINER_CERTIFICATE, habitat.getComponent(SecuritySupport.class).getAppContainerCallbackHandler()); s = ctx.getSubject();
new Object[]{user, realm}); setClientSecurityContext(user, fs); return; } else if (obj instanceof X509CertificateCredential){ new Object[]{user, realm}); setClientSecurityContext(user, fs); return;
doClientLogin(SecurityConstants.CERTIFICATE, Util.getInstance().getCallbackHandler()); s = ctx.getSubject();
postClientAuth(subject, PasswordCredential.class); return subject; } else if (type == SecurityConstants.CERTIFICATE){ postClientAuth(subject, X509CertificateCredential.class); return subject; } else if (type == SecurityConstants.ALL){
new Object[]{user, realm}); setClientSecurityContext(user, fs); return; } else if (obj instanceof X509CertificateCredential){ new Object[]{user, realm}); setClientSecurityContext(user, fs); return;
doClientLogin(SecurityConstants.CERTIFICATE, Util.getInstance().getCallbackHandler()); s = ctx.getSubject();
postClientAuth(subject, PasswordCredential.class); return subject; } else if (type == SecurityConstants.CERTIFICATE){ postClientAuth(subject, X509CertificateCredential.class); return subject; } else if (type == SecurityConstants.ALL){
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); } }
/** * Return the certificate chain for the specified alias. * @param the alias. * @return the chain of X509 Certificates. */ public X509Certificate[] getCertificateChain(String alias) { if(_logger.isLoggable(Level.FINE)){ _logger.log(Level.FINE,"Getting certificate chain"); } X509KeyManager keyMgr = getManagerFromToken(alias); if (keyMgr != null) { String aliasName = alias.substring(alias.indexOf(':') + 1); return keyMgr.getCertificateChain(aliasName); } else { return mgr.getCertificateChain(alias); } }
user +" realm :" + realm); setClientSecurityContext(user, fs); return; } else if (obj instanceof X509CertificateCredential){ user +" realm :" + realm); setClientSecurityContext(user, fs); return;
@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; }
/** * Return the private key for the specified alias. * @param the alias. * @return the private key. */ public PrivateKey getPrivateKey(String alias) { if(_logger.isLoggable(Level.FINE)){ _logger.log(Level.FINE, "Getting private key for alias:{0}", alias); } X509KeyManager keyMgr = getManagerFromToken(alias); if (keyMgr != null) { String aliasName = alias.substring(alias.indexOf(':') + 1); return keyMgr.getPrivateKey(aliasName); } else { return mgr.getPrivateKey(alias); } }
@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; }
/** * Return the private key for the specified alias. * @param the alias. * @return the private key. */ public PrivateKey getPrivateKey(String alias) { if(_logger.isLoggable(Level.FINE)){ _logger.log(Level.FINE, "Getting private key for alias:{0}", alias); } X509KeyManager keyMgr = getManagerFromToken(alias); if (keyMgr != null) { String aliasName = alias.substring(alias.indexOf(':') + 1); return keyMgr.getPrivateKey(aliasName); } else { return mgr.getPrivateKey(alias); } }
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; }
/** * Return the private key for the specified alias. * @param the alias. * @return the private key. */ public PrivateKey getPrivateKey(String alias) { if(_logger.isLoggable(Level.FINE)){ _logger.log(Level.FINE,"Getting private key for alias:" + alias); } X509KeyManager keyMgr = getManagerFromToken(alias); if (keyMgr != null) { String aliasName = alias.substring(alias.indexOf(':') + 1); return keyMgr.getPrivateKey(aliasName); } else { return mgr.getPrivateKey(alias); } }
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; }
/** * Return the certificate chain for the specified alias. * @param the alias. * @return the chain of X509 Certificates. */ public X509Certificate[] getCertificateChain(String alias) { if(_logger.isLoggable(Level.FINE)){ _logger.log(Level.FINE,"Getting certificate chain"); } X509KeyManager keyMgr = getManagerFromToken(alias); if (keyMgr != null) { String aliasName = alias.substring(alias.indexOf(':') + 1); return keyMgr.getCertificateChain(aliasName); } else { return mgr.getCertificateChain(alias); } }