changing Math.random to SecureRandom
diff --git a/src/main/java/com/gitblit/models/UserModel.java b/src/main/java/com/gitblit/models/UserModel.java
index d411e50..edbdf02 100644
--- a/src/main/java/com/gitblit/models/UserModel.java
+++ b/src/main/java/com/gitblit/models/UserModel.java
@@ -17,6 +17,7 @@
import java.io.Serializable;
import java.security.Principal;
+import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -662,6 +663,9 @@
}
public String createCookie() {
- return StringUtils.getSHA1(String.valueOf(Math.random()));
+ SecureRandom random = new SecureRandom();
+ byte[] values = new byte[20];
+ random.nextBytes(values);
+ return StringUtils.getSHA1(String.valueOf(values));
}
}