jdk/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java
changeset 32649 2ee9017c7597
parent 25859 3317bb8137f4
child 42351 85ed90be0ae1
equal deleted inserted replaced
32648:1fa861caf840 32649:2ee9017c7597
    72                 "http.auth.serializeRequests")).booleanValue();
    72                 "http.auth.serializeRequests")).booleanValue();
    73     }
    73     }
    74 
    74 
    75     /* AuthCacheValue: */
    75     /* AuthCacheValue: */
    76 
    76 
    77     transient protected PasswordAuthentication pw;
    77     protected transient PasswordAuthentication pw;
    78 
    78 
    79     public PasswordAuthentication credentials() {
    79     public PasswordAuthentication credentials() {
    80         return pw;
    80         return pw;
    81     }
    81     }
    82 
    82 
   111      * Authenticator for a particular realm is single threaded.
   111      * Authenticator for a particular realm is single threaded.
   112      * ie. if multiple threads need to get credentials from the user
   112      * ie. if multiple threads need to get credentials from the user
   113      * at the same time, then all but the first will block until
   113      * at the same time, then all but the first will block until
   114      * the first completes its authentication.
   114      * the first completes its authentication.
   115      */
   115      */
   116     static private HashMap<String,Thread> requests = new HashMap<>();
   116     private static HashMap<String,Thread> requests = new HashMap<>();
   117 
   117 
   118     /* check if a request for this destination is in progress
   118     /* check if a request for this destination is in progress
   119      * return false immediately if not. Otherwise block until
   119      * return false immediately if not. Otherwise block until
   120      * request is finished and return true
   120      * request is finished and return true
   121      */
   121      */
   122     static private boolean requestIsInProgress (String key) {
   122     private static boolean requestIsInProgress (String key) {
   123         if (!serializeAuth) {
   123         if (!serializeAuth) {
   124             /* behavior is disabled. Revert to concurrent requests */
   124             /* behavior is disabled. Revert to concurrent requests */
   125             return false;
   125             return false;
   126         }
   126         }
   127         synchronized (requests) {
   127         synchronized (requests) {
   145     }
   145     }
   146 
   146 
   147     /* signal completion of an authentication (whether it succeeded or not)
   147     /* signal completion of an authentication (whether it succeeded or not)
   148      * so that other threads can continue.
   148      * so that other threads can continue.
   149      */
   149      */
   150     static private void requestCompleted (String key) {
   150     private static void requestCompleted (String key) {
   151         synchronized (requests) {
   151         synchronized (requests) {
   152             Thread thread = requests.get(key);
   152             Thread thread = requests.get(key);
   153             if (thread != null && thread == Thread.currentThread()) {
   153             if (thread != null && thread == Thread.currentThread()) {
   154                 boolean waspresent = requests.remove(key) != null;
   154                 boolean waspresent = requests.remove(key) != null;
   155                 assert waspresent;
   155                 assert waspresent;