@NotNull public static Proxy getProxy(@NotNull final String proxyHost, final int proxyPort, @NotNull final String proxyUser, @NotNull final String proxyPassword) { if (StringUtilities.isBlank(proxyHost)) { return Proxy.NO_PROXY; } if (StringUtilities.isNotEmpty(proxyUser)) { Authenticator.setDefault(new Authenticator() { @Override public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(proxyUser, proxyPassword.toCharArray()); } }); } return new Proxy(HTTP, InetSocketAddress.createUnresolved(proxyHost, proxyPort)); }
public static IdentityKey getIdentityKey(String privateKeyFile, String privateKeyString, String privateKeyPassphrase) { IdentityKey identityKey = null; if (StringUtilities.isNotEmpty(privateKeyFile)) { identityKey = new KeyFile(privateKeyFile); } if (StringUtilities.isNotEmpty(privateKeyString)) { if (identityKey != null) { throw new IllegalArgumentException(String.format("%s and %s inputs are mutually exclusive. They can't be both set at the same time.", Constants.PRIVATE_KEY_FILE, Constants.PRIVATE_KEY_DATA)); } identityKey = new KeyData(privateKeyString); } if (identityKey != null && StringUtilities.isNotEmpty(privateKeyPassphrase)) { identityKey.setPassPhrase(privateKeyPassphrase); } return identityKey; }
@NotNull public static Proxy getProxy(@NotNull final String proxyHost, final int proxyPort, @NotNull final String proxyUser, @NotNull final String proxyPassword) { if (StringUtilities.isBlank(proxyHost)) { return Proxy.NO_PROXY; } if (StringUtilities.isNotEmpty(proxyUser)) { Authenticator.setDefault(new Authenticator() { @Override public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(proxyUser, proxyPassword.toCharArray()); } }); } return new Proxy(HTTP, InetSocketAddress.createUnresolved(proxyHost, proxyPort)); } }
public static IdentityKey getIdentityKey(String privateKeyFile, String privateKeyString, String privateKeyPassphrase) { IdentityKey identityKey = null; if (StringUtilities.isNotEmpty(privateKeyFile)) { identityKey = new KeyFile(privateKeyFile); } if (StringUtilities.isNotEmpty(privateKeyString)) { if (identityKey != null) { throw new IllegalArgumentException(String.format("%s and %s inputs are mutually exclusive. They can't be both set at the same time.", Constants.PRIVATE_KEY_FILE, Constants.PRIVATE_KEY_DATA)); } identityKey = new KeyData(privateKeyString); } if (identityKey != null && StringUtilities.isNotEmpty(privateKeyPassphrase)) { identityKey.setPassPhrase(privateKeyPassphrase); } return identityKey; }