Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

GitBlitServer.java 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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.InputStreamReader;
  23. import java.io.OutputStream;
  24. import java.net.InetAddress;
  25. import java.net.ServerSocket;
  26. import java.net.Socket;
  27. import java.net.URI;
  28. import java.net.URL;
  29. import java.net.UnknownHostException;
  30. import java.security.ProtectionDomain;
  31. import java.text.MessageFormat;
  32. import java.util.ArrayList;
  33. import java.util.Date;
  34. import java.util.List;
  35. import java.util.Scanner;
  36. import org.eclipse.jetty.ajp.Ajp13SocketConnector;
  37. import org.eclipse.jetty.server.Connector;
  38. import org.eclipse.jetty.server.Server;
  39. import org.eclipse.jetty.server.bio.SocketConnector;
  40. import org.eclipse.jetty.server.nio.SelectChannelConnector;
  41. import org.eclipse.jetty.server.session.HashSessionManager;
  42. import org.eclipse.jetty.server.ssl.SslConnector;
  43. import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
  44. import org.eclipse.jetty.server.ssl.SslSocketConnector;
  45. import org.eclipse.jetty.util.thread.QueuedThreadPool;
  46. import org.eclipse.jetty.webapp.WebAppContext;
  47. import org.eclipse.jgit.storage.file.FileBasedConfig;
  48. import org.eclipse.jgit.util.FS;
  49. import org.eclipse.jgit.util.FileUtils;
  50. import org.slf4j.Logger;
  51. import org.slf4j.LoggerFactory;
  52. import com.beust.jcommander.JCommander;
  53. import com.beust.jcommander.Parameter;
  54. import com.beust.jcommander.ParameterException;
  55. import com.beust.jcommander.Parameters;
  56. import com.gitblit.authority.GitblitAuthority;
  57. import com.gitblit.authority.NewCertificateConfig;
  58. import com.gitblit.utils.StringUtils;
  59. import com.gitblit.utils.TimeUtils;
  60. import com.gitblit.utils.X509Utils;
  61. import com.gitblit.utils.X509Utils.X509Log;
  62. import com.gitblit.utils.X509Utils.X509Metadata;
  63. import com.unboundid.ldap.listener.InMemoryDirectoryServer;
  64. import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig;
  65. import com.unboundid.ldap.listener.InMemoryListenerConfig;
  66. import com.unboundid.ldif.LDIFReader;
  67. /**
  68. * GitBlitServer is the embedded Jetty server for Gitblit GO. This class starts
  69. * and stops an instance of Jetty that is configured from a combination of the
  70. * gitblit.properties file and command line parameters. JCommander is used to
  71. * simplify command line parameter processing. This class also automatically
  72. * generates a self-signed certificate for localhost, if the keystore does not
  73. * already exist.
  74. *
  75. * @author James Moger
  76. *
  77. */
  78. public class GitBlitServer {
  79. private static Logger logger;
  80. public static void main(String... args) {
  81. GitBlitServer server = new GitBlitServer();
  82. // filter out the baseFolder parameter
  83. List<String> filtered = new ArrayList<String>();
  84. String folder = "data";
  85. for (int i = 0; i< args.length; i++) {
  86. String arg = args[i];
  87. if (arg.equals("--baseFolder")) {
  88. if (i + 1 == args.length) {
  89. System.out.println("Invalid --baseFolder parameter!");
  90. System.exit(-1);
  91. } else if (args[i + 1] != ".") {
  92. folder = args[i + 1];
  93. }
  94. i = i + 1;
  95. } else {
  96. filtered.add(arg);
  97. }
  98. }
  99. Params.baseFolder = folder;
  100. Params params = new Params();
  101. JCommander jc = new JCommander(params);
  102. try {
  103. jc.parse(filtered.toArray(new String[filtered.size()]));
  104. if (params.help) {
  105. server.usage(jc, null);
  106. }
  107. } catch (ParameterException t) {
  108. server.usage(jc, t);
  109. }
  110. if (params.stop) {
  111. server.stop(params);
  112. } else {
  113. server.start(params);
  114. }
  115. }
  116. /**
  117. * Display the command line usage of Gitblit GO.
  118. *
  119. * @param jc
  120. * @param t
  121. */
  122. protected final void usage(JCommander jc, ParameterException t) {
  123. System.out.println(Constants.BORDER);
  124. System.out.println(Constants.getGitBlitVersion());
  125. System.out.println(Constants.BORDER);
  126. System.out.println();
  127. if (t != null) {
  128. System.out.println(t.getMessage());
  129. System.out.println();
  130. }
  131. if (jc != null) {
  132. jc.usage();
  133. System.out
  134. .println("\nExample:\n java -server -Xmx1024M -jar gitblit.jar --repositoriesFolder c:\\git --httpPort 80 --httpsPort 443");
  135. }
  136. System.exit(0);
  137. }
  138. /**
  139. * Stop Gitblt GO.
  140. */
  141. public void stop(Params params) {
  142. try {
  143. Socket s = new Socket(InetAddress.getByName("127.0.0.1"), params.shutdownPort);
  144. OutputStream out = s.getOutputStream();
  145. System.out.println("Sending Shutdown Request to " + Constants.NAME);
  146. out.write("\r\n".getBytes());
  147. out.flush();
  148. s.close();
  149. } catch (UnknownHostException e) {
  150. e.printStackTrace();
  151. } catch (IOException e) {
  152. e.printStackTrace();
  153. }
  154. }
  155. /**
  156. * Start Gitblit GO.
  157. */
  158. protected final void start(Params params) {
  159. final File baseFolder = new File(Params.baseFolder).getAbsoluteFile();
  160. FileSettings settings = params.FILESETTINGS;
  161. if (!StringUtils.isEmpty(params.settingsfile)) {
  162. if (new File(params.settingsfile).exists()) {
  163. settings = new FileSettings(params.settingsfile);
  164. }
  165. }
  166. logger = LoggerFactory.getLogger(GitBlitServer.class);
  167. logger.info(Constants.BORDER);
  168. logger.info(" _____ _ _ _ _ _ _");
  169. logger.info(" | __ \\(_)| | | | | |(_)| |");
  170. logger.info(" | | \\/ _ | |_ | |__ | | _ | |_");
  171. logger.info(" | | __ | || __|| '_ \\ | || || __|");
  172. logger.info(" | |_\\ \\| || |_ | |_) || || || |_");
  173. logger.info(" \\____/|_| \\__||_.__/ |_||_| \\__|");
  174. int spacing = (Constants.BORDER.length() - Constants.getGitBlitVersion().length()) / 2;
  175. StringBuilder sb = new StringBuilder();
  176. while (spacing > 0) {
  177. spacing--;
  178. sb.append(' ');
  179. }
  180. logger.info(sb.toString() + Constants.getGitBlitVersion());
  181. logger.info("");
  182. logger.info(Constants.BORDER);
  183. System.setProperty("java.awt.headless", "true");
  184. String osname = System.getProperty("os.name");
  185. String osversion = System.getProperty("os.version");
  186. logger.info("Running on " + osname + " (" + osversion + ")");
  187. List<Connector> connectors = new ArrayList<Connector>();
  188. // conditionally configure the http connector
  189. if (params.port > 0) {
  190. Connector httpConnector = createConnector(params.useNIO, settings.getInteger(Keys.server.nioThreadPoolSize, 50), params.port);
  191. String bindInterface = settings.getString(Keys.server.httpBindInterface, null);
  192. if (!StringUtils.isEmpty(bindInterface)) {
  193. logger.warn(MessageFormat.format("Binding connector on port {0,number,0} to {1}",
  194. params.port, bindInterface));
  195. httpConnector.setHost(bindInterface);
  196. }
  197. if (params.port < 1024 && !isWindows()) {
  198. logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
  199. }
  200. connectors.add(httpConnector);
  201. }
  202. // conditionally configure the https connector
  203. if (params.securePort > 0) {
  204. File certificatesConf = new File(baseFolder, X509Utils.CA_CONFIG);
  205. File serverKeyStore = new File(baseFolder, X509Utils.SERVER_KEY_STORE);
  206. File serverTrustStore = new File(baseFolder, X509Utils.SERVER_TRUST_STORE);
  207. File caRevocationList = new File(baseFolder, X509Utils.CA_REVOCATION_LIST);
  208. // generate CA & web certificates, create certificate stores
  209. X509Metadata metadata = new X509Metadata("localhost", params.storePassword);
  210. // set default certificate values from config file
  211. if (certificatesConf.exists()) {
  212. FileBasedConfig config = new FileBasedConfig(certificatesConf, FS.detect());
  213. try {
  214. config.load();
  215. } catch (Exception e) {
  216. logger.error("Error parsing " + certificatesConf, e);
  217. }
  218. NewCertificateConfig certificateConfig = NewCertificateConfig.KEY.parse(config);
  219. certificateConfig.update(metadata);
  220. }
  221. metadata.notAfter = new Date(System.currentTimeMillis() + 10*TimeUtils.ONEYEAR);
  222. X509Utils.prepareX509Infrastructure(metadata, baseFolder, new X509Log() {
  223. @Override
  224. public void log(String message) {
  225. BufferedWriter writer = null;
  226. try {
  227. writer = new BufferedWriter(new FileWriter(new File(baseFolder, X509Utils.CERTS + File.separator + "log.txt"), true));
  228. writer.write(MessageFormat.format("{0,date,yyyy-MM-dd HH:mm}: {1}", new Date(), message));
  229. writer.newLine();
  230. writer.flush();
  231. } catch (Exception e) {
  232. LoggerFactory.getLogger(GitblitAuthority.class).error("Failed to append log entry!", e);
  233. } finally {
  234. if (writer != null) {
  235. try {
  236. writer.close();
  237. } catch (IOException e) {
  238. }
  239. }
  240. }
  241. }
  242. });
  243. if (serverKeyStore.exists()) {
  244. Connector secureConnector = createSSLConnector(params.alias, serverKeyStore, serverTrustStore, params.storePassword,
  245. caRevocationList, params.useNIO, settings.getInteger(Keys.server.nioThreadPoolSize, 50), params.securePort, params.requireClientCertificates);
  246. String bindInterface = settings.getString(Keys.server.httpsBindInterface, null);
  247. if (!StringUtils.isEmpty(bindInterface)) {
  248. logger.warn(MessageFormat.format(
  249. "Binding ssl connector on port {0,number,0} to {1}", params.securePort,
  250. bindInterface));
  251. secureConnector.setHost(bindInterface);
  252. }
  253. if (params.securePort < 1024 && !isWindows()) {
  254. logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
  255. }
  256. connectors.add(secureConnector);
  257. } else {
  258. logger.warn("Failed to find or load Keystore?");
  259. logger.warn("SSL connector DISABLED.");
  260. }
  261. }
  262. // conditionally configure the ajp connector
  263. if (params.ajpPort > 0) {
  264. Connector ajpConnector = createAJPConnector(params.ajpPort);
  265. String bindInterface = settings.getString(Keys.server.ajpBindInterface, null);
  266. if (!StringUtils.isEmpty(bindInterface)) {
  267. logger.warn(MessageFormat.format("Binding connector on port {0,number,0} to {1}",
  268. params.ajpPort, bindInterface));
  269. ajpConnector.setHost(bindInterface);
  270. }
  271. if (params.ajpPort < 1024 && !isWindows()) {
  272. logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
  273. }
  274. connectors.add(ajpConnector);
  275. }
  276. // tempDir is where the embedded Gitblit web application is expanded and
  277. // where Jetty creates any necessary temporary files
  278. File tempDir = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, baseFolder, params.temp);
  279. if (tempDir.exists()) {
  280. try {
  281. FileUtils.delete(tempDir, FileUtils.RECURSIVE | FileUtils.RETRY);
  282. } catch (IOException x) {
  283. logger.warn("Failed to delete temp dir " + tempDir.getAbsolutePath(), x);
  284. }
  285. }
  286. if (!tempDir.mkdirs()) {
  287. logger.warn("Failed to create temp dir " + tempDir.getAbsolutePath());
  288. }
  289. Server server = new Server();
  290. server.setStopAtShutdown(true);
  291. server.setConnectors(connectors.toArray(new Connector[connectors.size()]));
  292. // Get the execution path of this class
  293. // We use this to set the WAR path.
  294. ProtectionDomain protectionDomain = GitBlitServer.class.getProtectionDomain();
  295. URL location = protectionDomain.getCodeSource().getLocation();
  296. // Root WebApp Context
  297. WebAppContext rootContext = new WebAppContext();
  298. rootContext.setContextPath(settings.getString(Keys.server.contextPath, "/"));
  299. rootContext.setServer(server);
  300. rootContext.setWar(location.toExternalForm());
  301. rootContext.setTempDirectory(tempDir);
  302. // Set cookies HttpOnly so they are not accessible to JavaScript engines
  303. HashSessionManager sessionManager = new HashSessionManager();
  304. sessionManager.setHttpOnly(true);
  305. // Use secure cookies if only serving https
  306. sessionManager.setSecureCookies(params.port <= 0 && params.securePort > 0);
  307. rootContext.getSessionHandler().setSessionManager(sessionManager);
  308. // Ensure there is a defined User Service
  309. String realmUsers = params.userService;
  310. if (StringUtils.isEmpty(realmUsers)) {
  311. logger.error(MessageFormat.format("PLEASE SPECIFY {0}!!", Keys.realm.userService));
  312. return;
  313. }
  314. // Override settings from the command-line
  315. settings.overrideSetting(Keys.realm.userService, params.userService);
  316. settings.overrideSetting(Keys.git.repositoriesFolder, params.repositoriesFolder);
  317. settings.overrideSetting(Keys.git.daemonPort, params.gitPort);
  318. // Start up an in-memory LDAP server, if configured
  319. try {
  320. if (StringUtils.isEmpty(params.ldapLdifFile) == false) {
  321. File ldifFile = new File(params.ldapLdifFile);
  322. if (ldifFile != null && ldifFile.exists()) {
  323. URI ldapUrl = new URI(settings.getRequiredString(Keys.realm.ldap.server));
  324. String firstLine = new Scanner(ldifFile).nextLine();
  325. String rootDN = firstLine.substring(4);
  326. String bindUserName = settings.getString(Keys.realm.ldap.username, "");
  327. String bindPassword = settings.getString(Keys.realm.ldap.password, "");
  328. // Get the port
  329. int port = ldapUrl.getPort();
  330. if (port == -1)
  331. port = 389;
  332. InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(rootDN);
  333. config.addAdditionalBindCredentials(bindUserName, bindPassword);
  334. config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", port));
  335. config.setSchema(null);
  336. InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
  337. ds.importFromLDIF(true, new LDIFReader(ldifFile));
  338. ds.startListening();
  339. logger.info("LDAP Server started at ldap://localhost:" + port);
  340. }
  341. }
  342. } catch (Exception e) {
  343. // Completely optional, just show a warning
  344. logger.warn("Unable to start LDAP server", e);
  345. }
  346. // Set the server's contexts
  347. server.setHandler(rootContext);
  348. // Setup the GitBlit context
  349. GitBlit gitblit = getGitBlitInstance();
  350. gitblit.configureContext(settings, baseFolder, true);
  351. rootContext.addEventListener(gitblit);
  352. try {
  353. // start the shutdown monitor
  354. if (params.shutdownPort > 0) {
  355. Thread shutdownMonitor = new ShutdownMonitorThread(server, params);
  356. shutdownMonitor.start();
  357. }
  358. // start Jetty
  359. server.start();
  360. server.join();
  361. } catch (Exception e) {
  362. e.printStackTrace();
  363. System.exit(100);
  364. }
  365. }
  366. protected GitBlit getGitBlitInstance() {
  367. return GitBlit.self();
  368. }
  369. /**
  370. * Creates an http connector.
  371. *
  372. * @param useNIO
  373. * @param port
  374. * @param maxThreads
  375. * @return an http connector
  376. */
  377. private Connector createConnector(boolean useNIO, int port, int maxThreads) {
  378. Connector connector;
  379. if (useNIO) {
  380. logger.info("Setting up NIO SelectChannelConnector on port " + port);
  381. SelectChannelConnector nioconn = new SelectChannelConnector();
  382. nioconn.setSoLingerTime(-1);
  383. nioconn.setThreadPool(new QueuedThreadPool(maxThreads));
  384. connector = nioconn;
  385. } else {
  386. logger.info("Setting up SocketConnector on port " + port);
  387. SocketConnector sockconn = new SocketConnector();
  388. connector = sockconn;
  389. }
  390. connector.setPort(port);
  391. connector.setMaxIdleTime(30000);
  392. return connector;
  393. }
  394. /**
  395. * Creates an https connector.
  396. *
  397. * SSL renegotiation will be enabled if the JVM is 1.6.0_22 or later.
  398. * oracle.com/technetwork/java/javase/documentation/tlsreadme2-176330.html
  399. *
  400. * @param certAlias
  401. * @param keyStore
  402. * @param clientTrustStore
  403. * @param storePassword
  404. * @param caRevocationList
  405. * @param useNIO
  406. * @param nioThreadPoolSize
  407. * @param port
  408. * @param requireClientCertificates
  409. * @return an https connector
  410. */
  411. private Connector createSSLConnector(String certAlias, File keyStore, File clientTrustStore,
  412. String storePassword, File caRevocationList, boolean useNIO, int nioThreadPoolSize, int port,
  413. boolean requireClientCertificates) {
  414. GitblitSslContextFactory factory = new GitblitSslContextFactory(certAlias,
  415. keyStore, clientTrustStore, storePassword, caRevocationList);
  416. SslConnector connector;
  417. if (useNIO) {
  418. logger.info("Setting up NIO SslSelectChannelConnector on port " + port);
  419. SslSelectChannelConnector ssl = new SslSelectChannelConnector(factory);
  420. ssl.setSoLingerTime(-1);
  421. if (requireClientCertificates) {
  422. factory.setNeedClientAuth(true);
  423. } else {
  424. factory.setWantClientAuth(true);
  425. }
  426. ssl.setThreadPool(new QueuedThreadPool(nioThreadPoolSize));
  427. connector = ssl;
  428. } else {
  429. logger.info("Setting up NIO SslSocketConnector on port " + port);
  430. SslSocketConnector ssl = new SslSocketConnector(factory);
  431. connector = ssl;
  432. }
  433. connector.setPort(port);
  434. connector.setMaxIdleTime(30000);
  435. return connector;
  436. }
  437. /**
  438. * Creates an ajp connector.
  439. *
  440. * @param port
  441. * @return an ajp connector
  442. */
  443. private Connector createAJPConnector(int port) {
  444. logger.info("Setting up AJP Connector on port " + port);
  445. Ajp13SocketConnector ajp = new Ajp13SocketConnector();
  446. ajp.setPort(port);
  447. if (port < 1024 && !isWindows()) {
  448. logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
  449. }
  450. return ajp;
  451. }
  452. /**
  453. * Tests to see if the operating system is Windows.
  454. *
  455. * @return true if this is a windows machine
  456. */
  457. private boolean isWindows() {
  458. return System.getProperty("os.name").toLowerCase().indexOf("windows") > -1;
  459. }
  460. /**
  461. * The ShutdownMonitorThread opens a socket on a specified port and waits
  462. * for an incoming connection. When that connection is accepted a shutdown
  463. * message is issued to the running Jetty server.
  464. *
  465. * @author James Moger
  466. *
  467. */
  468. private static class ShutdownMonitorThread extends Thread {
  469. private final ServerSocket socket;
  470. private final Server server;
  471. private final Logger logger = LoggerFactory.getLogger(ShutdownMonitorThread.class);
  472. public ShutdownMonitorThread(Server server, Params params) {
  473. this.server = server;
  474. setDaemon(true);
  475. setName(Constants.NAME + " Shutdown Monitor");
  476. ServerSocket skt = null;
  477. try {
  478. skt = new ServerSocket(params.shutdownPort, 1, InetAddress.getByName("127.0.0.1"));
  479. } catch (Exception e) {
  480. logger.warn("Could not open shutdown monitor on port " + params.shutdownPort, e);
  481. }
  482. socket = skt;
  483. }
  484. @Override
  485. public void run() {
  486. logger.info("Shutdown Monitor listening on port " + socket.getLocalPort());
  487. Socket accept;
  488. try {
  489. accept = socket.accept();
  490. BufferedReader reader = new BufferedReader(new InputStreamReader(
  491. accept.getInputStream()));
  492. reader.readLine();
  493. logger.info(Constants.BORDER);
  494. logger.info("Stopping " + Constants.NAME);
  495. logger.info(Constants.BORDER);
  496. server.stop();
  497. server.setStopAtShutdown(false);
  498. accept.close();
  499. socket.close();
  500. } catch (Exception e) {
  501. logger.warn("Failed to shutdown Jetty", e);
  502. }
  503. }
  504. }
  505. /**
  506. * JCommander Parameters class for GitBlitServer.
  507. */
  508. @Parameters(separators = " ")
  509. public static class Params {
  510. public static String baseFolder;
  511. private final FileSettings FILESETTINGS = new FileSettings(new File(baseFolder, Constants.PROPERTIES_FILE).getAbsolutePath());
  512. /*
  513. * Server parameters
  514. */
  515. @Parameter(names = { "-h", "--help" }, description = "Show this help")
  516. public Boolean help = false;
  517. @Parameter(names = { "--stop" }, description = "Stop Server")
  518. public Boolean stop = false;
  519. @Parameter(names = { "--tempFolder" }, description = "Folder for server to extract built-in webapp")
  520. public String temp = FILESETTINGS.getString(Keys.server.tempFolder, "temp");
  521. /*
  522. * GIT Servlet Parameters
  523. */
  524. @Parameter(names = { "--repositoriesFolder" }, description = "Git Repositories Folder")
  525. public String repositoriesFolder = FILESETTINGS.getString(Keys.git.repositoriesFolder,
  526. "git");
  527. /*
  528. * Authentication Parameters
  529. */
  530. @Parameter(names = { "--userService" }, description = "Authentication and Authorization Service (filename or fully qualified classname)")
  531. public String userService = FILESETTINGS.getString(Keys.realm.userService,
  532. "users.conf");
  533. /*
  534. * JETTY Parameters
  535. */
  536. @Parameter(names = { "--useNio" }, description = "Use NIO Connector else use Socket Connector.")
  537. public Boolean useNIO = FILESETTINGS.getBoolean(Keys.server.useNio, true);
  538. @Parameter(names = "--httpPort", description = "HTTP port for to serve. (port <= 0 will disable this connector)")
  539. public Integer port = FILESETTINGS.getInteger(Keys.server.httpPort, 0);
  540. @Parameter(names = "--httpsPort", description = "HTTPS port to serve. (port <= 0 will disable this connector)")
  541. public Integer securePort = FILESETTINGS.getInteger(Keys.server.httpsPort, 8443);
  542. @Parameter(names = "--ajpPort", description = "AJP port to serve. (port <= 0 will disable this connector)")
  543. public Integer ajpPort = FILESETTINGS.getInteger(Keys.server.ajpPort, 0);
  544. @Parameter(names = "--gitPort", description = "Git Daemon port to serve. (port <= 0 will disable this connector)")
  545. public Integer gitPort = FILESETTINGS.getInteger(Keys.git.daemonPort, 9418);
  546. @Parameter(names = "--alias", description = "Alias of SSL certificate in keystore for serving https.")
  547. public String alias = FILESETTINGS.getString(Keys.server.certificateAlias, "");
  548. @Parameter(names = "--storePassword", description = "Password for SSL (https) keystore.")
  549. public String storePassword = FILESETTINGS.getString(Keys.server.storePassword, "");
  550. @Parameter(names = "--shutdownPort", description = "Port for Shutdown Monitor to listen on. (port <= 0 will disable this monitor)")
  551. public Integer shutdownPort = FILESETTINGS.getInteger(Keys.server.shutdownPort, 8081);
  552. @Parameter(names = "--requireClientCertificates", description = "Require client X509 certificates for https connections.")
  553. public Boolean requireClientCertificates = FILESETTINGS.getBoolean(Keys.server.requireClientCertificates, false);
  554. /*
  555. * Setting overrides
  556. */
  557. @Parameter(names = { "--settings" }, description = "Path to alternative settings")
  558. public String settingsfile;
  559. @Parameter(names = { "--ldapLdifFile" }, description = "Path to LDIF file. This will cause an in-memory LDAP server to be started according to gitblit settings")
  560. public String ldapLdifFile;
  561. }
  562. }