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