Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java
          +++ new/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java
↓ open down ↓ 262 lines elided ↑ open up ↑
 263  263                  + ":" + url.getHost().toLowerCase() + ":" + port;
 264  264          return getAuth(key, url);
 265  265      }
 266  266  
 267  267      /**
 268  268       * Returns info for the URL, for an HTTP server auth.  Used when we
 269  269       * do know the realm (i.e. when we're responding to a challenge).
 270  270       * In this case we do not use the path because the protection space
 271  271       * is identified by the host:port:realm only
 272  272       */
 273      -    static AuthenticationInfo getServerAuth(URL url, String realm, AuthScheme scheme) {
      273 +    static String getServerAuthKey(URL url, String realm, AuthScheme scheme) {
 274  274          int port = url.getPort();
 275  275          if (port == -1) {
 276  276              port = url.getDefaultPort();
 277  277          }
 278  278          String key = SERVER_AUTHENTICATION + ":" + scheme + ":" + url.getProtocol().toLowerCase()
 279  279                       + ":" + url.getHost().toLowerCase() + ":" + port + ":" + realm;
      280 +        return key;
      281 +    }
      282 +
      283 +    static AuthenticationInfo getServerAuth(String key) {
 280  284          AuthenticationInfo cached = getAuth(key, null);
 281  285          if ((cached == null) && requestIsInProgress (key)) {
 282  286              /* check the cache again, it might contain an entry */
 283  287              cached = getAuth(key, null);
 284  288          }
 285  289          return cached;
 286  290      }
 287  291  
 288  292  
 289  293      /**
↓ open down ↓ 17 lines elided ↑ open up ↑
 307  311          String key = PROXY_AUTHENTICATION + "::" + host.toLowerCase() + ":" + port;
 308  312          AuthenticationInfo result = (AuthenticationInfo) cache.get(key, null);
 309  313          return result;
 310  314      }
 311  315  
 312  316      /**
 313  317       * Returns a firewall authentication, for the given host/port and realm.
 314  318       * Used in response to a challenge. Note, the protocol field is always
 315  319       * blank for proxies.
 316  320       */
 317      -    static AuthenticationInfo getProxyAuth(String host, int port, String realm, AuthScheme scheme) {
      321 +    static String getProxyAuthKey(String host, int port, String realm, AuthScheme scheme) {
 318  322          String key = PROXY_AUTHENTICATION + ":" + scheme + "::" + host.toLowerCase()
 319  323                          + ":" + port + ":" + realm;
      324 +        return key;
      325 +    }
      326 +
      327 +    static AuthenticationInfo getProxyAuth(String key) {
 320  328          AuthenticationInfo cached = (AuthenticationInfo) cache.get(key, null);
 321  329          if ((cached == null) && requestIsInProgress (key)) {
 322  330              /* check the cache again, it might contain an entry */
 323  331              cached = (AuthenticationInfo) cache.get(key, null);
 324  332          }
 325  333          return cached;
 326  334      }
 327  335  
 328  336  
 329  337      /**
 330  338       * Add this authentication to the cache
 331  339       */
 332  340      void addToCache() {
 333      -        cache.put (cacheKey(true), this);
      341 +        String key = cacheKey(true);
      342 +        cache.put(key, this);
 334  343          if (supportsPreemptiveAuthorization()) {
 335      -            cache.put (cacheKey(false), this);
      344 +            cache.put(cacheKey(false), this);
 336  345          }
 337      -        endAuthRequest();
      346 +        endAuthRequest(key);
 338  347      }
 339  348  
 340      -    void endAuthRequest () {
      349 +    static void endAuthRequest (String key) {
 341  350          if (!serializeAuth) {
 342  351              return;
 343  352          }
 344  353          synchronized (requests) {
 345      -            requestCompleted (cacheKey(true));
      354 +            requestCompleted(key);
 346  355          }
 347  356      }
 348  357  
 349  358      /**
 350  359       * Remove this authentication from the cache
 351  360       */
 352  361      void removeFromCache() {
 353  362          cache.remove(cacheKey(true), this);
 354  363          if (supportsPreemptiveAuthorization()) {
 355  364              cache.remove(cacheKey(false), this);
↓ open down ↓ 86 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX