James Moger
2011-04-06 7ba0ec1e871a1f7b5a40b3272e860ade13038e95
src/com/gitblit/GitBlitServer.java
@@ -40,7 +40,6 @@
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jgit.http.server.GitServlet;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;
@@ -176,17 +175,19 @@
      wicketFilter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, wicketPathSpec);
      rootContext.addFilter(wicketFilter, wicketPathSpec, FilterMapping.DEFAULT);
      // GIT Servlet
      Handler handler;
      // Git Servlet
      ServletHolder gitServlet = null;
      String gitServletPathSpec = "/git/*";
      ServletHolder gitServlet = rootContext.addServlet(GitServlet.class, gitServletPathSpec);
      if (StoredSettings.getBoolean("allowPushPull", true)) {
         gitServlet = rootContext.addServlet(GitServlet.class, gitServletPathSpec);
      gitServlet.setInitParameter("base-path", params.repositoriesFolder);
      gitServlet.setInitParameter("export-all", params.exportAll ? "1" : "0");
      String realmUsers = params.realmFile;
      // Authentication Realm
      Handler handler;
      if (realmUsers != null && new File(realmUsers).exists() && params.authenticateAccess) {
         if (realmUsers != null && new File(realmUsers).exists() && params.authenticatePushPull) {
            // Authenticate Pull/Push
         List<String> list = StoredSettings.getStrings("gitRoles");
         String[] roles;
         if (list.size() == 0) {
@@ -194,7 +195,7 @@
         } else {
            roles = list.toArray(new String[list.size()]);
         }
         logger.info("Authentication required for GIT access");
            logger.info("Authentication required for git servlet pull/push access");
         logger.info("Setting up realm from " + realmUsers);
         HashLoginService loginService = new HashLoginService(Constants.NAME, realmUsers);
@@ -220,7 +221,12 @@
         handler = security;
      } else {
         logger.info("Setting up anonymous access");
            // Anonymous Pull/Push
            logger.info("Setting up anonymous git servlet pull/push access");
            handler = rootContext;
         }
      } else {
         logger.info("Git servlet pull/push disabled");
         handler = rootContext;
      }
@@ -356,7 +362,7 @@
      /*
       * GIT Servlet Parameters
       */
      @Parameter(names = { "--repos" }, description = "GIT Repositories Folder")
      @Parameter(names = { "--repos" }, description = "Git Repositories Folder")
      public String repositoriesFolder = StoredSettings.getString("repositoriesFolder", "repos");
      @Parameter(names = { "--exportAll" }, description = "Export All Found Repositories")
@@ -365,8 +371,8 @@
      /*
       * Authentication Parameters
       */
      @Parameter(names = { "--authenticateAccess" }, description = "Authenticate GIT access")
      public Boolean authenticateAccess = StoredSettings.getBoolean("authenticateAccess", true);
      @Parameter(names = { "--authenticatePushPull" }, description = "Authenticate Git Push/Pull access")
      public Boolean authenticatePushPull = StoredSettings.getBoolean("authenticatePushPull", true);
      @Parameter(names = { "--realm" }, description = "Users Realm Hash File")
      public String realmFile = StoredSettings.getString("realmFile", "users.properties");