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

Digest Authentication (RFC 2617) not working - missing abs_path (without query)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 6u10
    • core-libs
    • Cause Known
    • x86
    • windows_vista

      FULL PRODUCT VERSION :
      java version "1.6.0_17"
      Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
      Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.0.6000]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Web server: IIS 6, Authentication digest, webservice - but test http connection only

      A DESCRIPTION OF THE PROBLEM :
      Try connect to service by url="http://server.net/service.asmx?WSDL"
      Used: sun.net.www.protocol.http.HttpURLConnection
      Result: <401: Unauthorized>

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      I run test with HttpURLConnection
      HttpURLConnection: <200: OK> http://server.net/service.asmx
      HttpURLConnection: <401: Unauthorized> http://server.net/service.asmx?WSDL

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      HttpURLConnection: <200: OK> http://server.net/service.asmx
      HttpURLConnection: <200: OK> http://server.net/service.asmx?WSDL

      like in web-browser - http header:
      Authorization: Digest username="test", uri="/service.asmx", ....

      http://www.ietf.org/rfc/rfc2617.txt "3.2.1 The WWW-Authenticate Response Header"
       reference to http://www.ietf.org/rfc/rfc2616.txt "3.2.2 http URL"
      http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]
      ACTUAL -
      HttpURLConnection: <200: OK> http://server.net/service.asmx
      HttpURLConnection: <401: Unauthorized> http://server.net/service.asmx?WSDL

      http header in second case:
      Authorization: Digest username="test", uri="/service.asmx?WSDL",...

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      HttpURLConnection: <401: Unauthorized> http://server.net/service.asmx?WSDL
      java.net.ProtocolException: Server redirected too many times (20)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1368)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1362)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1016)
      at java.net.URLConnection.getContent(URLConnection.java:688)
      ...

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      String userInfo = "test";
      public void test() throws Exception {
              Authenticator.setDefault(new Authenticator() {
                  protected PasswordAuthentication getPasswordAuthentication() {
                      return new PasswordAuthentication(userInfo,"test".toCharArray());
                  }
              testURL(new URI("http://server.net/service.asmx"));
              testURLQuery(new URI("http://server.net/service.asmx?WSDL"));
              });
      }

          private void testURL(URI targetURI) throws Exception {
              URI serviceURI = new URI(targetURI.getScheme(), userInfo, targetURI
                      .getHost(), targetURI.getPort(), targetURI.getPath(), null,
                      null);
              testConnection(serviceURI);
          }

          private void testURLQuery(URI targetURI) throws Exception {
              URI serviceURI = new URI(targetURI.getScheme(), userInfo, targetURI
                      .getHost(), targetURI.getPort(), targetURI.getPath(), targetURI
                      .getQuery(), null);
              testConnection(serviceURI);
          }

          private void testConnection(URI serviceURI) throws Exception {
              HttpURLConnection connection = (HttpURLConnection) serviceURI.toURL()
                      .openConnection();
              int statusCode = connection.getResponseCode();
              logger.debug(String.format("HttpURLConnection: <%s: %s> %s", statusCode, connection.getResponseMessage(), serviceURI));
              connection.connect();
              connection.getContent();
          }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: