tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1377853 - /tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java
Date Mon, 27 Aug 2012 20:53:57 GMT
Author: markt
Date: Mon Aug 27 20:53:56 2012
New Revision: 1377853

URL: http://svn.apache.org/viewvc?rev=1377853&view=rev
Log:
Improve concurrency of DIGEST auth

Modified:
    tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java

Modified: tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java?rev=1377853&r1=1377852&r2=1377853&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java (original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java Mon Aug 27
20:53:56 2012
@@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletRes
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.Realm;
 import org.apache.catalina.connector.Request;
+import org.apache.catalina.util.ConcurrentMessageDigest;
 import org.apache.catalina.util.MD5Encoder;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -76,8 +77,10 @@ public class DigestAuthenticator extends
 
     /**
      * MD5 message digest provider.
+     * @deprecated  Unused - will be removed in Tomcat 8.0.x onwards
      */
-     protected static volatile MessageDigest md5Helper;
+    @Deprecated
+    protected static volatile MessageDigest md5Helper;
 
 
     /**
@@ -308,12 +311,8 @@ public class DigestAuthenticator extends
         String ipTimeKey =
             request.getRemoteAddr() + ":" + currentTime + ":" + getKey();
 
-        byte[] buffer;
-        synchronized (md5Helper) {
-            buffer = md5Helper.digest(
-                    ipTimeKey.getBytes(B2CConverter.ISO_8859_1));
-        }
-
+        byte[] buffer = ConcurrentMessageDigest.digestMD5(
+                ipTimeKey.getBytes(B2CConverter.ISO_8859_1));
         String nonce = currentTime + ":" + MD5Encoder.encode(buffer);
 
         NonceInfo info = new NonceInfo(currentTime, 100);
@@ -583,11 +582,8 @@ public class DigestAuthenticator extends
             }
             String serverIpTimeKey =
                 request.getRemoteAddr() + ":" + nonceTime + ":" + key;
-            byte[] buffer = null;
-            synchronized (md5Helper) {
-                buffer = md5Helper.digest(
-                        serverIpTimeKey.getBytes(B2CConverter.ISO_8859_1));
-            }
+            byte[] buffer = ConcurrentMessageDigest.digestMD5(
+                    serverIpTimeKey.getBytes(B2CConverter.ISO_8859_1));
             String md5ServerIpTimeKey = MD5Encoder.encode(buffer);
             if (!md5ServerIpTimeKey.equals(md5clientIpTimeKey)) {
                 return false;
@@ -645,10 +641,8 @@ public class DigestAuthenticator extends
             // MD5(Method + ":" + uri)
             String a2 = method + ":" + uri;
 
-            byte[] buffer;
-            synchronized (md5Helper) {
-                buffer = md5Helper.digest(a2.getBytes(B2CConverter.ISO_8859_1));
-            }
+            byte[] buffer = ConcurrentMessageDigest.digestMD5(
+                    a2.getBytes(B2CConverter.ISO_8859_1));
             String md5a2 = MD5Encoder.encode(buffer);
 
             return realm.authenticate(userName, response, nonce, nc, cnonce,



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message