Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/GGInAFilter.java @ 3864:c434dd2e84cf
Add the river name to the gaugeinfo
flys-client/trunk@5638 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Bjoern Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 08:52:53 +0000 |
parents | a4c9296f6efa |
children | 17fe00c09b7c |
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; |
3485
71ba3cf3ec5e
Refactor Authentication to allow to pass the Freatures to the user class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2974
diff
changeset
|
35 private ServletContext sc; |
2889
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 |
3851
a4c9296f6efa
Use the Context PATH servlet variable when using URLs in the GGInAFilter
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3485
diff
changeset
|
37 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
|
38 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
|
39 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
|
40 |
2889
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 |
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 * Initialize. |
2952
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
44 * |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
45 * Read FilterConfig parameter deactivate |
2889
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 */ |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 @Override |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 public void init(FilterConfig config) |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 throws ServletException |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 { |
2952
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
51 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
|
52 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
|
53 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
|
54 this.authmethod = sc.getInitParameter("authentication"); |
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
|
55 if (deactivate != null && deactivate.equalsIgnoreCase("true")) { |
2952
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
56 this.deactivate = true; |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
57 } |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
58 |
2889
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 } |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 |
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 * Called when filter in chain invoked. |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 * @param req request to servlet |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 * @param resp response of servlet |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 * @param chain the filter chain |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 */ |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 @Override |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 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
|
70 throws IOException, ServletException |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 { |
2952
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
72 if (this.deactivate) { |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
73 logger.debug("GGinAFilter is deactivated"); |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
74 chain.doFilter(req, resp); |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
75 return; |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
76 } |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
77 |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
78 HttpServletRequest sreq = (HttpServletRequest) req; |
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 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
|
81 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
|
82 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
|
83 } |
2952
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
84 |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
85 logger.debug("Request for: " + requesturi); |
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 // Allow access to login pages |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
88 // 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
|
89 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
|
90 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
|
91 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
|
92 || requesturi.equals(path + "/FLYS.css")) { |
2952
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
93 logger.debug("Request for login " + requesturi); |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
94 chain.doFilter(req, resp); |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
95 return; |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
96 } |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
97 |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
98 HttpSession session = sreq.getSession(); |
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 String uri = requesturi; |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
101 if (sreq.getQueryString() != null) { |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
102 uri = uri + "?" + sreq.getQueryString(); |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
103 } |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
104 session.setAttribute("requesturi", uri); |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
105 |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
106 User user = (User)session.getAttribute("user"); |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
107 if (user == null) { |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
108 logger.debug("No user in session: " + requesturi); |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
109 this.redirect(resp); |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
110 return; |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
111 } |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
112 if (user.hasExpired()) { |
2974
8255247da645
Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2964
diff
changeset
|
113 // try to re-authenticate the user |
2952
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
114 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
|
115 String encoding = sreq.getCharacterEncoding(); |
8255247da645
Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2964
diff
changeset
|
116 try { |
8255247da645
Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2964
diff
changeset
|
117 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
|
118 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
|
119 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
|
120 this.redirect(resp); |
8255247da645
Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2964
diff
changeset
|
121 } |
8255247da645
Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2964
diff
changeset
|
122 } |
8255247da645
Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2964
diff
changeset
|
123 catch(AuthenticationException e) { |
8255247da645
Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2964
diff
changeset
|
124 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
|
125 this.redirect(resp); |
8255247da645
Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2964
diff
changeset
|
126 return; |
8255247da645
Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2964
diff
changeset
|
127 } |
2952
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
128 } |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
129 |
2889
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
130 logger.debug("GGInAFilter.doFilter"); |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
131 chain.doFilter(req, resp); |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
132 return; |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
133 } |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
134 |
2952
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
135 private void redirect(ServletResponse resp) throws IOException { |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
136 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
|
137 ((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
|
138 "/login.jsp"); |
2952
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
139 } |
3cacd42a0336
Filter all requests to FLYS
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2893
diff
changeset
|
140 |
2889
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
141 |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
142 /** |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
143 * Do nothing at destruction. |
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 @Override |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
146 public void destroy() { |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
147 } |
2974
8255247da645
Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2964
diff
changeset
|
148 |
8255247da645
Implement re-authentication if the user (ticket) has expired.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2964
diff
changeset
|
149 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
|
150 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
|
151 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
|
152 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
|
153 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
|
154 } |
2889
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
155 } |
6c613c9f3a51
Stub for A&A Servlet Filter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
156 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |