James Moger
2014-04-17 1d78b8b372f15d89f10fd32cb0227a6a7966de3c
src/main/java/com/gitblit/manager/ServicesManager.java
@@ -102,6 +102,12 @@
      return this;
   }
   public boolean isServingRepositories() {
      return settings.getBoolean(Keys.git.enableGitServlet, true)
            || (gitDaemon != null && gitDaemon.isRunning())
            || (sshDaemon != null && sshDaemon.isRunning());
   }
   protected void configureFederation() {
      boolean validPassphrase = true;
      String passphrase = settings.getString(Keys.federation.passphrase, "");
@@ -228,6 +234,10 @@
   }
   public String getSshDaemonUrl(HttpServletRequest request, UserModel user, RepositoryModel repository) {
      if (user == null || UserModel.ANONYMOUS.equals(user)) {
         // SSH always requires authentication - anonymous access prohibited
         return null;
      }
      if (sshDaemon != null) {
         String bindInterface = settings.getString(Keys.git.sshBindInterface, "localhost");
         if (bindInterface.equals("localhost")
@@ -244,29 +254,11 @@
      return null;
   }
   public AccessPermission getSshDaemonAccessPermission(UserModel user, RepositoryModel repository) {
      if (sshDaemon != null && user.canClone(repository)) {
         AccessPermission sshDaemonPermission = user.getRepositoryPermission(repository).permission;
         if (sshDaemonPermission.atLeast(AccessPermission.CLONE)) {
            if (repository.accessRestriction.atLeast(AccessRestrictionType.CLONE)) {
               // can not authenticate clone via anonymous ssh protocol
               sshDaemonPermission = AccessPermission.NONE;
            } else if (repository.accessRestriction.atLeast(AccessRestrictionType.PUSH)) {
               // can not authenticate push via anonymous ssh protocol
               sshDaemonPermission = AccessPermission.CLONE;
            } else {
               // normal user permission
            }
         }
         return sshDaemonPermission;
      }
      return AccessPermission.NONE;
   }
   /**
    * Extract the hostname from the canonical url or return the
    * hostname from the servlet request.
    *
    *
    * @param request
    * @return
    */