# HG changeset patch # User Bjoern Ricks # Date 1348491893 0 # Node ID a4c9296f6efaacdbb6d75069b8a8574147e52b40 # Parent 8d0ababa2db713c696fd298d6fd8dc4d4cf813a7 Use the Context PATH servlet variable when using URLs in the GGInAFilter flys-client/trunk@5591 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 8d0ababa2db7 -r a4c9296f6efa flys-client/ChangeLog --- a/flys-client/ChangeLog Mon Sep 24 11:53:29 2012 +0000 +++ b/flys-client/ChangeLog Mon Sep 24 13:04:53 2012 +0000 @@ -1,3 +1,12 @@ +2012-09-24 Björn Ricks + + issue846 (GGInA: Auth mechanism ignores URL prefix) + + * src/main/java/de/intevation/flys/client/server/LoginServlet.java, + src/main/java/de/intevation/flys/client/server/GGInAFilter.java, + src/main/webapp/login.jsp: + Consider the Context Path variable when using urls in the GGInAFilter. + 2012-09-24 Felix Wolfsteller issue871 (parameterization of flowvelocity loo¿s a tiny bit messy). diff -r 8d0ababa2db7 -r a4c9296f6efa flys-client/src/main/java/de/intevation/flys/client/server/GGInAFilter.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/GGInAFilter.java Mon Sep 24 11:53:29 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/GGInAFilter.java Mon Sep 24 13:04:53 2012 +0000 @@ -34,6 +34,10 @@ private String authmethod; private ServletContext sc; + public static final String LOGIN_JSP = "/login.jsp"; + public static final String LOGIN_SERVLET = "/flys/login"; + public static final String FLYS_CSS = "/FLYS.css"; + /** * Initialize. @@ -46,6 +50,7 @@ { String deactivate = config.getInitParameter("deactivate"); this.sc = config.getServletContext(); + logger.debug("GGInAFilter context " + this.sc.getContextPath()); this.authmethod = sc.getInitParameter("authentication"); if (deactivate != null && deactivate.equalsIgnoreCase("true")) { this.deactivate = true; @@ -81,8 +86,10 @@ // Allow access to login pages // TODO Maybe replace with Filter - if (requesturi.equals("/login.jsp") || requesturi.equals("/flys/login") - || requesturi.equals("/FLYS.css")) { + String path = this.sc.getContextPath(); + if (requesturi.equals(path + "/login.jsp") || + requesturi.equals(path + "/flys/login") + || requesturi.equals(path + "/FLYS.css")) { logger.debug("Request for login " + requesturi); chain.doFilter(req, resp); return; @@ -127,7 +134,8 @@ private void redirect(ServletResponse resp) throws IOException { logger.debug("Redirect to login"); - ((HttpServletResponse) resp).sendRedirect("/login.jsp"); + ((HttpServletResponse) resp).sendRedirect(this.sc.getContextPath() + + "/login.jsp"); } diff -r 8d0ababa2db7 -r a4c9296f6efa flys-client/src/main/java/de/intevation/flys/client/server/LoginServlet.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/LoginServlet.java Mon Sep 24 11:53:29 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/LoginServlet.java Mon Sep 24 13:04:53 2012 +0000 @@ -22,20 +22,25 @@ private static Logger logger = Logger.getLogger(LoginServlet.class); - private void redirectFailure(HttpServletResponse resp) throws IOException { - resp.sendRedirect("/login.jsp"); + private void redirectFailure(HttpServletResponse resp, String path) + throws IOException { + resp.sendRedirect(path + "/login.jsp"); } - private void redirectFailure(HttpServletResponse resp, Exception e) throws IOException { - this.redirectFailure(resp, e.getMessage()); + private void redirectFailure(HttpServletResponse resp, String path, + Exception e) throws IOException { + this.redirectFailure(resp, path, e.getMessage()); } - private void redirectFailure(HttpServletResponse resp, String message) throws IOException { - resp.sendRedirect("/login.jsp?error=" + message); + private void redirectFailure(HttpServletResponse resp, String path, + String message) throws IOException { + resp.sendRedirect(path + "/login.jsp?error=" + message); } - private void redirectSuccess(HttpServletResponse resp, String uri) throws IOException { + + private void redirectSuccess(HttpServletResponse resp, String path, + String uri) throws IOException { if (uri == null) { - uri = "/FLYS.html"; + uri = path + "/FLYS.html"; } resp.sendRedirect(uri); } @@ -44,7 +49,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { logger.debug("Processing get request"); - this.redirectFailure(resp); + this.redirectFailure(resp, req.getContextPath()); } @Override @@ -59,7 +64,7 @@ if (username == null || password == null) { logger.debug("No username or password provided"); - this.redirectFailure(resp); + this.redirectFailure(resp, req.getContextPath()); return; } @@ -67,7 +72,7 @@ Authentication aresp = this.auth(username, password, encoding); if (aresp == null || !aresp.isSuccess()) { logger.debug("Authentication not successful"); - this.redirectFailure(resp); + this.redirectFailure(resp, req.getContextPath()); } User user = aresp.getUser(); @@ -76,7 +81,8 @@ if (!client.userExists(user)) { logger.debug("Creating db user"); if (!client.createUser(user)) { - this.redirectFailure(resp, "Could not create new user"); + this.redirectFailure(resp, req.getContextPath(), + "Could not create new user"); } } @@ -85,11 +91,11 @@ String uri = (String)session.getAttribute("requesturi"); - this.redirectSuccess(resp, uri); + this.redirectSuccess(resp, req.getContextPath(), uri); } catch(AuthenticationException e) { logger.error(e); - this.redirectFailure(resp, e); + this.redirectFailure(resp, req.getContextPath(), e); } } diff -r 8d0ababa2db7 -r a4c9296f6efa flys-client/src/main/webapp/login.jsp --- a/flys-client/src/main/webapp/login.jsp Mon Sep 24 11:53:29 2012 +0000 +++ b/flys-client/src/main/webapp/login.jsp Mon Sep 24 13:04:53 2012 +0000 @@ -6,7 +6,7 @@ -
+ " id="authentication">

FLYS Anmeldung

<% String error = request.getParameter("error"); %> <% if (error != null) { %>