You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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. /**
  141. * Stop Gitblt GO.
  142. */
  143. public void stop(Params params) {
  144. try {
  145. Socket s = new Socket(InetAddress.getByName("127.0.0.1"), params.shutdownPort);
  146. OutputStream out = s.getOutputStream();
  147. System.out.println("Sending Shutdown Request to " + Constants.NAME);
  148. out.write("\r\n".getBytes());
  149. out.flush();
  150. s.close();
  151. } catch (UnknownHostException e) {
  152. e.printStackTrace();
  153. } catch (IOException e) {
  154. e.printStackTrace();
  155. }
  156. }
  157. /**
  158. * Start Gitblit GO.
  159. */
  160. protected final void start(Params params) {
  161. final File baseFolder = new File(Params.baseFolder).getAbsoluteFile();
  162. FileSettings settings = params.FILESETTINGS;
  163. if (!StringUtils.isEmpty(params.settingsfile)) {
  164. if (new File(params.settingsfile).exists()) {
  165. settings = new FileSettings(params.settingsfile);
  166. }
  167. }
  168. if (params.dailyLogFile) {
  169. // Configure log4j for daily log file generation
  170. InputStream is = null;
  171. try {
  172. is = getClass().getResourceAsStream("/log4j.properties");
  173. Properties loggingProperties = new Properties();
  174. loggingProperties.load(is);
  175. loggingProperties.put("log4j.appender.R.File", new File(baseFolder, "logs/gitblit.log").getAbsolutePath());
  176. loggingProperties.put("log4j.rootCategory", "INFO, R");
  177. if (settings.getBoolean(Keys.web.debugMode, false)) {
  178. loggingProperties.put("log4j.logger.com.gitblit", "DEBUG");
  179. }
  180. PropertyConfigurator.configure(loggingProperties);
  181. } catch (Exception e) {
  182. e.printStackTrace();
  183. } finally {
  184. try {
  185. is.close();
  186. } catch (IOException e) {
  187. e.printStackTrace();
  188. }
  189. }
  190. }
  191. logger = LoggerFactory.getLogger(GitBlitServer.class);
  192. logger.info(Constants.BORDER);
  193. logger.info(" _____ _ _ _ _ _ _");
  194. logger.info(" | __ \\(_)| | | | | |(_)| |");
  195. logger.info(" | | \\/ _ | |_ | |__ | | _ | |_");
  196. logger.info(" | | __ | || __|| '_ \\ | || || __|");
  197. logger.info(" | |_\\ \\| || |_ | |_) || || || |_");
  198. logger.info(" \\____/|_| \\__||_.__/ |_||_| \\__|");
  199. int spacing = (Constants.BORDER.length() - Constants.getGitBlitVersion().length()) / 2;
  200. StringBuilder sb = new StringBuilder();
  201. while (spacing > 0) {
  202. spacing--;
  203. sb.append(' ');
  204. }
  205. logger.info(sb.toString() + Constants.getGitBlitVersion());
  206. logger.info("");
  207. logger.info(Constants.BORDER);
  208. System.setProperty("java.awt.headless", "true");
  209. String osname = System.getProperty("os.name");
  210. String osversion = System.getProperty("os.version");
  211. logger.info("Running on " + osname + " (" + osversion + ")");
  212. QueuedThreadPool threadPool = new QueuedThreadPool();
  213. int maxThreads = settings.getInteger(Keys.server.threadPoolSize, 50);
  214. if (maxThreads > 0) {
  215. threadPool.setMaxThreads(maxThreads);
  216. }
  217. Server server = new Server(threadPool);
  218. server.setStopAtShutdown(true);
  219. // conditionally configure the https connector
  220. if (params.securePort > 0) {
  221. File certificatesConf = new File(baseFolder, X509Utils.CA_CONFIG);
  222. File serverKeyStore = new File(baseFolder, X509Utils.SERVER_KEY_STORE);
  223. File serverTrustStore = new File(baseFolder, X509Utils.SERVER_TRUST_STORE);
  224. File caRevocationList = new File(baseFolder, X509Utils.CA_REVOCATION_LIST);
  225. // generate CA & web certificates, create certificate stores
  226. X509Metadata metadata = new X509Metadata("localhost", params.storePassword);
  227. // set default certificate values from config file
  228. if (certificatesConf.exists()) {
  229. FileBasedConfig config = new FileBasedConfig(certificatesConf, FS.detect());
  230. try {
  231. config.load();
  232. } catch (Exception e) {
  233. logger.error("Error parsing " + certificatesConf, e);
  234. }
  235. NewCertificateConfig certificateConfig = NewCertificateConfig.KEY.parse(config);
  236. certificateConfig.update(metadata);
  237. }
  238. metadata.notAfter = new Date(System.currentTimeMillis() + 10*TimeUtils.ONEYEAR);
  239. X509Utils.prepareX509Infrastructure(metadata, baseFolder, new X509Log() {
  240. @Override
  241. public void log(String message) {
  242. BufferedWriter writer = null;
  243. try {
  244. writer = new BufferedWriter(new FileWriter(new File(baseFolder, X509Utils.CERTS + File.separator + "log.txt"), true));
  245. writer.write(MessageFormat.format("{0,date,yyyy-MM-dd HH:mm}: {1}", new Date(), message));
  246. writer.newLine();
  247. writer.flush();
  248. } catch (Exception e) {
  249. LoggerFactory.getLogger(GitblitAuthority.class).error("Failed to append log entry!", e);
  250. } finally {
  251. if (writer != null) {
  252. try {
  253. writer.close();
  254. } catch (IOException e) {
  255. }
  256. }
  257. }
  258. }
  259. });
  260. if (serverKeyStore.exists()) {
  261. /*
  262. * HTTPS
  263. */
  264. logger.info("Setting up HTTPS transport on port " + params.securePort);
  265. GitblitSslContextFactory factory = new GitblitSslContextFactory(params.alias,
  266. serverKeyStore, serverTrustStore, params.storePassword, caRevocationList);
  267. if (params.requireClientCertificates) {
  268. factory.setNeedClientAuth(true);
  269. } else {
  270. factory.setWantClientAuth(true);
  271. }
  272. ServerConnector connector = new ServerConnector(server, factory);
  273. connector.setSoLingerTime(-1);
  274. connector.setIdleTimeout(30000);
  275. connector.setPort(params.securePort);
  276. String bindInterface = settings.getString(Keys.server.httpsBindInterface, null);
  277. if (!StringUtils.isEmpty(bindInterface)) {
  278. logger.warn(MessageFormat.format(
  279. "Binding HTTPS transport on port {0,number,0} to {1}", params.securePort,
  280. bindInterface));
  281. connector.setHost(bindInterface);
  282. }
  283. if (params.securePort < 1024 && !isWindows()) {
  284. logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
  285. }
  286. server.addConnector(connector);
  287. } else {
  288. logger.warn("Failed to find or load Keystore?");
  289. logger.warn("HTTPS transport DISABLED.");
  290. }
  291. }
  292. // conditionally configure the http transport
  293. if (params.port > 0) {
  294. /*
  295. * HTTP
  296. */
  297. logger.info("Setting up HTTP transport on port " + params.port);
  298. HttpConfiguration httpConfig = new HttpConfiguration();
  299. if (params.port > 0 && params.securePort > 0 && settings.getBoolean(Keys.server.redirectToHttpsPort, true)) {
  300. httpConfig.setSecureScheme("https");
  301. httpConfig.setSecurePort(params.securePort);
  302. }
  303. httpConfig.setSendServerVersion(false);
  304. httpConfig.setSendDateHeader(false);
  305. ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
  306. connector.setSoLingerTime(-1);
  307. connector.setIdleTimeout(30000);
  308. connector.setPort(params.port);
  309. String bindInterface = settings.getString(Keys.server.httpBindInterface, null);
  310. if (!StringUtils.isEmpty(bindInterface)) {
  311. logger.warn(MessageFormat.format("Binding HTTP transport on port {0,number,0} to {1}",
  312. params.port, bindInterface));
  313. connector.setHost(bindInterface);
  314. }
  315. if (params.port < 1024 && !isWindows()) {
  316. logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
  317. }
  318. server.addConnector(connector);
  319. }
  320. // tempDir is where the embedded Gitblit web application is expanded and
  321. // where Jetty creates any necessary temporary files
  322. File tempDir = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, baseFolder, params.temp);
  323. if (tempDir.exists()) {
  324. try {
  325. FileUtils.delete(tempDir, FileUtils.RECURSIVE | FileUtils.RETRY);
  326. } catch (IOException x) {
  327. logger.warn("Failed to delete temp dir " + tempDir.getAbsolutePath(), x);
  328. }
  329. }
  330. if (!tempDir.mkdirs()) {
  331. logger.warn("Failed to create temp dir " + tempDir.getAbsolutePath());
  332. }
  333. // Get the execution path of this class
  334. // We use this to set the WAR path.
  335. ProtectionDomain protectionDomain = GitBlitServer.class.getProtectionDomain();
  336. URL location = protectionDomain.getCodeSource().getLocation();
  337. // Root WebApp Context
  338. WebAppContext rootContext = new WebAppContext();
  339. rootContext.setContextPath(settings.getString(Keys.server.contextPath, "/"));
  340. rootContext.setServer(server);
  341. rootContext.setWar(location.toExternalForm());
  342. rootContext.setTempDirectory(tempDir);
  343. // Set cookies HttpOnly so they are not accessible to JavaScript engines
  344. HashSessionManager sessionManager = new HashSessionManager();
  345. sessionManager.setHttpOnly(true);
  346. // Use secure cookies if only serving https
  347. sessionManager.setSecureRequestOnly(params.port <= 0 && params.securePort > 0);
  348. rootContext.getSessionHandler().setSessionManager(sessionManager);
  349. // Ensure there is a defined User Service
  350. String realmUsers = params.userService;
  351. if (StringUtils.isEmpty(realmUsers)) {
  352. logger.error(MessageFormat.format("PLEASE SPECIFY {0}!!", Keys.realm.userService));
  353. return;
  354. }
  355. // Override settings from the command-line
  356. settings.overrideSetting(Keys.realm.userService, params.userService);
  357. settings.overrideSetting(Keys.git.repositoriesFolder, params.repositoriesFolder);
  358. settings.overrideSetting(Keys.git.daemonPort, params.gitPort);
  359. settings.overrideSetting(Keys.git.sshPort, params.sshPort);
  360. // Start up an in-memory LDAP server, if configured
  361. try {
  362. if (!StringUtils.isEmpty(params.ldapLdifFile)) {
  363. File ldifFile = new File(params.ldapLdifFile);
  364. if (ldifFile != null && ldifFile.exists()) {
  365. URI ldapUrl = new URI(settings.getRequiredString(Keys.realm.ldap.server));
  366. String firstLine = new Scanner(ldifFile).nextLine();
  367. String rootDN = firstLine.substring(4);
  368. String bindUserName = settings.getString(Keys.realm.ldap.username, "");
  369. String bindPassword = settings.getString(Keys.realm.ldap.password, "");
  370. // Get the port
  371. int port = ldapUrl.getPort();
  372. if (port == -1)
  373. port = 389;
  374. InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(rootDN);
  375. config.addAdditionalBindCredentials(bindUserName, bindPassword);
  376. config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", port));
  377. config.setSchema(null);
  378. InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
  379. ds.importFromLDIF(true, new LDIFReader(ldifFile));
  380. ds.startListening();
  381. logger.info("LDAP Server started at ldap://localhost:" + port);
  382. }
  383. }
  384. } catch (Exception e) {
  385. // Completely optional, just show a warning
  386. logger.warn("Unable to start LDAP server", e);
  387. }
  388. // Set the server's contexts
  389. server.setHandler(rootContext);
  390. // redirect HTTP requests to HTTPS
  391. if (params.port > 0 && params.securePort > 0 && settings.getBoolean(Keys.server.redirectToHttpsPort, true)) {
  392. logger.info(String.format("Configuring automatic http(%1$s) -> https(%2$s) redirects", params.port, params.securePort));
  393. // Create the internal mechanisms to handle secure connections and redirects
  394. Constraint constraint = new Constraint();
  395. constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
  396. ConstraintMapping cm = new ConstraintMapping();
  397. cm.setConstraint(constraint);
  398. cm.setPathSpec("/*");
  399. ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
  400. sh.setConstraintMappings(new ConstraintMapping[] { cm });
  401. // Configure this context to use the Security Handler defined before
  402. rootContext.setHandler(sh);
  403. }
  404. // Setup the Gitblit context
  405. GitblitContext gitblit = newGitblit(settings, baseFolder);
  406. rootContext.addEventListener(gitblit);
  407. try {
  408. // start the shutdown monitor
  409. if (params.shutdownPort > 0) {
  410. Thread shutdownMonitor = new ShutdownMonitorThread(server, params);
  411. shutdownMonitor.start();
  412. }
  413. // start Jetty
  414. server.start();
  415. server.join();
  416. } catch (Exception e) {
  417. e.printStackTrace();
  418. System.exit(100);
  419. }
  420. }
  421. protected GitblitContext newGitblit(IStoredSettings settings, File baseFolder) {
  422. return new GitblitContext(settings, baseFolder);
  423. }
  424. /**
  425. * Tests to see if the operating system is Windows.
  426. *
  427. * @return true if this is a windows machine
  428. */
  429. private boolean isWindows() {
  430. return System.getProperty("os.name").toLowerCase().indexOf("windows") > -1;
  431. }
  432. /**
  433. * The ShutdownMonitorThread opens a socket on a specified port and waits
  434. * for an incoming connection. When that connection is accepted a shutdown
  435. * message is issued to the running Jetty server.
  436. *
  437. * @author James Moger
  438. *
  439. */
  440. private static class ShutdownMonitorThread extends Thread {
  441. private final ServerSocket socket;
  442. private final Server server;
  443. private final Logger logger = LoggerFactory.getLogger(ShutdownMonitorThread.class);
  444. public ShutdownMonitorThread(Server server, Params params) {
  445. this.server = server;
  446. setDaemon(true);
  447. setName(Constants.NAME + " Shutdown Monitor");
  448. ServerSocket skt = null;
  449. try {
  450. skt = new ServerSocket(params.shutdownPort, 1, InetAddress.getByName("127.0.0.1"));
  451. } catch (Exception e) {
  452. logger.warn("Could not open shutdown monitor on port " + params.shutdownPort, e);
  453. }
  454. socket = skt;
  455. }
  456. @Override
  457. public void run() {
  458. logger.info("Shutdown Monitor listening on port " + socket.getLocalPort());
  459. Socket accept;
  460. try {
  461. accept = socket.accept();
  462. BufferedReader reader = new BufferedReader(new InputStreamReader(
  463. accept.getInputStream()));
  464. reader.readLine();
  465. logger.info(Constants.BORDER);
  466. logger.info("Stopping " + Constants.NAME);
  467. logger.info(Constants.BORDER);
  468. server.stop();
  469. server.setStopAtShutdown(false);
  470. accept.close();
  471. socket.close();
  472. } catch (Exception e) {
  473. logger.warn("Failed to shutdown Jetty", e);
  474. }
  475. }
  476. }
  477. /**
  478. * Parameters class for GitBlitServer.
  479. */
  480. public static class Params {
  481. public static String baseFolder;
  482. private final FileSettings FILESETTINGS = new FileSettings(new File(baseFolder, Constants.PROPERTIES_FILE).getAbsolutePath());
  483. /*
  484. * Server parameters
  485. */
  486. @Option(name = "--help", aliases = { "-h"}, usage = "Show this help")
  487. public Boolean help = false;
  488. @Option(name = "--stop", usage = "Stop Server")
  489. public Boolean stop = false;
  490. @Option(name = "--tempFolder", usage = "Folder for server to extract built-in webapp", metaVar="PATH")
  491. public String temp = FILESETTINGS.getString(Keys.server.tempFolder, "temp");
  492. @Option(name = "--dailyLogFile", usage = "Log to a rolling daily log file INSTEAD of stdout.")
  493. public Boolean dailyLogFile = false;
  494. /*
  495. * GIT Servlet Parameters
  496. */
  497. @Option(name = "--repositoriesFolder", usage = "Git Repositories Folder", metaVar="PATH")
  498. public String repositoriesFolder = FILESETTINGS.getString(Keys.git.repositoriesFolder,
  499. "git");
  500. /*
  501. * Authentication Parameters
  502. */
  503. @Option(name = "--userService", usage = "Authentication and Authorization Service (filename or fully qualified classname)")
  504. public String userService = FILESETTINGS.getString(Keys.realm.userService,
  505. "users.conf");
  506. /*
  507. * JETTY Parameters
  508. */
  509. @Option(name = "--httpPort", usage = "HTTP port for to serve. (port <= 0 will disable this connector)", metaVar="PORT")
  510. public Integer port = FILESETTINGS.getInteger(Keys.server.httpPort, 0);
  511. @Option(name = "--httpsPort", usage = "HTTPS port to serve. (port <= 0 will disable this connector)", metaVar="PORT")
  512. public Integer securePort = FILESETTINGS.getInteger(Keys.server.httpsPort, 8443);
  513. @Option(name = "--gitPort", usage = "Git Daemon port to serve. (port <= 0 will disable this connector)", metaVar="PORT")
  514. public Integer gitPort = FILESETTINGS.getInteger(Keys.git.daemonPort, 9418);
  515. @Option(name = "--sshPort", usage = "Git SSH port to serve. (port <= 0 will disable this connector)", metaVar = "PORT")
  516. public Integer sshPort = FILESETTINGS.getInteger(Keys.git.sshPort, 29418);
  517. @Option(name = "--alias", usage = "Alias of SSL certificate in keystore for serving https.", metaVar="ALIAS")
  518. public String alias = FILESETTINGS.getString(Keys.server.certificateAlias, "");
  519. @Option(name = "--storePassword", usage = "Password for SSL (https) keystore.", metaVar="PASSWORD")
  520. public String storePassword = FILESETTINGS.getString(Keys.server.storePassword, "");
  521. @Option(name = "--shutdownPort", usage = "Port for Shutdown Monitor to listen on. (port <= 0 will disable this monitor)", metaVar="PORT")
  522. public Integer shutdownPort = FILESETTINGS.getInteger(Keys.server.shutdownPort, 8081);
  523. @Option(name = "--requireClientCertificates", usage = "Require client X509 certificates for https connections.")
  524. public Boolean requireClientCertificates = FILESETTINGS.getBoolean(Keys.server.requireClientCertificates, false);
  525. /*
  526. * Setting overrides
  527. */
  528. @Option(name = "--settings", usage = "Path to alternative settings", metaVar="FILE")
  529. public String settingsfile;
  530. @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")
  531. public String ldapLdifFile;
  532. }
  533. }