Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

GitBlitServer.java 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. /*
  2. * Copyright 2011 gitblit.com.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.gitblit;
  17. import java.io.BufferedReader;
  18. import java.io.BufferedWriter;
  19. import java.io.File;
  20. import java.io.FileWriter;
  21. import java.io.IOException;
  22. import java.io.InputStream;
  23. import java.io.InputStreamReader;
  24. import java.io.OutputStream;
  25. import java.net.InetAddress;
  26. import java.net.ServerSocket;
  27. import java.net.Socket;
  28. import java.net.URI;
  29. import java.net.URL;
  30. import java.net.UnknownHostException;
  31. import java.security.ProtectionDomain;
  32. import java.text.MessageFormat;
  33. import java.util.ArrayList;
  34. import java.util.Date;
  35. import java.util.List;
  36. import java.util.Properties;
  37. import java.util.Scanner;
  38. import org.apache.log4j.PropertyConfigurator;
  39. import org.eclipse.jetty.security.ConstraintMapping;
  40. import org.eclipse.jetty.security.ConstraintSecurityHandler;
  41. import org.eclipse.jetty.server.HttpConfiguration;
  42. import org.eclipse.jetty.server.HttpConnectionFactory;
  43. import org.eclipse.jetty.server.Server;
  44. import org.eclipse.jetty.server.ServerConnector;
  45. import org.eclipse.jetty.server.session.HashSessionManager;
  46. import org.eclipse.jetty.util.security.Constraint;
  47. import org.eclipse.jetty.util.thread.QueuedThreadPool;
  48. import org.eclipse.jetty.webapp.WebAppContext;
  49. import org.eclipse.jgit.storage.file.FileBasedConfig;
  50. import org.eclipse.jgit.util.FS;
  51. import org.eclipse.jgit.util.FileUtils;
  52. import org.kohsuke.args4j.CmdLineException;
  53. import org.kohsuke.args4j.CmdLineParser;
  54. import org.kohsuke.args4j.Option;
  55. import org.slf4j.Logger;
  56. import org.slf4j.LoggerFactory;
  57. import com.gitblit.authority.GitblitAuthority;
  58. import com.gitblit.authority.NewCertificateConfig;
  59. import com.gitblit.servlet.GitblitContext;
  60. import com.gitblit.utils.StringUtils;
  61. import com.gitblit.utils.TimeUtils;
  62. import com.gitblit.utils.X509Utils;
  63. import com.gitblit.utils.X509Utils.X509Log;
  64. import com.gitblit.utils.X509Utils.X509Metadata;
  65. import com.unboundid.ldap.listener.InMemoryDirectoryServer;
  66. import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig;
  67. import com.unboundid.ldap.listener.InMemoryListenerConfig;
  68. import com.unboundid.ldif.LDIFReader;
  69. /**
  70. * GitBlitServer is the embedded Jetty server for Gitblit GO. This class starts
  71. * and stops an instance of Jetty that is configured from a combination of the
  72. * gitblit.properties file and command line parameters. JCommander is used to
  73. * simplify command line parameter processing. This class also automatically
  74. * generates a self-signed certificate for localhost, if the keystore does not
  75. * already exist.
  76. *
  77. * @author James Moger
  78. *
  79. */
  80. public class GitBlitServer {
  81. private static Logger logger;
  82. public static void main(String... args) {
  83. GitBlitServer server = new GitBlitServer();
  84. // filter out the baseFolder parameter
  85. List<String> filtered = new ArrayList<String>();
  86. String folder = "data";
  87. for (int i = 0; i < args.length; i++) {
  88. String arg = args[i];
  89. if (arg.equals("--baseFolder")) {
  90. if (i + 1 == args.length) {
  91. System.out.println("Invalid --baseFolder parameter!");
  92. System.exit(-1);
  93. } else if (!".".equals(args[i + 1])) {
  94. folder = args[i + 1];
  95. }
  96. i = i + 1;
  97. } else {
  98. filtered.add(arg);
  99. }
  100. }
  101. Params.baseFolder = folder;
  102. Params params = new Params();
  103. CmdLineParser parser = new CmdLineParser(params);
  104. try {
  105. parser.parseArgument(filtered);
  106. if (params.help) {
  107. server.usage(parser, null);
  108. }
  109. } catch (CmdLineException t) {
  110. server.usage(parser, t);
  111. }
  112. if (params.stop) {
  113. server.stop(params);
  114. } else {
  115. server.start(params);
  116. }
  117. }
  118. /**
  119. * Display the command line usage of Gitblit GO.
  120. *
  121. * @param parser
  122. * @param t
  123. */
  124. protected final void usage(CmdLineParser parser, CmdLineException t) {
  125. System.out.println(Constants.BORDER);
  126. System.out.println(Constants.getGitBlitVersion());
  127. System.out.println(Constants.BORDER);
  128. System.out.println();
  129. if (t != null) {
  130. System.out.println(t.getMessage());
  131. System.out.println();
  132. }
  133. if (parser != null) {
  134. parser.printUsage(System.out);
  135. System.out
  136. .println("\nExample:\n java -server -Xmx1024M -jar gitblit.jar --repositoriesFolder c:\\git --httpPort 80 --httpsPort 443");
  137. }
  138. System.exit(0);
  139. }
  140. protected File getBaseFolder(Params params) {
  141. String path = System.getProperty("GITBLIT_HOME", Params.baseFolder);
  142. if (!StringUtils.isEmpty(System.getenv("GITBLIT_HOME"))) {
  143. path = System.getenv("GITBLIT_HOME");
  144. }
  145. return new File(path).getAbsoluteFile();
  146. }
  147. /**
  148. * Stop Gitblt GO.
  149. */
  150. public void stop(Params params) {
  151. try {
  152. Socket s = new Socket(InetAddress.getByName("127.0.0.1"), params.shutdownPort);
  153. OutputStream out = s.getOutputStream();
  154. System.out.println("Sending Shutdown Request to " + Constants.NAME);
  155. out.write("\r\n".getBytes());
  156. out.flush();
  157. s.close();
  158. } catch (UnknownHostException e) {
  159. e.printStackTrace();
  160. } catch (IOException e) {
  161. e.printStackTrace();
  162. }
  163. }
  164. /**
  165. * Start Gitblit GO.
  166. */
  167. protected final void start(Params params) {
  168. final File baseFolder = getBaseFolder(params);
  169. FileSettings settings = params.FILESETTINGS;
  170. if (!StringUtils.isEmpty(params.settingsfile)) {
  171. if (new File(params.settingsfile).exists()) {
  172. settings = new FileSettings(params.settingsfile);
  173. }
  174. }
  175. if (params.dailyLogFile) {
  176. // Configure log4j for daily log file generation
  177. InputStream is = null;
  178. try {
  179. is = getClass().getResourceAsStream("/log4j.properties");
  180. Properties loggingProperties = new Properties();
  181. loggingProperties.load(is);
  182. loggingProperties.put("log4j.appender.R.File", new File(baseFolder, "logs/gitblit.log").getAbsolutePath());
  183. loggingProperties.put("log4j.rootCategory", "INFO, R");
  184. if (settings.getBoolean(Keys.web.debugMode, false)) {
  185. loggingProperties.put("log4j.logger.com.gitblit", "DEBUG");
  186. }
  187. PropertyConfigurator.configure(loggingProperties);
  188. } catch (Exception e) {
  189. e.printStackTrace();
  190. } finally {
  191. try {
  192. if (is != null) {
  193. is.close();
  194. }
  195. } catch (IOException e) {
  196. e.printStackTrace();
  197. }
  198. }
  199. }
  200. logger = LoggerFactory.getLogger(GitBlitServer.class);
  201. logger.info("\n" + Constants.getASCIIArt());
  202. System.setProperty("java.awt.headless", "true");
  203. String osname = System.getProperty("os.name");
  204. String osversion = System.getProperty("os.version");
  205. logger.info("Running on " + osname + " (" + osversion + ")");
  206. QueuedThreadPool threadPool = new QueuedThreadPool();
  207. int maxThreads = settings.getInteger(Keys.server.threadPoolSize, 50);
  208. if (maxThreads > 0) {
  209. threadPool.setMaxThreads(maxThreads);
  210. }
  211. Server server = new Server(threadPool);
  212. server.setStopAtShutdown(true);
  213. // conditionally configure the https connector
  214. if (params.securePort > 0) {
  215. File certificatesConf = new File(baseFolder, X509Utils.CA_CONFIG);
  216. File serverKeyStore = new File(baseFolder, X509Utils.SERVER_KEY_STORE);
  217. File serverTrustStore = new File(baseFolder, X509Utils.SERVER_TRUST_STORE);
  218. File caRevocationList = new File(baseFolder, X509Utils.CA_REVOCATION_LIST);
  219. // generate CA & web certificates, create certificate stores
  220. X509Metadata metadata = new X509Metadata("localhost", params.storePassword);
  221. // set default certificate values from config file
  222. if (certificatesConf.exists()) {
  223. FileBasedConfig config = new FileBasedConfig(certificatesConf, FS.detect());
  224. try {
  225. config.load();
  226. } catch (Exception e) {
  227. logger.error("Error parsing " + certificatesConf, e);
  228. }
  229. NewCertificateConfig certificateConfig = NewCertificateConfig.KEY.parse(config);
  230. certificateConfig.update(metadata);
  231. }
  232. metadata.notAfter = new Date(System.currentTimeMillis() + 10*TimeUtils.ONEYEAR);
  233. X509Utils.prepareX509Infrastructure(metadata, baseFolder, new X509Log() {
  234. @Override
  235. public void log(String message) {
  236. BufferedWriter writer = null;
  237. try {
  238. writer = new BufferedWriter(new FileWriter(new File(baseFolder, X509Utils.CERTS + File.separator + "log.txt"), true));
  239. writer.write(MessageFormat.format("{0,date,yyyy-MM-dd HH:mm}: {1}", new Date(), message));
  240. writer.newLine();
  241. writer.flush();
  242. } catch (Exception e) {
  243. LoggerFactory.getLogger(GitblitAuthority.class).error("Failed to append log entry!", e);
  244. } finally {
  245. if (writer != null) {
  246. try {
  247. writer.close();
  248. } catch (IOException e) {
  249. }
  250. }
  251. }
  252. }
  253. });
  254. if (serverKeyStore.exists()) {
  255. /*
  256. * HTTPS
  257. */
  258. logger.info("Setting up HTTPS transport on port " + params.securePort);
  259. GitblitSslContextFactory factory = new GitblitSslContextFactory(params.alias,
  260. serverKeyStore, serverTrustStore, params.storePassword, caRevocationList);
  261. if (params.requireClientCertificates) {
  262. factory.setNeedClientAuth(true);
  263. } else {
  264. factory.setWantClientAuth(true);
  265. }
  266. ServerConnector connector = new ServerConnector(server, factory);
  267. connector.setSoLingerTime(-1);
  268. connector.setIdleTimeout(30000);
  269. connector.setPort(params.securePort);
  270. String bindInterface = settings.getString(Keys.server.httpsBindInterface, null);
  271. if (!StringUtils.isEmpty(bindInterface)) {
  272. logger.warn(MessageFormat.format(
  273. "Binding HTTPS transport on port {0,number,0} to {1}", params.securePort,
  274. bindInterface));
  275. connector.setHost(bindInterface);
  276. }
  277. if (params.securePort < 1024 && !isWindows()) {
  278. logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
  279. }
  280. server.addConnector(connector);
  281. } else {
  282. logger.warn("Failed to find or load Keystore?");
  283. logger.warn("HTTPS transport DISABLED.");
  284. }
  285. }
  286. // conditionally configure the http transport
  287. if (params.port > 0) {
  288. /*
  289. * HTTP
  290. */
  291. logger.info("Setting up HTTP transport on port " + params.port);
  292. HttpConfiguration httpConfig = new HttpConfiguration();
  293. if (params.port > 0 && params.securePort > 0 && settings.getBoolean(Keys.server.redirectToHttpsPort, true)) {
  294. httpConfig.setSecureScheme("https");
  295. httpConfig.setSecurePort(params.securePort);
  296. }
  297. httpConfig.setSendServerVersion(false);
  298. httpConfig.setSendDateHeader(false);
  299. ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
  300. connector.setSoLingerTime(-1);
  301. connector.setIdleTimeout(30000);
  302. connector.setPort(params.port);
  303. String bindInterface = settings.getString(Keys.server.httpBindInterface, null);
  304. if (!StringUtils.isEmpty(bindInterface)) {
  305. logger.warn(MessageFormat.format("Binding HTTP transport on port {0,number,0} to {1}",
  306. params.port, bindInterface));
  307. connector.setHost(bindInterface);
  308. }
  309. if (params.port < 1024 && !isWindows()) {
  310. logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
  311. }
  312. server.addConnector(connector);
  313. }
  314. // tempDir is where the embedded Gitblit web application is expanded and
  315. // where Jetty creates any necessary temporary files
  316. File tempDir = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, baseFolder, params.temp);
  317. if (tempDir.exists()) {
  318. try {
  319. FileUtils.delete(tempDir, FileUtils.RECURSIVE | FileUtils.RETRY);
  320. } catch (IOException x) {
  321. logger.warn("Failed to delete temp dir " + tempDir.getAbsolutePath(), x);
  322. }
  323. }
  324. if (!tempDir.mkdirs()) {
  325. logger.warn("Failed to create temp dir " + tempDir.getAbsolutePath());
  326. }
  327. // Get the execution path of this class
  328. // We use this to set the WAR path.
  329. ProtectionDomain protectionDomain = GitBlitServer.class.getProtectionDomain();
  330. URL location = protectionDomain.getCodeSource().getLocation();
  331. // Root WebApp Context
  332. WebAppContext rootContext = new WebAppContext();
  333. rootContext.setContextPath(settings.getString(Keys.server.contextPath, "/"));
  334. rootContext.setServer(server);
  335. rootContext.setWar(location.toExternalForm());
  336. rootContext.setTempDirectory(tempDir);
  337. // Set cookies HttpOnly so they are not accessible to JavaScript engines
  338. HashSessionManager sessionManager = new HashSessionManager();
  339. sessionManager.setHttpOnly(true);
  340. // Use secure cookies if only serving https
  341. sessionManager.setSecureRequestOnly( (params.port <= 0 && params.securePort > 0) ||
  342. (params.port > 0 && params.securePort > 0 && settings.getBoolean(Keys.server.redirectToHttpsPort, true)) );
  343. rootContext.getSessionHandler().setSessionManager(sessionManager);
  344. // Ensure there is a defined User Service
  345. String realmUsers = params.userService;
  346. if (StringUtils.isEmpty(realmUsers)) {
  347. logger.error(MessageFormat.format("PLEASE SPECIFY {0}!!", Keys.realm.userService));
  348. return;
  349. }
  350. // Override settings from the command-line
  351. settings.overrideSetting(Keys.realm.userService, params.userService);
  352. settings.overrideSetting(Keys.git.repositoriesFolder, params.repositoriesFolder);
  353. settings.overrideSetting(Keys.git.daemonPort, params.gitPort);
  354. settings.overrideSetting(Keys.git.sshPort, params.sshPort);
  355. // Start up an in-memory LDAP server, if configured
  356. try {
  357. if (!StringUtils.isEmpty(params.ldapLdifFile)) {
  358. File ldifFile = new File(params.ldapLdifFile);
  359. if (ldifFile != null && ldifFile.exists()) {
  360. URI ldapUrl = new URI(settings.getRequiredString(Keys.realm.ldap.server));
  361. String firstLine = new Scanner(ldifFile).nextLine();
  362. String rootDN = firstLine.substring(4);
  363. String bindUserName = settings.getString(Keys.realm.ldap.username, "");
  364. String bindPassword = settings.getString(Keys.realm.ldap.password, "");
  365. // Get the port
  366. int port = ldapUrl.getPort();
  367. if (port == -1)
  368. port = 389;
  369. InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(rootDN);
  370. config.addAdditionalBindCredentials(bindUserName, bindPassword);
  371. config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", port));
  372. config.setSchema(null);
  373. InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
  374. ds.importFromLDIF(true, new LDIFReader(ldifFile));
  375. ds.startListening();
  376. logger.info("LDAP Server started at ldap://localhost:" + port);
  377. }
  378. }
  379. } catch (Exception e) {
  380. // Completely optional, just show a warning
  381. logger.warn("Unable to start LDAP server", e);
  382. }
  383. // Set the server's contexts
  384. server.setHandler(rootContext);
  385. // redirect HTTP requests to HTTPS
  386. if (params.port > 0 && params.securePort > 0 && settings.getBoolean(Keys.server.redirectToHttpsPort, true)) {
  387. logger.info(String.format("Configuring automatic http(%1$s) -> https(%2$s) redirects", params.port, params.securePort));
  388. // Create the internal mechanisms to handle secure connections and redirects
  389. Constraint constraint = new Constraint();
  390. constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
  391. ConstraintMapping cm = new ConstraintMapping();
  392. cm.setConstraint(constraint);
  393. cm.setPathSpec("/*");
  394. ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
  395. sh.setConstraintMappings(new ConstraintMapping[] { cm });
  396. // Configure this context to use the Security Handler defined before
  397. rootContext.setHandler(sh);
  398. }
  399. // Setup the Gitblit context
  400. GitblitContext gitblit = newGitblit(settings, baseFolder);
  401. rootContext.addEventListener(gitblit);
  402. try {
  403. // start the shutdown monitor
  404. if (params.shutdownPort > 0) {
  405. Thread shutdownMonitor = new ShutdownMonitorThread(server, params);
  406. shutdownMonitor.start();
  407. }
  408. // start Jetty
  409. server.start();
  410. server.join();
  411. } catch (Exception e) {
  412. e.printStackTrace();
  413. System.exit(100);
  414. }
  415. }
  416. protected GitblitContext newGitblit(IStoredSettings settings, File baseFolder) {
  417. return new GitblitContext(settings, baseFolder);
  418. }
  419. /**
  420. * Tests to see if the operating system is Windows.
  421. *
  422. * @return true if this is a windows machine
  423. */
  424. private boolean isWindows() {
  425. return System.getProperty("os.name").toLowerCase().indexOf("windows") > -1;
  426. }
  427. /**
  428. * The ShutdownMonitorThread opens a socket on a specified port and waits
  429. * for an incoming connection. When that connection is accepted a shutdown
  430. * message is issued to the running Jetty server.
  431. *
  432. * @author James Moger
  433. *
  434. */
  435. private static class ShutdownMonitorThread extends Thread {
  436. private final ServerSocket socket;
  437. private final Server server;
  438. private final Logger logger = LoggerFactory.getLogger(ShutdownMonitorThread.class);
  439. public ShutdownMonitorThread(Server server, Params params) {
  440. this.server = server;
  441. setDaemon(true);
  442. setName(Constants.NAME + " Shutdown Monitor");
  443. ServerSocket skt = null;
  444. try {
  445. skt = new ServerSocket(params.shutdownPort, 1, InetAddress.getByName("127.0.0.1"));
  446. } catch (Exception e) {
  447. logger.warn("Could not open shutdown monitor on port " + params.shutdownPort, e);
  448. }
  449. socket = skt;
  450. }
  451. @Override
  452. public void run() {
  453. // Only run if the socket was able to be created (not already in use, failed to bind, etc.)
  454. if (null != socket) {
  455. logger.info("Shutdown Monitor listening on port " + socket.getLocalPort());
  456. Socket accept;
  457. try {
  458. accept = socket.accept();
  459. BufferedReader reader = new BufferedReader(new InputStreamReader(
  460. accept.getInputStream()));
  461. reader.readLine();
  462. logger.info(Constants.BORDER);
  463. logger.info("Stopping " + Constants.NAME);
  464. logger.info(Constants.BORDER);
  465. server.stop();
  466. server.setStopAtShutdown(false);
  467. accept.close();
  468. socket.close();
  469. } catch (Exception e) {
  470. logger.warn("Failed to shutdown Jetty", e);
  471. }
  472. }
  473. }
  474. }
  475. /**
  476. * Parameters class for GitBlitServer.
  477. */
  478. public static class Params {
  479. public static String baseFolder;
  480. private final FileSettings FILESETTINGS = new FileSettings(new File(baseFolder, Constants.PROPERTIES_FILE).getAbsolutePath());
  481. /*
  482. * Server parameters
  483. */
  484. @Option(name = "--help", aliases = { "-h"}, usage = "Show this help")
  485. public Boolean help = false;
  486. @Option(name = "--stop", usage = "Stop Server")
  487. public Boolean stop = false;
  488. @Option(name = "--tempFolder", usage = "Folder for server to extract built-in webapp", metaVar="PATH")
  489. public String temp = FILESETTINGS.getString(Keys.server.tempFolder, "temp");
  490. @Option(name = "--dailyLogFile", usage = "Log to a rolling daily log file INSTEAD of stdout.")
  491. public Boolean dailyLogFile = false;
  492. /*
  493. * GIT Servlet Parameters
  494. */
  495. @Option(name = "--repositoriesFolder", usage = "Git Repositories Folder", metaVar="PATH")
  496. public String repositoriesFolder = FILESETTINGS.getString(Keys.git.repositoriesFolder,
  497. "git");
  498. /*
  499. * Authentication Parameters
  500. */
  501. @Option(name = "--userService", usage = "Authentication and Authorization Service (filename or fully qualified classname)")
  502. public String userService = FILESETTINGS.getString(Keys.realm.userService,
  503. "users.conf");
  504. /*
  505. * JETTY Parameters
  506. */
  507. @Option(name = "--httpPort", usage = "HTTP port for to serve. (port <= 0 will disable this connector)", metaVar="PORT")
  508. public Integer port = FILESETTINGS.getInteger(Keys.server.httpPort, 0);
  509. @Option(name = "--httpsPort", usage = "HTTPS port to serve. (port <= 0 will disable this connector)", metaVar="PORT")
  510. public Integer securePort = FILESETTINGS.getInteger(Keys.server.httpsPort, 8443);
  511. @Option(name = "--gitPort", usage = "Git Daemon port to serve. (port <= 0 will disable this connector)", metaVar="PORT")
  512. public Integer gitPort = FILESETTINGS.getInteger(Keys.git.daemonPort, 9418);
  513. @Option(name = "--sshPort", usage = "Git SSH port to serve. (port <= 0 will disable this connector)", metaVar = "PORT")
  514. public Integer sshPort = FILESETTINGS.getInteger(Keys.git.sshPort, 29418);
  515. @Option(name = "--alias", usage = "Alias of SSL certificate in keystore for serving https.", metaVar="ALIAS")
  516. public String alias = FILESETTINGS.getString(Keys.server.certificateAlias, "");
  517. @Option(name = "--storePassword", usage = "Password for SSL (https) keystore.", metaVar="PASSWORD")
  518. public String storePassword = FILESETTINGS.getString(Keys.server.storePassword, "");
  519. @Option(name = "--shutdownPort", usage = "Port for Shutdown Monitor to listen on. (port <= 0 will disable this monitor)", metaVar="PORT")
  520. public Integer shutdownPort = FILESETTINGS.getInteger(Keys.server.shutdownPort, 8081);
  521. @Option(name = "--requireClientCertificates", usage = "Require client X509 certificates for https connections.")
  522. public Boolean requireClientCertificates = FILESETTINGS.getBoolean(Keys.server.requireClientCertificates, false);
  523. /*
  524. * Setting overrides
  525. */
  526. @Option(name = "--settings", usage = "Path to alternative settings", metaVar="FILE")
  527. public String settingsfile;
  528. @Option(name = "--ldapLdifFile", usage = "Path to LDIF file. This will cause an in-memory LDAP server to be started according to gitblit settings", metaVar="FILE")
  529. public String ldapLdifFile;
  530. }
  531. }