summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/models
diff options
context:
space:
mode:
authorFlorian Zschocke <florian.zschocke@devolo.de>2016-12-13 16:56:59 +0100
committerFlorian Zschocke <florian.zschocke@devolo.de>2016-12-13 16:57:39 +0100
commitbf179e6e1a1cf422076af2d5ef471f85a7ecf6e2 (patch)
treebe18999b9ff48d4201e795c6459d3c2eb5c39601 /src/main/java/com/gitblit/models
parent9a51d2bf8ed3663715fc735afb0444e179c334f7 (diff)
parent2be2c2c95c9a3747fd200e3ea3623607053d5299 (diff)
downloadgitblit-bf179e6e1a1cf422076af2d5ef471f85a7ecf6e2.tar.gz
gitblit-bf179e6e1a1cf422076af2d5ef471f85a7ecf6e2.zip
Merge branch 'rcaa-master' into master.
Diffstat (limited to 'src/main/java/com/gitblit/models')
-rw-r--r--src/main/java/com/gitblit/models/UserModel.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/models/UserModel.java b/src/main/java/com/gitblit/models/UserModel.java
index e1522748..f8f7ed6d 100644
--- a/src/main/java/com/gitblit/models/UserModel.java
+++ b/src/main/java/com/gitblit/models/UserModel.java
@@ -17,6 +17,7 @@ package com.gitblit.models;
import java.io.Serializable;
import java.security.Principal;
+import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -36,6 +37,7 @@ import com.gitblit.Constants.PermissionType;
import com.gitblit.Constants.RegistrantType;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.ModelUtils;
+import com.gitblit.utils.SecureRandom;
import com.gitblit.utils.StringUtils;
/**
@@ -52,6 +54,8 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
public static final UserModel ANONYMOUS = new UserModel();
+ private static final SecureRandom RANDOM = new SecureRandom();
+
// field names are reflectively mapped in EditUser page
public String username;
public String password;
@@ -660,4 +664,8 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
String projectPath = StringUtils.getFirstPathElement(repository);
return !StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase(getPersonalPath());
}
+
+ public String createCookie() {
+ return StringUtils.getSHA1(RANDOM.randomBytes(32));
+ }
}