Created
February 6, 2015 09:52
-
-
Save SmiddyPence/568f8905a7e54c2abe42 to your computer and use it in GitHub Desktop.
Static Java Block To Set Proxy for external http requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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