From 1e1b85270f93b3bca624c99b478f3a9a23be2395 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Sat, 29 Sep 2012 23:40:46 -0400
Subject: [PATCH] Preliminary implementation of server-side forking (issue 137)

---
 src/com/gitblit/FileUserService.java |   43 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/src/com/gitblit/FileUserService.java b/src/com/gitblit/FileUserService.java
index b8d4a40..40bc3f6 100644
--- a/src/com/gitblit/FileUserService.java
+++ b/src/com/gitblit/FileUserService.java
@@ -85,6 +85,28 @@
 	}
 
 	/**
+	 * Does the user service support changes to user display name?
+	 * 
+	 * @return true or false
+	 * @since 1.0.0
+	 */
+	@Override
+	public boolean supportsDisplayNameChanges() {
+		return false;
+	}
+
+	/**
+	 * Does the user service support changes to user email address?
+	 * 
+	 * @return true or false
+	 * @since 1.0.0
+	 */
+	@Override
+	public boolean supportsEmailAddressChanges() {
+		return false;
+	}
+
+	/**
 	 * Does the user service support changes to team memberships?
 	 * 
 	 * @return true or false
@@ -111,13 +133,16 @@
 	 * @return cookie value
 	 */
 	@Override
-	public char[] getCookie(UserModel model) {
+	public String getCookie(UserModel model) {
+		if (!StringUtils.isEmpty(model.cookie)) {
+			return model.cookie;
+		}
 		Properties allUsers = super.read();
 		String value = allUsers.getProperty(model.username);
 		String[] roles = value.split(",");
 		String password = roles[0];
 		String cookie = StringUtils.getSHA1(model.username + password);
-		return cookie.toCharArray();
+		return cookie;
 	}
 
 	/**
@@ -178,6 +203,15 @@
 	}
 
 	/**
+	 * Logout a user.
+	 * 
+	 * @param user
+	 */
+	@Override
+	public void logout(UserModel user) {	
+	}
+
+	/**
 	 * Retrieve the user object for the specified username.
 	 * 
 	 * @param username
@@ -200,6 +234,8 @@
 				// Permissions
 				if (role.equalsIgnoreCase(Constants.ADMIN_ROLE)) {
 					model.canAdmin = true;
+				} else if (role.equalsIgnoreCase(Constants.FORK_ROLE)) {
+					model.canFork = true;
 				} else if (role.equalsIgnoreCase(Constants.NOT_FEDERATED_ROLE)) {
 					model.excludeFromFederation = true;
 				}
@@ -249,6 +285,9 @@
 			if (model.canAdmin) {
 				roles.add(Constants.ADMIN_ROLE);
 			}
+			if (model.canFork) {
+				roles.add(Constants.FORK_ROLE);
+			}
 			if (model.excludeFromFederation) {
 				roles.add(Constants.NOT_FEDERATED_ROLE);
 			}

--
Gitblit v1.9.1