Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7007970

java.net.Authenticator cannot be set on a per-connection basis

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 6u23
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_2008

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: