3

I need a Java Socket client class that supports authenticated socks proxy, java.net.Proxy only supports one set of credentials for the whole JVM. I have multiple proxies each with different logins. here's what java's proxy Authenticator does, only one login for the whole JVM. how do I have multiple?

Authenticator.setDefault(new Authenticator(){
  protected  PasswordAuthentication  getPasswordAuthentication(){
   PasswordAuthentication p=new PasswordAuthentication("xxx", "xxx".toCharArray());
   return p;
  }
 });

1 Answer 1

3

In your Authenticator implementation you can ask for the proxy the authentication is for using: getRequestingHost().

Based on the value of getRequestingHost() you can return the PasswordAuthentication for that proxy.

Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.