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

Basic Authentication fails with multiple realms

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 1.4.2
    • 1.4.1
    • core-libs
    • mantis
    • generic, x86
    • solaris_8, windows_2000

    Description

      Basic Authentication fails with multiple realms.
      I setup of two realms on apache server . Both realms have different user databases. When I set Authenticator.setDefault() to one realm's user and then try to access the resource existing in second realm thru HttpURLConnection, then it throws the following exception.

      java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
              at java.util.LinkedList.entry(LinkedList.java:356)
              at java.util.LinkedList.get(LinkedList.java:299)
              at sun.net.www.protocol.http.PathMap.get(AuthenticationInfo.java:375)
              at sun.net.www.protocol.http.AuthenticationInfo.getAuth(AuthenticationInfo.java:181)
              at sun.net.www.protocol.http.AuthenticationInfo.getServerAuth(AuthenticationInfo.java:171)
              at sun.net.www.protocol.http.HttpURLConnection.getServerAuthentication(HttpURLConnection.java:951)
              at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:611)
              at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:238)
              at BasicAuthTestCase.main(BasicAuthTestCase.java:34)


      How to reproduce it:
      ====================
      1. Take the attached BasicAuthTestCase.java
      2. Need to setup two realms on apache(or may be any other server) . Both will be having two different user lists.

      For example I have like...
      realm -> AuthCheck/ -> It has a list of users
      realm -> NoAuth/ -> It has a list of users

      3. Execute the attached code

      Output:
      ------
      java BasicAuthTestCase
      Response url1: 401 ---> Accessed before setting Authenticator.setDefault()
      npath = /AuthCheck/
      opath = /AuthCheck/
      second Response url1: 200 --> After setting user info
      java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 --> {Tried to access second realm }
              at java.util.LinkedList.entry(LinkedList.java:356)
              at java.util.LinkedList.get(LinkedList.java:299)
              at sun.net.www.protocol.http.PathMap.get(AuthenticationInfo.java:375)
              at sun.net.www.protocol.http.AuthenticationInfo.getAuth(AuthenticationInfo.java:181)
              at sun.net.www.protocol.http.AuthenticationInfo.getServerAuth(AuthenticationInfo.java:171)
              at sun.net.www.protocol.http.HttpURLConnection.getServerAuthentication(HttpURLConnection.java:951)
              at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:611)
              at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:238)
              at BasicAuthTestCase.main(BasicAuthTestCase.java:34)


      Attachments

        Issue Links

          Activity

            People

              michaelm Michael McMahon
              vakellasunw Venkata Akella (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: