Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- URL proximo = new URL(System.getenv('PROXIMO_URL')
- String userInfo = proximo.getUserInfo()
- String user = userInfo.substring(0, userInfo.indexOf(':'))
- String password = userInfo.substring(userInfo.indexOf(':') + 1)
- System.setProperty('socksProxyHost', proximo.getHost())
- System.setProperty('socksProxyPort', '1080')
- Authenticator.setDefault(new ProxyAuth(user, password))
- private class ProxyAuth extends Authenticator {
- private PasswordAuthentication passwordAuthentication;
- private ProxyAuth(String user, String password) {
- passwordAuthentication = new PasswordAuthentication(user, password.toCharArray())
- }
- @Override
- protected PasswordAuthentication getPasswordAuthentication() {
- return passwordAuthentication;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement