Skip to content

Instantly share code, notes, and snippets.

@SmiddyPence
Created February 6, 2015 09:52
Show Gist options
  • Save SmiddyPence/568f8905a7e54c2abe42 to your computer and use it in GitHub Desktop.
Save SmiddyPence/568f8905a7e54c2abe42 to your computer and use it in GitHub Desktop.
Static Java Block To Set Proxy for external http requests
static {
final String authUser = "XXXXX";
final String authPassword = "XXXXXX";
Authenticator.setDefault(
new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
authUser, authPassword.toCharArray());
}
}
);
System.setProperty("http.proxyHost", "XXXXX");
System.setProperty("http.proxyPort", "80");
System.setProperty("http.proxyUser", authUser);
System.setProperty("http.proxyPassword", authPassword);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment