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 22KB

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