Fabrice Bacchella
2015-06-03 b57b9ec3edd2ca7e7e44190f85e3743cea822e3e
src/main/java/com/gitblit/git/GitblitUploadPackFactory.java
@@ -15,16 +15,14 @@
 */
package com.gitblit.git;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.UploadPack;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.eclipse.jgit.transport.resolver.UploadPackFactory;
import com.gitblit.manager.ISessionManager;
import com.gitblit.models.UserModel;
import com.gitblit.manager.IAuthenticationManager;
import com.gitblit.transport.git.GitDaemonClient;
/**
 * The upload pack factory creates an upload pack which controls what refs are
@@ -36,26 +34,19 @@
 */
public class GitblitUploadPackFactory<X> implements UploadPackFactory<X> {
   private final ISessionManager sessionManager;
   private final IAuthenticationManager authenticationManager;
   public GitblitUploadPackFactory(ISessionManager sessionManager) {
      this.sessionManager = sessionManager;
   public GitblitUploadPackFactory(IAuthenticationManager authenticationManager) {
      this.authenticationManager = authenticationManager;
   }
   @Override
   public UploadPack create(X req, Repository db)
         throws ServiceNotEnabledException, ServiceNotAuthorizedException {
      UserModel user = UserModel.ANONYMOUS;
      int timeout = 0;
      if (req instanceof HttpServletRequest) {
         // http/https request may or may not be authenticated
         user = sessionManager.authenticate((HttpServletRequest) req);
         if (user == null) {
            user = UserModel.ANONYMOUS;
         }
      } else if (req instanceof GitDaemonClient) {
      if (req instanceof GitDaemonClient) {
         // git daemon request is always anonymous
         GitDaemonClient client = (GitDaemonClient) req;
         // set timeout from Git daemon