Duplicate :
|
FULL PRODUCT VERSION : JDK 6 ADDITIONAL OS VERSION INFORMATION : Any OS. A DESCRIPTION OF THE PROBLEM : java.net.Authenticator can only be set as a static instance, but not per connection. This is not really useful in a multithreaded multi-user environment where many connections to many servers should be authenticated. The limitation is known at Sun/Oracle, as this comment in sun.net.www.protocol.http.HttpURLConnection shows: /* We only have a single static authenticator for now. * REMIND: backwards compatibility with JDK 1.1. Should be * eliminated for JDK 2.0. */ private static HttpAuthenticator defaultAuth; STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Look at the JavaDocs, or at the implementation class sun.net.www.protocol.http.HttpURLConnection. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - I would expect that authentication with HTTP connections could also be used in a multithreaded multi-user server environment. This could easily be achieved by setting an Authenticator on a connection instance that would override the static default Authenticator. ACTUAL - Programmes have to use other HTTP clients, the e.g. Apache HTTP Client. REPRODUCIBILITY : This bug can be reproduced always. CUSTOMER SUBMITTED WORKAROUND : Use another HTTP client, e.g. Apache HTTP Client.