Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
add proxy(user-pass) to java execution
public static void addProxy(String user, String pass, String host, String port) {
if(user!= null && pass != null) {
final String authUser = user;
final String authPassword = pass;
Authenticator.setDefault(
new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
authUser, authPassword.toCharArray());
}
}
);
System.setProperty("http.proxyUser", authUser);
System.setProperty("http.proxyPassword", authPassword);
}
System.setProperty("http.proxyHost", host);
System.setProperty("http.proxyPort", port);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment