summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/models
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2012-10-11 18:11:50 -0400
committerJames Moger <james.moger@gitblit.com>2012-10-11 18:11:50 -0400
commit15640f86032169ad9bfef17c387b94f30a61582f (patch)
tree6f3dc7bb8248f2d239da6c6d237de90921fed114 /src/com/gitblit/models
parentfa89b73e63911f5b216ac8c06e39cff8e987e3ba (diff)
downloadgitblit-15640f86032169ad9bfef17c387b94f30a61582f.tar.gz
gitblit-15640f86032169ad9bfef17c387b94f30a61582f.zip
Experimental committer verification
Diffstat (limited to 'src/com/gitblit/models')
-rw-r--r--src/com/gitblit/models/RepositoryModel.java1
-rw-r--r--src/com/gitblit/models/UserModel.java28
2 files changed, 29 insertions, 0 deletions
diff --git a/src/com/gitblit/models/RepositoryModel.java b/src/com/gitblit/models/RepositoryModel.java
index 914523df..502f886e 100644
--- a/src/com/gitblit/models/RepositoryModel.java
+++ b/src/com/gitblit/models/RepositoryModel.java
@@ -75,6 +75,7 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
public boolean allowForks;
public Set<String> forks;
public String originRepository;
+ public boolean verifyCommitter;
public RepositoryModel() {
this("", "", "", new Date(0));
diff --git a/src/com/gitblit/models/UserModel.java b/src/com/gitblit/models/UserModel.java
index 6fe8df2b..8b3fe826 100644
--- a/src/com/gitblit/models/UserModel.java
+++ b/src/com/gitblit/models/UserModel.java
@@ -405,4 +405,32 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
public int compareTo(UserModel o) {
return username.compareTo(o.username);
}
+
+ /**
+ * Returns true if the name/email pair match this user account.
+ *
+ * @param name
+ * @param email
+ * @return true, if the name and email address match this account
+ */
+ public boolean is(String name, String email) {
+ // at a minimum a usename or display name must be supplied
+ if (StringUtils.isEmpty(name)) {
+ return false;
+ }
+ boolean nameVerified = name.equalsIgnoreCase(username) || name.equalsIgnoreCase(getDisplayName());
+ boolean emailVerified = false;
+ if (StringUtils.isEmpty(emailAddress)) {
+ // user account has not specified an email address
+ // rely on username/displayname verification
+ emailVerified = true;
+ } else {
+ // user account has specified an email address
+ // require email address verification
+ if (!StringUtils.isEmpty(email)) {
+ emailVerified = email.equalsIgnoreCase(emailAddress);
+ }
+ }
+ return nameVerified && emailVerified;
+ }
}