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 KeyStore getKeyStore() throws IOException{ return getKeyStores()[0]; }
public KeyStore getTrustStore() throws IOException{ return getTrustStores()[0]; }
public void postConstruct() { try { initDate = new Date(); KeyStore[] keyStores = getKeyStores(); initKeyManagers(keyStores, secSupp.getKeyStorePasswords()); initTrustManagers(getTrustStores()); if (keyStores != null) { for (KeyStore keyStore : keyStores) { mergedTrustStore = mergingTrustStores(secSupp.getTrustStores()); } catch(Exception ex) { if (_logger.isLoggable(Level.FINE)) { KeyManager[] kMgrs = getKeyManagers(); if (keyAlias != null && keyAlias.length() > 0 && kMgrs != null) { for (int i = 0; i < kMgrs.length; i++) { ctx.init(kMgrs, getTrustManagers(), null);
private void initSSLUtils() { if (sslUtils == null) { if (Globals.getDefaultHabitat() != null) { sslUtils = Globals.getDefaultHabitat().getService(SSLUtils.class); } else { sslUtils = new SSLUtils(); sslUtils.postConstruct(); } } } }
public KeyManager[] getKeyManagers() throws Exception{ return getKeyManagers(null); } public KeyManager[] getKeyManagers(String algorithm) throws IOException,
secSupp = SecuritySupport.getDefaultInstance(); KeyStore[] keyStores = getKeyStores(); if (keyStores != null) { for (KeyStore keyStore : keyStores) { mergedTrustStore = mergingTrustStores(secSupp.getTrustStores()); getSSLContext(null, null, null); } catch(Exception ex) { if (_logger.isLoggable(Level.FINE)) {
public TrustManager[] getTrustManagers() throws Exception{ return getTrustManagers(null); } public TrustManager[] getTrustManagers(String algorithm) throws IOException,
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() {
checkPermission(SecuritySupport.KEYSTORE_PASS_PROP); PrivateKeyEntry privKeyEntry = null; if (certNickname != null) { int ind = certNickname.indexOf(':'); KeyStore[] kstores = getKeyStores(); int count = -1; String aliasName = certNickname;
/** * Logout the user. * * <p> This method removes the <code>PrincipalImpl</code> * that was added by the <code>commit</code> method. * * <p> * * @exception LoginException if the logout fails. * * @return true in all cases since this <code>LoginModule</code> * should not be ignored. */ public boolean logout() throws LoginException { // unset the alias ssl = null; sslUtils.setAppclientSsl(ssl); subject.getPrincipals().remove(userPrincipal); succeeded = false; succeeded = commitSucceeded; alias = null; userPrincipal = null; return true; }
public String[] getSupportedCipherSuites() { try { final SSLUtils sslUtils = mHabitat.getService(SSLUtils.class); return sslUtils.getSupportedCipherSuites(); } catch (final Exception ex) { AMXLoggerInfo.getLogger().log( Level.INFO, AMXLoggerInfo.cantGetCipherSuites, ex); return new String[0]; } }
private boolean checkProperty(String key) { if(key.equals("javax.net.ssl.keyStorePassword") || key.equals("javax.net.ssl.trustStorePassword")){ SSLUtils.checkPermission(key); } if (cacheEnabled()) { return cache.checkPermission(new PropertyPermission(key, "read")); } return false; }
private void initSSLUtils() { if (sslUtils == null) { if (Globals.getDefaultHabitat() != null) { sslUtils = Globals.getDefaultHabitat().getByType(SSLUtils.class); } else { sslUtils = new SSLUtils(); sslUtils.postConstruct(); } } } }
public KeyManager[] getKeyManagers() throws Exception{ return getKeyManagers(null); } public KeyManager[] getKeyManagers(String algorithm) throws IOException,
secSupp = SecuritySupport.getDefaultInstance(); KeyStore[] keyStores = getKeyStores(); if (keyStores != null) { for (KeyStore keyStore : keyStores) { mergedTrustStore = mergingTrustStores(secSupp.getTrustStores()); getSSLContext(null, null, null); } catch(Exception ex) { if (_logger.isLoggable(Level.FINE)) {
public TrustManager[] getTrustManagers() throws Exception{ return getTrustManagers(null); } public TrustManager[] getTrustManagers(String algorithm) throws IOException,
checkPermission(SecuritySupport.KEYSTORE_PASS_PROP); PrivateKeyEntry privKeyEntry = null; if (certNickname != null) { int ind = certNickname.indexOf(':'); KeyStore[] kstores = getKeyStores(); int count = -1; String aliasName = certNickname;
/** * Logout the user. * * <p> This method removes the <code>PrincipalImpl</code> * that was added by the <code>commit</code> method. * * <p> * * @exception LoginException if the logout fails. * * @return true in all cases since this <code>LoginModule</code> * should not be ignored. */ public boolean logout() throws LoginException { // unset the alias ssl = null; sslUtils.setAppclientSsl(ssl); subject.getPrincipals().remove(userPrincipal); succeeded = false; commitSucceeded = false; alias = null; userPrincipal = null; return true; }
@Override public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); String[] cipherSuites = sslutils.getSupportedCipherSuites(); for (String cipherSuite : cipherSuites) { if (!cipherSuite.contains("_KRB5_")) { ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(cipherSuite); } } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } }