From 12cb80a8360a2430ee46979a0e86985fa0f3715b Mon Sep 17 00:00:00 2001 From: markt Date: Mon, 10 Oct 2011 11:21:52 +0000 Subject: [PATCH] After some testing with DIGEST auth, this approach is slower git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1180877 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/catalina/util/MsgDigest.java | 77 ---------------------------- 1 file changed, 77 deletions(-) delete mode 100644 java/org/apache/catalina/util/MsgDigest.java diff --git a/java/org/apache/catalina/util/MsgDigest.java b/java/org/apache/catalina/util/MsgDigest.java deleted file mode 100644 index 2cb48972d..000000000 --- a/java/org/apache/catalina/util/MsgDigest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.catalina.util; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; - - -/** - * Helper class for generating message digests in multi-threaded environments. - */ -public class MsgDigest { - - private static Helper md5 = new Helper("MD5"); - private static Helper sha1 = new Helper("SHA1"); - - public static byte[] getMD5(byte[] input) { - return md5.digest(input); - } - - public static byte[] getSHA1(byte[] input) { - return sha1.digest(input); - } - - private static class Helper { - - private final String digestName; - private final Queue digesters = - new ConcurrentLinkedQueue(); - - public Helper(String digestName) { - this.digestName = digestName; - } - - public byte[] digest(byte[] input) { - - // Get a digest from the queue - MessageDigest digest = digesters.poll(); - if (digest == null) { - // Queue empty, create a new one - try { - digest = MessageDigest.getInstance(digestName); - } catch (NoSuchAlgorithmException e) { - throw new IllegalArgumentException(e); - } - } - - // Reset the digest before we use it - digest.reset(); - - // Create the digest for the provided input - digest.update(input); - byte[] result = digest.digest(); - - // Return the digester to the queue - digesters.add(digest); - - return result; - } - } -} -- 2.11.0