From f76fee63ed9cb3a30d3c0c092d860b1cb93a481b Mon Sep 17 00:00:00 2001
From: Gerard Smyth <gerard.smyth@gmail.com>
Date: Thu, 08 May 2014 13:09:30 -0400
Subject: [PATCH] Updated the SyndicationServlet to provide an additional option to return details of the tags in the repository instead of the commits. This uses a new 'ot' request parameter to indicate the object type of the content to return, which can be ither TAG or COMMIT. If this is not provided, then COMMIT is assumed to maintain backwards compatability. If tags are returned, then the paging parameters, 'l' and 'pg' are still supported, but searching options are currently ignored.

---
 src/main/java/com/gitblit/servlet/AuthenticationFilter.java |   43 ++++++++++++++++++++-----------------------
 1 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/src/main/java/com/gitblit/servlet/AuthenticationFilter.java b/src/main/java/com/gitblit/servlet/AuthenticationFilter.java
index 214f204..5710a4a 100644
--- a/src/main/java/com/gitblit/servlet/AuthenticationFilter.java
+++ b/src/main/java/com/gitblit/servlet/AuthenticationFilter.java
@@ -16,12 +16,13 @@
 package com.gitblit.servlet;
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
 import java.security.Principal;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletException;
@@ -36,10 +37,13 @@
 import org.slf4j.LoggerFactory;
 
 import com.gitblit.Constants;
-import com.gitblit.manager.ISessionManager;
+import com.gitblit.dagger.DaggerFilter;
+import com.gitblit.manager.IAuthenticationManager;
 import com.gitblit.models.UserModel;
 import com.gitblit.utils.DeepCopier;
 import com.gitblit.utils.StringUtils;
+
+import dagger.ObjectGraph;
 
 /**
  * The AuthenticationFilter is a servlet filter that preprocesses requests that
@@ -50,7 +54,7 @@
  * @author James Moger
  *
  */
-public abstract class AuthenticationFilter implements Filter {
+public abstract class AuthenticationFilter extends DaggerFilter {
 
 	protected static final String CHALLENGE = "Basic realm=\"" + Constants.NAME + "\"";
 
@@ -58,10 +62,11 @@
 
 	protected transient Logger logger = LoggerFactory.getLogger(getClass());
 
-	protected final ISessionManager sessionManager;
+	protected IAuthenticationManager authenticationManager;
 
-	protected AuthenticationFilter(ISessionManager sessionManager) {
-		this.sessionManager = sessionManager;
+	@Override
+	protected void inject(ObjectGraph dagger, FilterConfig filterConfig) {
+		this.authenticationManager = dagger.get(IAuthenticationManager.class);
 	}
 
 	/**
@@ -98,6 +103,12 @@
 			url = url.substring(1);
 		}
 		String fullUrl = url + (StringUtils.isEmpty(params) ? "" : ("?" + params));
+		try {
+			fullUrl = URLDecoder.decode(fullUrl, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			logger.warn("UTF-8 decoding of URL failed: "+fullUrl, e);
+			e.printStackTrace();
+		}
 		return fullUrl;
 	}
 
@@ -108,7 +119,7 @@
 	 * @return user
 	 */
 	protected UserModel getUser(HttpServletRequest httpRequest) {
-		UserModel user = sessionManager.authenticate(httpRequest, requiresClientCertificate());
+		UserModel user = authenticationManager.authenticate(httpRequest, requiresClientCertificate());
 		return user;
 	}
 
@@ -135,20 +146,6 @@
 				}
 			}
 		}
-	}
-
-	/**
-	 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
-	 */
-	@Override
-	public void init(final FilterConfig config) throws ServletException {
-	}
-
-	/**
-	 * @see javax.servlet.Filter#destroy()
-	 */
-	@Override
-	public void destroy() {
 	}
 
 	/**
@@ -184,7 +181,7 @@
 			// Gitblit does not currently use actual roles in the traditional
 			// servlet container sense.  That is the reason this is marked
 			// deprecated, but I may want to revisit this.
-			return user.canAccessRepository(role);
+			return user.hasRepositoryPermission(role);
 		}
 
 		@Override
@@ -192,4 +189,4 @@
 			return user;
 		}
 	}
-}
\ No newline at end of file
+}

--
Gitblit v1.9.1