From 0e44acbb2fec928a1606dc60f427a148fff405c9 Mon Sep 17 00:00:00 2001
From: Mohamed Ragab <moragab@gmail.com>
Date: Wed, 02 May 2012 11:15:01 -0400
Subject: [PATCH] Added a script to facilitate setting the proxy host and port and no proxy hosts, and then it concatenates all the java system properties for setting the java proxy configurations and puts the resulting string in an environment variable JAVA_PROXY_CONFIG, modified the scirpts gitblit,  gitblit-ubuntu, and gitblit-centos to source the java-proxy-config.sh script and then include the resulting java proxy configuration in the java command

---
 src/com/gitblit/GitBlit.java |   82 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 68 insertions(+), 14 deletions(-)

diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index 7b557d7..565b024 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -377,6 +377,38 @@
 		this.userService = userService;
 		this.userService.setup(settings);
 	}
+	
+	/**
+	 * 
+	 * @return true if the user service supports credential changes
+	 */
+	public boolean supportsCredentialChanges() {
+		return userService.supportsCredentialChanges();
+	}
+
+	/**
+	 * 
+	 * @return true if the user service supports display name changes
+	 */
+	public boolean supportsDisplayNameChanges() {
+		return userService.supportsDisplayNameChanges();
+	}
+
+	/**
+	 * 
+	 * @return true if the user service supports email address changes
+	 */
+	public boolean supportsEmailAddressChanges() {
+		return userService.supportsEmailAddressChanges();
+	}
+
+	/**
+	 * 
+	 * @return true if the user service supports team membership changes
+	 */
+	public boolean supportsTeamMembershipChanges() {
+		return userService.supportsTeamMembershipChanges();
+	}
 
 	/**
 	 * Authenticate a user based on a username and password.
@@ -464,6 +496,18 @@
 			userCookie.setPath("/");
 			response.addCookie(userCookie);
 		}
+	}
+	
+	/**
+	 * Logout a user.
+	 * 
+	 * @param user
+	 */
+	public void logout(UserModel user) {
+		if (userService == null) {
+			return;
+		}
+		userService.logout(user);
 	}
 
 	/**
@@ -1050,27 +1094,33 @@
 		config.setBoolean("gitblit", null, "showReadme", repository.showReadme);
 		config.setBoolean("gitblit", null, "skipSizeCalculation", repository.skipSizeCalculation);
 		config.setBoolean("gitblit", null, "skipSummaryMetrics", repository.skipSummaryMetrics);
-		config.setStringList("gitblit", null, "federationSets", repository.federationSets);
 		config.setString("gitblit", null, "federationStrategy",
 				repository.federationStrategy.name());
 		config.setBoolean("gitblit", null, "isFederated", repository.isFederated);
-		if (!ArrayUtils.isEmpty(repository.preReceiveScripts)) {
-			config.setStringList("gitblit", null, "preReceiveScript", repository.preReceiveScripts);
-		}
-		if (!ArrayUtils.isEmpty(repository.postReceiveScripts)) {
-			config.setStringList("gitblit", null, "postReceiveScript",
-					repository.postReceiveScripts);
-		}
-		if (!ArrayUtils.isEmpty(repository.mailingLists)) {
-			config.setStringList("gitblit", null, "mailingList", repository.mailingLists);
-		}
-		if (!ArrayUtils.isEmpty(repository.indexedBranches)) {
-			config.setStringList("gitblit", null, "indexBranch", repository.indexedBranches);
-		}
+
+		updateList(config, "federationSets", repository.federationSets);
+		updateList(config, "preReceiveScript", repository.preReceiveScripts);
+		updateList(config, "postReceiveScript", repository.postReceiveScripts);
+		updateList(config, "mailingList", repository.mailingLists);
+		updateList(config, "indexBranch", repository.indexedBranches);
+
 		try {
 			config.save();
 		} catch (IOException e) {
 			logger.error("Failed to save repository config!", e);
+		}
+	}
+	
+	private void updateList(StoredConfig config, String field, List<String> list) {
+		// a null list is skipped, not cleared
+		// this is for RPC administration where an older manager might be used
+		if (list == null) {
+			return;
+		}
+		if (ArrayUtils.isEmpty(list)) {
+			config.unset("gitblit", null, field);
+		} else {
+			config.setStringList("gitblit", null, field, list);
 		}
 	}
 
@@ -1746,6 +1796,10 @@
 	 */
 	private ServerSettings loadSettingModels() {
 		ServerSettings settingsModel = new ServerSettings();
+		settingsModel.supportsCredentialChanges = userService.supportsCredentialChanges();
+		settingsModel.supportsDisplayNameChanges = userService.supportsDisplayNameChanges();
+		settingsModel.supportsEmailAddressChanges = userService.supportsEmailAddressChanges();
+		settingsModel.supportsTeamMembershipChanges = userService.supportsTeamMembershipChanges();
 		try {
 			// Read bundled Gitblit properties to extract setting descriptions.
 			// This copy is pristine and only used for populating the setting

--
Gitblit v1.9.1