Top Description Fields Constructors Methods
org.apache.tomcat.util.security

public Class ConcurrentMessageDigest

extends Object
Class Inheritance
Imports
java.security.MessageDigest, .NoSuchAlgorithmException, java.util.Map, .Queue, java.util.concurrent.ConcurrentHashMap, .ConcurrentLinkedQueue, org.apache.tomcat.util.res.StringManager

A thread safe wrapper around MessageDigest that does not make use of ThreadLocal and - broadly - only creates enough MessageDigest objects to satisfy the concurrency requirements.

Field Summary

Modifier and TypeField and Description
private static final String
private static final Map<String, Queue<MessageDigest>>
private static final String
private static final StringManager

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static byte[]
digest(String algorithm, byte[]... input)

public static byte[]
digest(String algorithm, int iterations, byte[]... input)

public static byte[]
digestMD5(byte[]... input)

public static byte[]
digestSHA1(byte[]... input)

public static void
init(String
The message digest algorithm to be supported
algorithm
)

Ensures that digest(String, byte[][]) will support the specified algorithm.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MD5back to summary
private static final String MD5
queuesback to summary
private static final Map<String, Queue<MessageDigest>> queues
SHA1back to summary
private static final String SHA1
smback to summary
private static final StringManager sm

Constructor Detail

ConcurrentMessageDigestback to summary
private ConcurrentMessageDigest()

Method Detail

digestback to summary
public static byte[] digest(String algorithm, byte[]... input)
digestback to summary
public static byte[] digest(String algorithm, int iterations, byte[]... input)
digestMD5back to summary
public static byte[] digestMD5(byte[]... input)
digestSHA1back to summary
public static byte[] digestSHA1(byte[]... input)
initback to summary
public static void init(String algorithm) throws NoSuchAlgorithmException

Ensures that digest(String, byte[][]) will support the specified algorithm. This method must be called and return successfully before using digest(String, byte[][]).

Parameters
algorithm:String

The message digest algorithm to be supported

Exceptions
NoSuchAlgorithmException:
If the algorithm is not supported by the JVM