/** * Configure an ssl listener on the server. * @param addr address to listen on * @param keystore location of the keystore * @param storPass password for the keystore * @param keyPass password for the key */ public void addSslListener(InetSocketAddress addr, String keystore, String storPass, String keyPass) throws IOException { if (sslListener != null || webServer.isStarted()) { throw new IOException("Failed to add ssl listener"); } sslListener = new SslListener(); sslListener.setHost(addr.getHostName()); sslListener.setPort(addr.getPort()); sslListener.setKeystore(keystore); sslListener.setPassword(storPass); sslListener.setKeyPassword(keyPass); webServer.addListener(sslListener); }
public boolean setupKeystoreType() { if (!sslPolicy.isSetKeystoreType()) { LogUtils.log(LOG, Level.INFO, "KEY_STORE_TYPE_NOT_SET", new Object[] {DEFAUL_KEYSTORE_TYPE}); //Can default to JKs so return true secureListener.setKeystoreType(DEFAUL_KEYSTORE_TYPE); return true; } String keyStoreType = sslPolicy.getKeystoreType(); LogUtils.log(LOG, Level.INFO, "KEY_STORE_TYPE_SET", new Object[] {keyStoreType}); secureListener.setKeystoreType(keyStoreType); return true; }
public boolean setupRequireClientAuthentication() { if (!sslPolicy.isSetRequireClientAuthentication()) { LogUtils.log(LOG, Level.WARNING, "REQUIRE_CLIENT_AUTHENTICATION_NOT_SET"); secureListener.setNeedClientAuth(DEFAULT_REQUIRE_CLIENT_AUTHENTICATION); return true; } Boolean holder = sslPolicy.isRequireClientAuthentication(); boolean setRequireClientAuthentication = holder.booleanValue(); LogUtils.log(LOG, Level.INFO, "REQUIRE_CLIENT_AUTHENTICATION_SET", new Object[]{setRequireClientAuthentication}); secureListener.setNeedClientAuth(setRequireClientAuthentication); return true; }
public boolean setupKeyPassword() { String keyPassword = null; if (sslPolicy.isSetKeyPassword()) { keyPassword = sslPolicy.getKeyPassword(); secureListener.setKeyPassword(keyPassword); return true; } keyPassword = System.getProperty("javax.net.ssl.keyStorePassword"); if (keyPassword == null) { LogUtils.log(LOG, Level.INFO, "KEY_PASSWORD_NOT_SET"); } secureListener.setKeyPassword(keyPassword); return true; }
public boolean setupKeystorePassword() { String keyStorePassword = null; if (sslPolicy.isSetKeystorePassword()) { keyStorePassword = sslPolicy.getKeystorePassword(); secureListener.setPassword(keyStorePassword); return true; } keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword"); if (keyStorePassword != null) { secureListener.setPassword(keyStorePassword); return true; } LogUtils.log(LOG, Level.SEVERE, "KEY_STORE_PASSWORD_NOT_SET"); return false; }
public boolean setupKeystore() { String keyStoreLocation = null; if (sslPolicy.isSetKeystore()) { keyStoreLocation = sslPolicy.getKeystore(); secureListener.setKeystore(keyStoreLocation); LogUtils.log(LOG, Level.INFO, "KEY_STORE_SET", new Object[] {keyStoreLocation}); return true; } keyStoreLocation = System.getProperty("javax.net.ssl.keyStore"); if (keyStoreLocation != null) { LogUtils.log(LOG, Level.INFO, "KEY_STORE_SET", new Object[] {keyStoreLocation}); secureListener.setKeystore(keyStoreLocation); return true; } keyStoreLocation = System.getProperty("user.home") + "/.keystore"; secureListener.setKeystore(keyStoreLocation); LogUtils.log(LOG, Level.INFO, "KEY_STORE_NOT_SET", new Object[] {keyStoreLocation}); return true; }
listener = new SslListener(new InetAddrPort(port)); SslListener secureListener = (SslListener)listener;
public boolean setupCiphersuites() { if (sslPolicy.isSetCiphersuites()) { List<String> cipherSuites = sslPolicy.getCiphersuites(); int numCipherSuites = cipherSuites.size(); String[] ciphs = new String[numCipherSuites]; String ciphsStr = null; for (int i = 0; i < numCipherSuites; i++) { ciphs[i] = cipherSuites.get(i); if (ciphsStr == null) { ciphsStr = ciphs[i]; } else { ciphsStr += ", " + ciphs[i]; } } LogUtils.log(LOG, Level.INFO, "CIPHERSUITE_SET", new Object[]{ciphsStr}); secureListener.setCipherSuites(ciphs); } LogUtils.log(LOG, Level.INFO, "CIPHERSUITE_NOT_SET"); return true; }
public void setupKeystoreAlgorithm() { String keyManagerFactoryAlgorithm = null; if (sslPolicy.isSetKeystoreAlgorithm()) { keyManagerFactoryAlgorithm = sslPolicy.getKeystoreAlgorithm(); secureListener.setAlgorithm(keyManagerFactoryAlgorithm); LogUtils.log(LOG, Level.INFO, "KEY_STORE_ALGORITHM_SET", new Object[] {keyManagerFactoryAlgorithm}); } keyManagerFactoryAlgorithm = KeyManagerFactory.getDefaultAlgorithm(); LogUtils.log(LOG, Level.INFO, "KEY_STORE_ALGORITHM_NOT_SET", new Object[] {keyManagerFactoryAlgorithm}); }
protected void customizeRequest(Socket socket, HttpRequest request) { super.customizeRequest(socket,request); URI uri=request.getURI(); // Convert the URI to a proxy URL uri.setScheme("https"); uri.setHost(_addr.getHost()); uri.setPort(_addr.getPort()); }