--- /dev/null
+# 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.
+
+uuidGenerator.createRandom=Creation of SecureRandom instance for UUID generation using [{0}] took [{1}] milliseconds.
import java.security.SecureRandom;
import java.util.Random;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
/**
* simple generation of a UUID
* @author Filip Hanik
* @version 1.0
*/
public class UUIDGenerator {
+ private static final Log log = LogFactory.getLog(UUIDGenerator.class);
+ protected static final StringManager sm =
+ StringManager.getManager("org.apache.catalina.tribes.util");
+
public static final int UUID_LENGTH = 16;
public static final int UUID_VERSION = 4;
public static final int BYTES_PER_INT = 4;
protected static SecureRandom secrand = null;
protected static Random rand = new Random();
+
static {
+ long start = System.currentTimeMillis();
secrand = new SecureRandom();
- secrand.setSeed(rand.nextLong());
+ // seed the generator
+ secrand.nextInt();
+ long time = System.currentTimeMillis() - start;
+ if (time > 100) {
+ log.info(sm.getString("uuidGenerator.createRandom",
+ secrand.getAlgorithm(), Long.valueOf(time)));
+ }
}
public static byte[] randomUUID(boolean secure) {
</fix>
</changelog>
</subsection>
+ <subsection name="Cluster">
+ <changelog>
+ <fix>
+ Securely seed the SecureRandom instance used for UUID generation and
+ report excessive creation time (greater than 100ms) at INFO level.
+ (markt)
+ </fix>
+ </changelog>
+ </subsection>
<subsection name="Web applications">
<changelog>
<fix>