| | |
| | | import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; |
| | | import org.eclipse.jgit.transport.resolver.UploadPackFactory; |
| | | |
| | | import com.gitblit.GitBlit; |
| | | import com.gitblit.manager.ISessionManager; |
| | | import com.gitblit.manager.IAuthenticationManager; |
| | | import com.gitblit.models.UserModel; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public class GitblitUploadPackFactory<X> implements UploadPackFactory<X> { |
| | | |
| | | private final IAuthenticationManager authenticationManager; |
| | | |
| | | public GitblitUploadPackFactory(IAuthenticationManager authenticationManager) { |
| | | this.authenticationManager = authenticationManager; |
| | | } |
| | | |
| | | @Override |
| | | public UploadPack create(X req, Repository db) |
| | | throws ServiceNotEnabledException, ServiceNotAuthorizedException { |
| | | |
| | | ISessionManager sessionManager = GitBlit.getManager(ISessionManager.class); |
| | | 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); |
| | | user = authenticationManager.authenticate((HttpServletRequest) req); |
| | | if (user == null) { |
| | | user = UserModel.ANONYMOUS; |
| | | } |