< prev index next >

src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD

@@ -277,11 +277,11 @@
         HeaderParser p = new HeaderParser (header);
         String s = p.findValue ("stale");
         if (s == null || !s.equals("true"))
             return false;
         String newNonce = p.findValue ("nonce");
-        if (newNonce == null || "".equals(newNonce)) {
+        if (newNonce == null || newNonce.isEmpty()) {
             return false;
         }
         params.setNonce (newNonce);
         return true;
     }

@@ -321,11 +321,11 @@
             // here.
             authMethod = Character.toUpperCase(authMethod.charAt(0))
                         + authMethod.substring(1).toLowerCase();
         }
         String algorithm = p.findValue("algorithm");
-        if (algorithm == null || "".equals(algorithm)) {
+        if (algorithm == null || algorithm.isEmpty()) {
             algorithm = "MD5";  // The default, accoriding to rfc2069
         }
         params.setAlgorithm (algorithm);
 
         // If authQop is true, then the server is doing RFC2617 and

@@ -449,11 +449,11 @@
             if (!rspauth.equals (expected)) {
                 throw new ProtocolException ("Response digest invalid");
             }
             /* Check if there is a nextnonce field */
             String nextnonce = p.findValue ("nextnonce");
-            if (nextnonce != null && ! "".equals(nextnonce)) {
+            if (nextnonce != null && !nextnonce.isEmpty()) {
                 params.setNonce (nextnonce);
             }
 
         } catch (NoSuchAlgorithmException ex) {
             throw new ProtocolException ("Unsupported algorithm in response");
< prev index next >