Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. URL proximo = new URL(System.getenv('PROXIMO_URL')
  2. String userInfo = proximo.getUserInfo()
  3. String user = userInfo.substring(0, userInfo.indexOf(':'))
  4. String password = userInfo.substring(userInfo.indexOf(':') + 1)
  5. System.setProperty('socksProxyHost', proximo.getHost())
  6. System.setProperty('socksProxyPort', '1080')
  7. Authenticator.setDefault(new ProxyAuth(user, password))
  8.  
  9. private class ProxyAuth extends Authenticator {
  10. private PasswordAuthentication passwordAuthentication;
  11.  
  12. private ProxyAuth(String user, String password) {
  13. passwordAuthentication = new PasswordAuthentication(user, password.toCharArray())
  14. }
  15.  
  16. @Override
  17. protected PasswordAuthentication getPasswordAuthentication() {
  18. return passwordAuthentication;
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement