Permalink
Browse files

#11 - Modifying LastFmPseudoOAuth2Filter to apply to both signin and …

…connect callback urls
  • Loading branch information...
1 parent 24d16a4 commit 8a0f830fb73076659377491deccf2cc55158f441 @michaellavelle committed Oct 21, 2011
@@ -45,10 +45,17 @@
public class LastFmPseudoOAuth2Filter implements Filter {
/**
- * The default callback path - can be overridden via filter config parameter
- * "callbackPath"
+ * The default signin callback path - can be overridden via filter config parameter
+ * "signinCallbackPath"
*/
- private String callbackPath = "/signin/lastfm";
+ private String signinCallbackPath = "/signin/lastfm";
+
+
+ /**
+ * The default connect callback path - can be overridden via filter config parameter
+ * "connectCallbackPath"
+ */
+ private String connectCallbackPath = "/connect/lastfm";
@Override
public void destroy() {
@@ -71,7 +78,7 @@ private String getToken(ServletRequest request) {
* @return true if processing a LastFm callback
*/
private boolean isLastFmCallback(HttpServletRequest request) {
- return request.getRequestURI().equals(callbackPath)
+ return (request.getMethod().toLowerCase().equals("get") && request.getRequestURI().equals(signinCallbackPath) || request.getRequestURI().equals(connectCallbackPath))
&& getToken(request) != null;
}
@@ -100,9 +107,14 @@ public void doFilter(ServletRequest req, ServletResponse resp,
@Override
public void init(FilterConfig config) throws ServletException {
- String callbackPath = config.getInitParameter("callbackPath");
- if (callbackPath != null) {
- this.callbackPath = callbackPath;
+ String signinCallbackPath = config.getInitParameter("signinCallbackPath");
+ if (signinCallbackPath != null) {
+ this.signinCallbackPath = signinCallbackPath;
+ }
+
+ String connectCallbackPath = config.getInitParameter("connectCallbackPath");
+ if (connectCallbackPath != null) {
+ this.connectCallbackPath = connectCallbackPath;
}
}

0 comments on commit 8a0f830

Please sign in to comment.