Paul Martin
2016-04-27 c2188a840bc4153ae92112b04b2e06a90d3944aa
src/main/java/com/gitblit/servlet/DownloadZipFilter.java
@@ -15,6 +15,9 @@
 */
package com.gitblit.servlet;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.manager.IAuthenticationManager;
import com.gitblit.manager.IRepositoryManager;
@@ -30,8 +33,10 @@
 * @author James Moger
 *
 */
@Singleton
public class DownloadZipFilter extends AccessRestrictionFilter {
   @Inject
   public DownloadZipFilter(
         IRuntimeManager runtimeManager,
         IAuthenticationManager authenticationManager,
@@ -49,11 +54,14 @@
   @Override
   protected String extractRepositoryName(String url) {
      int a = url.indexOf("r=");
      String repository = url.substring(a + 2);
      if (repository.indexOf('&') > -1) {
         repository = repository.substring(0, repository.indexOf('&'));
      if (a > -1) {
         String repository = url.substring(a + 2);
         if (repository.indexOf('&') > -1) {
            repository = repository.substring(0, repository.indexOf('&'));
         }
         return repository;
      }
      return repository;
      return null;
   }
   /**
@@ -73,7 +81,7 @@
    * @return true if the filter allows repository creation
    */
   @Override
   protected boolean isCreationAllowed() {
   protected boolean isCreationAllowed(String action) {
      return false;
   }
@@ -82,10 +90,11 @@
    *
    * @param repository
    * @param action
    * @param method
    * @return true if the action may be performed
    */
   @Override
   protected boolean isActionAllowed(RepositoryModel repository, String action) {
   protected boolean isActionAllowed(RepositoryModel repository, String action, String method) {
      return true;
   }
@@ -94,10 +103,11 @@
    *
    * @param repository
    * @param action
    * @param method
    * @return true if authentication required
    */
   @Override
   protected boolean requiresAuthentication(RepositoryModel repository, String action) {
   protected boolean requiresAuthentication(RepositoryModel repository, String action, String method) {
      return repository.accessRestriction.atLeast(AccessRestrictionType.VIEW);
   }