annotate flys-client/src/main/java/de/intevation/flys/client/server/GGInAFilter.java @ 4194:17fe00c09b7c

Don't redirect to request uri If a url is requested which isn't the FLYS start page (FLYS.html) the user had been redirected to this page after successfull authentication. This caused wrong redirects after a authentication is expired and if the browser preloads e.g. the CSS file. Therefore allow to set a redirect url in the web.xml config to always redirect the user to the correct page after successfull authentication. Fix for flys/issue970 (Zugangsfehler FLYS 2.9.3)
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 22 Oct 2012 09:51:12 +0200
parents a4c9296f6efa
children 93b53eaee401
rev   line source
2889
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.server;
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 import java.io.IOException;
3485
71ba3cf3ec5e Refactor Authentication to allow to pass the Freatures to the user class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2974
diff changeset
4 import java.util.Enumeration;
2889
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6 import javax.servlet.Filter;
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7 import javax.servlet.FilterChain;
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8 import javax.servlet.FilterConfig;
3485
71ba3cf3ec5e Refactor Authentication to allow to pass the Freatures to the user class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2974
diff changeset
9 import javax.servlet.ServletContext;
2889
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10 import javax.servlet.ServletException;
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 import javax.servlet.ServletRequest;
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12 import javax.servlet.ServletResponse;
2893
6e4e4b96ca6c Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2889
diff changeset
13
2889
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import javax.servlet.http.HttpServletRequest;
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 import javax.servlet.http.HttpServletResponse;
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
16 import javax.servlet.http.HttpSession;
2889
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 import org.apache.log4j.Logger;
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19
2974
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
20 import de.intevation.flys.client.server.auth.Authentication;
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
21 import de.intevation.flys.client.server.auth.AuthenticationException;
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
22 import de.intevation.flys.client.server.auth.AuthenticationFactory;
2964
c12e29661e6a Login: Cast session user to abstract type not WAS specific
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2957
diff changeset
23 import de.intevation.flys.client.server.auth.User;
3485
71ba3cf3ec5e Refactor Authentication to allow to pass the Freatures to the user class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2974
diff changeset
24 import de.intevation.flys.client.server.features.Features;
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
25
2889
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 /** ServletFilter used for GGInA authentification and certain authorisation. */
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 public class GGInAFilter implements Filter {
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30 /** Private logger. */
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 private static Logger logger = Logger.getLogger(GGInAFilter.class);
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
33 private boolean deactivate = false;
2974
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
34 private String authmethod;
4194
17fe00c09b7c Don't redirect to request uri
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3851
diff changeset
35 private String redirecturl;
3485
71ba3cf3ec5e Refactor Authentication to allow to pass the Freatures to the user class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2974
diff changeset
36 private ServletContext sc;
2889
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37
3851
a4c9296f6efa Use the Context PATH servlet variable when using URLs in the GGInAFilter
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3485
diff changeset
38 public static final String LOGIN_JSP = "/login.jsp";
a4c9296f6efa Use the Context PATH servlet variable when using URLs in the GGInAFilter
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3485
diff changeset
39 public static final String LOGIN_SERVLET = "/flys/login";
a4c9296f6efa Use the Context PATH servlet variable when using URLs in the GGInAFilter
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3485
diff changeset
40 public static final String FLYS_CSS = "/FLYS.css";
a4c9296f6efa Use the Context PATH servlet variable when using URLs in the GGInAFilter
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3485
diff changeset
41
2889
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 /**
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 * Initialize.
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
45 *
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
46 * Read FilterConfig parameter deactivate
2889
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 */
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 @Override
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 public void init(FilterConfig config)
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 throws ServletException
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51 {
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
52 String deactivate = config.getInitParameter("deactivate");
3485
71ba3cf3ec5e Refactor Authentication to allow to pass the Freatures to the user class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2974
diff changeset
53 this.sc = config.getServletContext();
3851
a4c9296f6efa Use the Context PATH servlet variable when using URLs in the GGInAFilter
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3485
diff changeset
54 logger.debug("GGInAFilter context " + this.sc.getContextPath());
3485
71ba3cf3ec5e Refactor Authentication to allow to pass the Freatures to the user class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2974
diff changeset
55 this.authmethod = sc.getInitParameter("authentication");
4194
17fe00c09b7c Don't redirect to request uri
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3851
diff changeset
56 this.redirecturl = sc.getInitParameter("redirect-url");
2955
f1030909eeb6 Check filter config in web.xml for String false to deactivate the GGInAFilter instead of "1".
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2952
diff changeset
57 if (deactivate != null && deactivate.equalsIgnoreCase("true")) {
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
58 this.deactivate = true;
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
59 }
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
60
2889
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 }
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 /**
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65 * Called when filter in chain invoked.
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66 * @param req request to servlet
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 * @param resp response of servlet
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 * @param chain the filter chain
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 */
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 @Override
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 throws IOException, ServletException
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 {
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
74 if (this.deactivate) {
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
75 logger.debug("GGinAFilter is deactivated");
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
76 chain.doFilter(req, resp);
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
77 return;
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
78 }
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
79
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
80 HttpServletRequest sreq = (HttpServletRequest) req;
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
81
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
82 String requesturi = sreq.getRequestURI();
3485
71ba3cf3ec5e Refactor Authentication to allow to pass the Freatures to the user class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2974
diff changeset
83 for (Enumeration e = req.getAttributeNames() ; e.hasMoreElements() ;) {
71ba3cf3ec5e Refactor Authentication to allow to pass the Freatures to the user class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2974
diff changeset
84 logger.debug(e.nextElement());
71ba3cf3ec5e Refactor Authentication to allow to pass the Freatures to the user class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2974
diff changeset
85 }
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
86
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
87 logger.debug("Request for: " + requesturi);
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
88
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
89 // Allow access to login pages
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
90 // TODO Maybe replace with Filter <url-pattern>
3851
a4c9296f6efa Use the Context PATH servlet variable when using URLs in the GGInAFilter
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3485
diff changeset
91 String path = this.sc.getContextPath();
a4c9296f6efa Use the Context PATH servlet variable when using URLs in the GGInAFilter
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3485
diff changeset
92 if (requesturi.equals(path + "/login.jsp") ||
a4c9296f6efa Use the Context PATH servlet variable when using URLs in the GGInAFilter
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3485
diff changeset
93 requesturi.equals(path + "/flys/login")
a4c9296f6efa Use the Context PATH servlet variable when using URLs in the GGInAFilter
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3485
diff changeset
94 || requesturi.equals(path + "/FLYS.css")) {
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
95 logger.debug("Request for login " + requesturi);
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
96 chain.doFilter(req, resp);
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
97 return;
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
98 }
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
99
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
100 HttpSession session = sreq.getSession();
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
101
4194
17fe00c09b7c Don't redirect to request uri
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3851
diff changeset
102 String uri = "/" + this.redirecturl;
17fe00c09b7c Don't redirect to request uri
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3851
diff changeset
103
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
104 if (sreq.getQueryString() != null) {
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
105 uri = uri + "?" + sreq.getQueryString();
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
106 }
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
107 session.setAttribute("requesturi", uri);
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
108
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
109 User user = (User)session.getAttribute("user");
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
110 if (user == null) {
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
111 logger.debug("No user in session: " + requesturi);
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
112 this.redirect(resp);
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
113 return;
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
114 }
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
115 if (user.hasExpired()) {
2974
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
116 // try to re-authenticate the user
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
117 logger.debug("User ticket has expired: " + requesturi);
2974
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
118 String encoding = sreq.getCharacterEncoding();
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
119 try {
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
120 Authentication auth = this.auth(user, encoding);
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
121 if (auth == null || !auth.isSuccess()) {
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
122 logger.debug("Re-athentication not successful");
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
123 this.redirect(resp);
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
124 }
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
125 }
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
126 catch(AuthenticationException e) {
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
127 logger.error("Failure during re-authentication", e);
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
128 this.redirect(resp);
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
129 return;
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
130 }
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
131 }
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
132
2889
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
133 logger.debug("GGInAFilter.doFilter");
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
134 chain.doFilter(req, resp);
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
135 return;
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
136 }
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
137
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
138 private void redirect(ServletResponse resp) throws IOException {
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
139 logger.debug("Redirect to login");
3851
a4c9296f6efa Use the Context PATH servlet variable when using URLs in the GGInAFilter
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3485
diff changeset
140 ((HttpServletResponse) resp).sendRedirect(this.sc.getContextPath() +
a4c9296f6efa Use the Context PATH servlet variable when using URLs in the GGInAFilter
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3485
diff changeset
141 "/login.jsp");
2952
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
142 }
3cacd42a0336 Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2893
diff changeset
143
2889
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
144
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
145 /**
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
146 * Do nothing at destruction.
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
147 */
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
148 @Override
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
149 public void destroy() {
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
150 }
2974
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
151
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
152 private Authentication auth(User user, String encoding)
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
153 throws AuthenticationException, IOException {
3485
71ba3cf3ec5e Refactor Authentication to allow to pass the Freatures to the user class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2974
diff changeset
154 Features features = (Features)sc.getAttribute(Features.CONTEXT_ATTRIBUTE);
2974
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
155 return AuthenticationFactory.getInstance(this.authmethod).auth(
3485
71ba3cf3ec5e Refactor Authentication to allow to pass the Freatures to the user class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2974
diff changeset
156 user.getName(), user.getPassword(), encoding, features);
2974
8255247da645 Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2964
diff changeset
157 }
2889
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
158 }
6c613c9f3a51 Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
159 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org