Commit edee79c9 authored by Bill Lynch's avatar Bill Lynch Committed by bill

JM-260 -- fix for bad auth redirect on plugin pages.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1256 b35dd754-fafc-0310-a699-88a17e54d16e
parent 32557cfb
...@@ -30,15 +30,12 @@ import java.util.ArrayList; ...@@ -30,15 +30,12 @@ import java.util.ArrayList;
public class AuthCheckFilter implements Filter { public class AuthCheckFilter implements Filter {
private ServletContext context; private ServletContext context;
private String loginPage; private String defaultLoginPage;
private List<String> excludes; private List<String> excludes;
public void init(FilterConfig config) throws ServletException { public void init(FilterConfig config) throws ServletException {
context = config.getServletContext(); context = config.getServletContext();
loginPage = config.getInitParameter("loginPage"); defaultLoginPage = config.getInitParameter("defaultLoginPage");
if (loginPage == null) {
loginPage = "login.jsp";
}
String excludesProp = config.getInitParameter("excludes"); String excludesProp = config.getInitParameter("excludes");
if (excludesProp != null) { if (excludesProp != null) {
StringTokenizer tokenizer = new StringTokenizer(excludesProp, ","); StringTokenizer tokenizer = new StringTokenizer(excludesProp, ",");
...@@ -55,6 +52,11 @@ public class AuthCheckFilter implements Filter { ...@@ -55,6 +52,11 @@ public class AuthCheckFilter implements Filter {
{ {
HttpServletRequest request = (HttpServletRequest)req; HttpServletRequest request = (HttpServletRequest)req;
HttpServletResponse response = (HttpServletResponse)res; HttpServletResponse response = (HttpServletResponse)res;
// Reset the defaultLoginPage variable
String loginPage = defaultLoginPage;
if (loginPage == null) {
loginPage = request.getContextPath() + "/login.jsp";
}
// Get the page we're on: // Get the page we're on:
String url = request.getRequestURL().toString(); String url = request.getRequestURL().toString();
// See if it's contained in the exclude list. If so, skip filter execution // See if it's contained in the exclude list. If so, skip filter execution
...@@ -69,7 +71,7 @@ public class AuthCheckFilter implements Filter { ...@@ -69,7 +71,7 @@ public class AuthCheckFilter implements Filter {
WebManager manager = new WebManager(); WebManager manager = new WebManager();
manager.init(request, response, request.getSession(), context); manager.init(request, response, request.getSession(), context);
if (manager.getUser() == null) { if (manager.getUser() == null) {
response.sendRedirect(getRedirectURL(request,null)); response.sendRedirect(getRedirectURL(request, loginPage, null));
return; return;
} }
} }
...@@ -79,14 +81,12 @@ public class AuthCheckFilter implements Filter { ...@@ -79,14 +81,12 @@ public class AuthCheckFilter implements Filter {
public void destroy() { public void destroy() {
} }
private String getRedirectURL(HttpServletRequest request, String optionalParams) { private String getRedirectURL(HttpServletRequest request, String loginPage,
String optionalParams)
{
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
try { try {
StringBuffer rURL = request.getRequestURL(); buf.append(request.getRequestURI());
int pos = rURL.lastIndexOf("/");
if ((pos+1) <= rURL.length()) {
buf.append(rURL.substring(pos+1, rURL.length()));
}
String qs = request.getQueryString(); String qs = request.getQueryString();
if (qs != null) { if (qs != null) {
buf.append("?").append(qs); buf.append("?").append(qs);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment