public SSLConfiguration build() { KeyStoreInfo keyStore = null; if (keyStorePath != null) { keyStore = new KeyStoreInfo(keyStorePath, keyStorePassword, keyStoreType); } KeyStoreInfo trustKeyStore = null; if (trustKeyStorePath != null) { trustKeyStore = new KeyStoreInfo(trustKeyStorePath, trustKeyStorePassword, trustKeyStoreType); } return new SSLConfiguration(keyStore, trustKeyStore, clientAuth); } }
public ServerSocket createSSLServer(int port, InetAddress bindAddr) throws Exception { SSLServerSocket serverSocket = (SSLServerSocket) configuration.getSSLServerSocketFactory().createServerSocket(port, 50, bindAddr); if (configuration.isNeedClientAuth()) { serverSocket.setNeedClientAuth(true); } else { serverSocket.setNeedClientAuth(false); } return serverSocket; }
@Override public Socket createProxySocket() throws IOException { try { return configuration.getSSLSocketFactory().createSocket(); } catch (SSLConfigurationException e) { throw new SocksException(e.getMessage()); } }
public SSLServerSocketFactory getSSLServerSocketFactory() throws SSLConfigurationException { checkNotNull(keyStoreInfo, "keyStoreInfo may not be null"); String KEY_STORE_PASSWORD = getKeyStoreInfo().getPassword(); String KEY_STORE_PATH = getKeyStoreInfo().getKeyStorePath(); KeyStore keyStore = null; KeyStore trustKeyStore = null; String TRUST_KEY_STORE_PATH = getTrustKeyStoreInfo().getKeyStorePath(); String TRUST_KEY_STORE_PASSWORD = getTrustKeyStoreInfo().getPassword(); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("SunX509"); trustKeyStore = KeyStore.getInstance("JKS");
public static SSLConfiguration loadClassPath(String filePath) throws FileNotFoundException, IOException { checkNotNull(filePath, "Argument [filePath] may not be null"); if (!filePath.startsWith(File.separator)) { filePath = File.separator + filePath; } URL url = SSLConfiguration.class.getResource(filePath); if (url == null) { throw new FileNotFoundException("classpath:" + filePath); } String path = url.getPath(); return load(path); }
public SSLServerSocketFactory getSSLServerSocketFactory() throws SSLConfigurationException { checkNotNull(keyStoreInfo, "keyStoreInfo may not be null"); String KEY_STORE_PASSWORD = getKeyStoreInfo().getPassword(); String KEY_STORE_PATH = getKeyStoreInfo().getKeyStorePath(); KeyStore keyStore = null; KeyStore trustKeyStore = null; String TRUST_KEY_STORE_PATH = getTrustKeyStoreInfo().getKeyStorePath(); String TRUST_KEY_STORE_PASSWORD = getTrustKeyStoreInfo().getPassword(); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("SunX509"); trustKeyStore = KeyStore.getInstance("JKS");
public static SSLConfiguration loadClassPath(String filePath) throws FileNotFoundException, IOException { checkNotNull(filePath, "Argument [filePath] may not be null"); if (!filePath.startsWith(File.separator)) { filePath = File.separator + filePath; } URL url = SSLConfiguration.class.getResource(filePath); if (url == null) { throw new FileNotFoundException("classpath:" + filePath); } String path = url.getPath(); return load(path); }
public ServerSocket createSSLServer(int port, InetAddress bindAddr) throws Exception { SSLServerSocket serverSocket = (SSLServerSocket) configuration.getSSLServerSocketFactory().createServerSocket(port, 50, bindAddr); if (configuration.isNeedClientAuth()) { serverSocket.setNeedClientAuth(true); } else { serverSocket.setNeedClientAuth(false); } return serverSocket; }
public SSLConfiguration build() { KeyStoreInfo keyStore = null; if (keyStorePath != null) { keyStore = new KeyStoreInfo(keyStorePath, keyStorePassword, keyStoreType); } KeyStoreInfo trustKeyStore = null; if (trustKeyStorePath != null) { trustKeyStore = new KeyStoreInfo(trustKeyStorePath, trustKeyStorePassword, trustKeyStoreType); } return new SSLConfiguration(keyStore, trustKeyStore, clientAuth); } }
if (proxySslValue != null) { proxy = new SSLSocks5(new InetSocketAddress(host, port), SSLConfiguration.load (proxySslValue));
@Override public Socket createProxySocket(InetAddress address, int port) throws IOException { try { return configuration.getSSLSocketFactory().createSocket(address, port); } catch (SSLConfigurationException e) { throw new SocksException(e.getMessage()); } }
public static SSLConfiguration load(String filePath) throws FileNotFoundException, IOException { checkNotNull(filePath, "Argument [filePath] may not be null"); logger.debug("load SSL configuration file:{}", filePath); KeyStoreInfo keyStoreInfo = null; KeyStoreInfo trustKeyStoreInfo = null; Properties properties = new Properties(); properties.load(new FileInputStream(filePath)); String keystorePath = PathUtil.getAbstractPath(properties.getProperty("ssl.keystore.location")); String password = properties.getProperty("ssl.keystore.password"); String type = properties.getProperty("ssl.keystore.type", "JSK"); String trustKeystorePath = PathUtil.getAbstractPath(properties.getProperty("ssl.trustStore.location")); String trustPassword = properties.getProperty("ssl.trustStore.password"); String trustType = properties.getProperty("ssl.trustStore.type", "JSK"); if (!Strings.isNullOrEmpty(keystorePath)) { keyStoreInfo = new KeyStoreInfo(keystorePath, password, type); } if (!Strings.isNullOrEmpty(trustKeystorePath)) { trustKeyStoreInfo = new KeyStoreInfo(trustKeystorePath, trustPassword, trustType); } String clientAuthValue = properties.getProperty("ssl.client.auth", "false"); boolean clientAuth = false; if (clientAuthValue.equalsIgnoreCase("true")) { clientAuth = true; } return new SSLConfiguration(keyStoreInfo, trustKeyStoreInfo, clientAuth); }
if (proxySslValue != null) { proxy = new SSLSocks5(new InetSocketAddress(host, port), SSLConfiguration.load (proxySslValue));
@Override public Socket createProxySocket(InetAddress address, int port) throws IOException { try { return configuration.getSSLSocketFactory().createSocket(address, port); } catch (SSLConfigurationException e) { throw new SocksException(e.getMessage()); } }
public static SSLConfiguration load(String filePath) throws FileNotFoundException, IOException { checkNotNull(filePath, "Argument [filePath] may not be null"); logger.debug("load SSL configuration file:{}", filePath); KeyStoreInfo keyStoreInfo = null; KeyStoreInfo trustKeyStoreInfo = null; Properties properties = new Properties(); properties.load(new FileInputStream(filePath)); String keystorePath = PathUtil.getAbstractPath(properties.getProperty("ssl.keystore.location")); String password = properties.getProperty("ssl.keystore.password"); String type = properties.getProperty("ssl.keystore.type", "JSK"); String trustKeystorePath = PathUtil.getAbstractPath(properties.getProperty("ssl.trustStore.location")); String trustPassword = properties.getProperty("ssl.trustStore.password"); String trustType = properties.getProperty("ssl.trustStore.type", "JSK"); if (!Strings.isNullOrEmpty(keystorePath)) { keyStoreInfo = new KeyStoreInfo(keystorePath, password, type); } if (!Strings.isNullOrEmpty(trustKeystorePath)) { trustKeyStoreInfo = new KeyStoreInfo(trustKeystorePath, trustPassword, trustType); } String clientAuthValue = properties.getProperty("ssl.client.auth", "false"); boolean clientAuth = false; if (clientAuthValue.equalsIgnoreCase("true")) { clientAuth = true; } return new SSLConfiguration(keyStoreInfo, trustKeyStoreInfo, clientAuth); }
if (sslConfigValue != null) { try { builder.useSSL(SSLConfiguration.load(sslConfigValue)); } catch (IOException e) { throw new IllegalArgumentException(e.getMessage());
@Override public Socket createProxySocket() throws IOException { try { return configuration.getSSLSocketFactory().createSocket(); } catch (SSLConfigurationException e) { throw new SocksException(e.getMessage()); } }
/** * Creates a {@link SSLConfiguration} instance with a string.<br> * The string should format as: <br> * <pre> * KEYS_TORE_PATH,KEY_STORE_PASSWORD,TRUST_KEY_STORE_PATH,TRUST_KEY_STORE_PASSWORD,CLIENT_AUTH * </pre> * * @param configuration configuration as a string. * @return the instance of {@link SSLConfiguration}. */ public static SSLConfiguration parse(String configuration) { String[] strings = configuration.split(","); if (strings.length == 2) { KeyStoreInfo keyStoreInfo = new KeyStoreInfo(strings[0], strings[1]); return new SSLConfiguration(keyStoreInfo, null); } else if (strings.length == 4) { KeyStoreInfo keyStoreInfo = new KeyStoreInfo(strings[0], strings[1]); KeyStoreInfo trustKeyStoreInfo = new KeyStoreInfo(strings[2], strings[3]); return new SSLConfiguration(keyStoreInfo, trustKeyStoreInfo); } else if (strings.length == 5) { KeyStoreInfo keyStoreInfo = new KeyStoreInfo(strings[0], strings[1]); KeyStoreInfo trustKeyStoreInfo = new KeyStoreInfo(strings[2], strings[3]); return new SSLConfiguration(keyStoreInfo, trustKeyStoreInfo, strings[4].equals("true")); } return null; }
if (sslConfigValue != null) { try { builder.useSSL(SSLConfiguration.load(sslConfigValue)); } catch (IOException e) { throw new IllegalArgumentException(e.getMessage());
/** * Creates a {@link SSLConfiguration} instance with a string.<br> * The string should format as: <br> * <pre> * KEYS_TORE_PATH,KEY_STORE_PASSWORD,TRUST_KEY_STORE_PATH,TRUST_KEY_STORE_PASSWORD,CLIENT_AUTH * </pre> * * @param configuration configuration as a string. * @return the instance of {@link SSLConfiguration}. */ public static SSLConfiguration parse(String configuration) { String[] strings = configuration.split(","); if (strings.length == 2) { KeyStoreInfo keyStoreInfo = new KeyStoreInfo(strings[0], strings[1]); return new SSLConfiguration(keyStoreInfo, null); } else if (strings.length == 4) { KeyStoreInfo keyStoreInfo = new KeyStoreInfo(strings[0], strings[1]); KeyStoreInfo trustKeyStoreInfo = new KeyStoreInfo(strings[2], strings[3]); return new SSLConfiguration(keyStoreInfo, trustKeyStoreInfo); } else if (strings.length == 5) { KeyStoreInfo keyStoreInfo = new KeyStoreInfo(strings[0], strings[1]); KeyStoreInfo trustKeyStoreInfo = new KeyStoreInfo(strings[2], strings[3]); return new SSLConfiguration(keyStoreInfo, trustKeyStoreInfo, strings[4].equals("true")); } return null; }