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 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); } }
/** * 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; }
/** * 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; }
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); }
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); }
username = values[2]; password = values[3]; trustKeyStoreInfo = new KeyStoreInfo(PathUtil.getAbstractPath(values[4]), values[5]); configuration = new SSLConfiguration(null, trustKeyStoreInfo); socks = new SSLSocks5(new InetSocketAddress(host, port), configuration); username = values[2]; password = values[3]; trustKeyStoreInfo = new KeyStoreInfo(PathUtil.getAbstractPath(values[4]), values[5]); keyStoreInfo = new KeyStoreInfo(PathUtil.getAbstractPath(values[6]), values[7]); configuration = new SSLConfiguration(keyStoreInfo, trustKeyStoreInfo); socks = new SSLSocks5(new InetSocketAddress(host, port), configuration);
username = values[2]; password = values[3]; trustKeyStoreInfo = new KeyStoreInfo(PathUtil.getAbstractPath(values[4]), values[5]); configuration = new SSLConfiguration(null, trustKeyStoreInfo); socks = new SSLSocks5(new InetSocketAddress(host, port), configuration); username = values[2]; password = values[3]; trustKeyStoreInfo = new KeyStoreInfo(PathUtil.getAbstractPath(values[4]), values[5]); keyStoreInfo = new KeyStoreInfo(PathUtil.getAbstractPath(values[6]), values[7]); configuration = new SSLConfiguration(keyStoreInfo, trustKeyStoreInfo); socks = new SSLSocks5(new InetSocketAddress(host, port), configuration);