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/GitBlitServer.java |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/com/gitblit/GitBlitServer.java b/src/com/gitblit/GitBlitServer.java
index e8ee89c..f0dce77 100644
--- a/src/com/gitblit/GitBlitServer.java
+++ b/src/com/gitblit/GitBlitServer.java
@@ -23,6 +23,7 @@
 import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
+import java.net.URI;
 import java.net.URL;
 import java.net.UnknownHostException;
 import java.security.ProtectionDomain;
@@ -160,10 +161,12 @@
 		logger.info("");
 		logger.info(Constants.BORDER);
 
+		System.setProperty("java.awt.headless", "true");
+
 		String osname = System.getProperty("os.name");
 		String osversion = System.getProperty("os.version");
 		logger.info("Running on " + osname + " (" + osversion + ")");
-
+		
 		List<Connector> connectors = new ArrayList<Connector>();
 
 		// conditionally configure the http connector
@@ -277,21 +280,27 @@
 			if (StringUtils.isEmpty(params.ldapLdifFile) == false) {
 				File ldifFile = new File(params.ldapLdifFile);
 				if (ldifFile != null && ldifFile.exists()) {
+					URI ldapUrl = new URI(settings.getRequiredString(Keys.realm.ldap.server));
 					String firstLine = new Scanner(ldifFile).nextLine();
 					String rootDN = firstLine.substring(4);
-					String bindUserName = settings.getString(Keys.realm.ldap_username, "");
-					String bindPassword = settings.getString(Keys.realm.ldap_password, "");
+					String bindUserName = settings.getString(Keys.realm.ldap.username, "");
+					String bindPassword = settings.getString(Keys.realm.ldap.password, "");
+					
+					// Get the port
+					int port = ldapUrl.getPort();
+					if (port == -1)
+						port = 389;
 					
 					InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(rootDN);
 					config.addAdditionalBindCredentials(bindUserName, bindPassword);
-					config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", 389));
+					config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", port));
 					config.setSchema(null);
 					
 					InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
 					ds.importFromLDIF(true, new LDIFReader(ldifFile));
 					ds.startListening();
 					
-					logger.info("LDAP Server started at ldap://localhost:389");
+					logger.info("LDAP Server started at ldap://localhost:" + port);
 				}
 			}
 		} catch (Exception e) {

--
Gitblit v1.9.1