Skip to content

Instantly share code, notes, and snippets.

Embed
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.