Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
          +++ new/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
↓ open down ↓ 241 lines elided ↑ open up ↑
 242  242      private boolean tryTransparentNTLMServer = true;
 243  243      private boolean tryTransparentNTLMProxy = true;
 244  244  
 245  245      /* Used by Windows specific code */
 246  246      private Object authObj;
 247  247  
 248  248      /* Set if the user is manually setting the Authorization or Proxy-Authorization headers */
 249  249      boolean isUserServerAuth;
 250  250      boolean isUserProxyAuth;
 251  251  
      252 +    String serverAuthKey, proxyAuthKey;
      253 +
 252  254      /* Progress source */
 253  255      protected ProgressSource pi;
 254  256  
 255  257      /* all the response headers we get back */
 256  258      private MessageHeader responses;
 257  259      /* the stream _from_ the server */
 258  260      private InputStream inputStream = null;
 259  261      /* post stream _to_ the server, if any */
 260  262      private PosterOutputStream poster = null;
 261  263  
↓ open down ↓ 1234 lines elided ↑ open up ↑
1496 1498  
1497 1499              // buffer the error stream if bytes < 4k
1498 1500              // and it can be buffered within 1 second
1499 1501              String te = responses.findValue("Transfer-Encoding");
1500 1502              if (http != null && http.isKeepingAlive() && enableESBuffer &&
1501 1503                  (cl > 0 || (te != null && te.equalsIgnoreCase("chunked")))) {
1502 1504                  errorStream = ErrorStream.getErrorStream(inputStream, cl, http);
1503 1505              }
1504 1506              throw e;
1505 1507          } finally {
1506      -            if (respCode == HTTP_PROXY_AUTH && proxyAuthentication != null) {
1507      -                proxyAuthentication.endAuthRequest();
     1508 +            if (proxyAuthKey != null) { 
     1509 +                AuthenticationInfo.endAuthRequest(proxyAuthKey); 
     1510 +            } 
     1511 +            if (serverAuthKey != null) { 
     1512 +                AuthenticationInfo.endAuthRequest(serverAuthKey); 
1508 1513              }
1509      -            else if (respCode == HTTP_UNAUTHORIZED && serverAuthentication != null) {
1510      -                serverAuthentication.endAuthRequest();
1511      -            }
1512 1514          }
1513 1515      }
1514 1516  
1515 1517      /*
1516 1518       * Creates a chained exception that has the same type as
1517 1519       * original exception and with the same message. Right now,
1518 1520       * there is no convenient APIs for doing so.
1519 1521       */
1520 1522      private IOException getChainedException(final IOException rememberedException) {
1521 1523          try {
↓ open down ↓ 191 lines elided ↑ open up ↑
1713 1715                  setTunnelState(TunnelState.NONE);
1714 1716                  break;
1715 1717              } while (retryTunnel < maxRedirects);
1716 1718  
1717 1719              if (retryTunnel >= maxRedirects || (respCode != HTTP_OK)) {
1718 1720                  throw new IOException("Unable to tunnel through proxy."+
1719 1721                                        " Proxy returns \"" +
1720 1722                                        statusLine + "\"");
1721 1723              }
1722 1724          } finally  {
1723      -            if (respCode == HTTP_PROXY_AUTH && proxyAuthentication != null) {
1724      -                proxyAuthentication.endAuthRequest();
     1725 +            if (proxyAuthKey != null) { 
     1726 +                AuthenticationInfo.endAuthRequest(proxyAuthKey);  
1725 1727              }
1726 1728          }
1727 1729  
1728 1730          // restore original request headers
1729 1731          requests = savedRequests;
1730 1732  
1731 1733          // reset responses
1732 1734          responses.reset();
1733 1735      }
1734 1736  
↓ open down ↓ 95 lines elided ↑ open up ↑
1830 1832              } else if ("Kerberos".equalsIgnoreCase(scheme)) {
1831 1833                  authScheme = KERBEROS;
1832 1834                  doingNTLMp2ndStage = true;
1833 1835              } else if ("Negotiate".equalsIgnoreCase(scheme)) {
1834 1836                  authScheme = NEGOTIATE;
1835 1837                  doingNTLMp2ndStage = true;
1836 1838              }
1837 1839  
1838 1840              if (realm == null)
1839 1841                  realm = "";
1840      -            ret = AuthenticationInfo.getProxyAuth(host,
1841      -                                                  port,
1842      -                                                  realm,
1843      -                                                  authScheme);
     1842 +            proxyAuthKey = AuthenticationInfo.getProxyAuthKey(host, port, realm, authScheme);
     1843 +            ret = AuthenticationInfo.getProxyAuth(proxyAuthKey); 
1844 1844              if (ret == null) {
1845 1845                  switch (authScheme) {
1846 1846                  case BASIC:
1847 1847                      InetAddress addr = null;
1848 1848                      try {
1849 1849                          final String finalHost = host;
1850 1850                          addr = java.security.AccessController.doPrivileged(
1851 1851                              new java.security.PrivilegedExceptionAction<InetAddress>() {
1852 1852                                  public InetAddress run()
1853 1853                                      throws java.net.UnknownHostException {
↓ open down ↓ 120 lines elided ↑ open up ↑
1974 1974                  authScheme = KERBEROS;
1975 1975                  doingNTLM2ndStage = true;
1976 1976              } else if ("Negotiate".equalsIgnoreCase(scheme)) {
1977 1977                  authScheme = NEGOTIATE;
1978 1978                  doingNTLM2ndStage = true;
1979 1979              }
1980 1980  
1981 1981              domain = p.findValue ("domain");
1982 1982              if (realm == null)
1983 1983                  realm = "";
1984      -            ret = AuthenticationInfo.getServerAuth(url, realm, authScheme);
     1984 +            serverAuthKey = AuthenticationInfo.getServerAuthKey(url, realm, authScheme);
     1985 +            ret = AuthenticationInfo.getServerAuth(serverAuthKey);
1985 1986              InetAddress addr = null;
1986 1987              if (ret == null) {
1987 1988                  try {
1988 1989                      addr = InetAddress.getByName(url.getHost());
1989 1990                  } catch (java.net.UnknownHostException ignored) {
1990 1991                      // User will have addr = null
1991 1992                  }
1992 1993              }
1993 1994              // replacing -1 with default port for a protocol
1994 1995              int port = url.getPort();
↓ open down ↓ 1101 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX