%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
net.sf.infrared.web.filter.InfraREDSessionFilter |
|
|
1 | /* |
|
2 | * Copyright 2005 Tavant Technologies and Contributors |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
15 | * |
|
16 | * |
|
17 | * |
|
18 | * Original Author: prashant.nair (Tavant Technologies) |
|
19 | * Contributor(s): -; |
|
20 | * |
|
21 | * |
|
22 | * Changes: |
|
23 | * -------- |
|
24 | * |
|
25 | */ |
|
26 | ||
27 | package net.sf.infrared.web.filter; |
|
28 | ||
29 | import java.io.IOException; |
|
30 | ||
31 | import javax.servlet.Filter; |
|
32 | import javax.servlet.FilterChain; |
|
33 | import javax.servlet.FilterConfig; |
|
34 | import javax.servlet.ServletException; |
|
35 | import javax.servlet.ServletRequest; |
|
36 | import javax.servlet.ServletResponse; |
|
37 | import javax.servlet.http.HttpServletRequest; |
|
38 | import javax.servlet.http.HttpServletResponse; |
|
39 | import javax.servlet.http.HttpSession; |
|
40 | ||
41 | import net.sf.infrared.base.util.LoggingFactory; |
|
42 | import net.sf.infrared.web.util.PerformanceDataSnapshot; |
|
43 | ||
44 | import org.apache.log4j.Logger; |
|
45 | ||
46 | /** |
|
47 | * |
|
48 | * @author prashant.nair |
|
49 | * Filter to check for session expiration in infrared. If the session expires |
|
50 | * the request gets directed to the performance summary page where the |
|
51 | * performance data snapshot is reset in the session. |
|
52 | */ |
|
53 | ||
54 | 0 | public class InfraREDSessionFilter implements Filter { |
55 | 0 | private static Logger logger = |
56 | LoggingFactory.getLogger("net.sf.infrared.web.filter.InfraREDSessionFilter"); |
|
57 | ||
58 | private FilterConfig filterConfig; |
|
59 | ||
60 | public void init(FilterConfig filterConfig) throws ServletException { |
|
61 | 0 | this.filterConfig = filterConfig; |
62 | 0 | } |
63 | ||
64 | public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) |
|
65 | throws IOException, ServletException { |
|
66 | 0 | String value = filterConfig.getInitParameter("excludeUrl"); |
67 | 0 | String url = ((HttpServletRequest) req).getRequestURI(); |
68 | ||
69 | 0 | HttpSession session = ((HttpServletRequest) req).getSession(); |
70 | 0 | PerformanceDataSnapshot perfData = (PerformanceDataSnapshot) session |
71 | .getAttribute("perfData"); |
|
72 | ||
73 | 0 | if ((url.indexOf(value) > -1) || (perfData != null)) { |
74 | 0 | chain.doFilter(req, res); |
75 | } |
|
76 | else { |
|
77 | 0 | logger.error(" Creating a new user session. Forwarding to performance summary page"); |
78 | 0 | ((HttpServletResponse) (res)).sendRedirect("perfData_summaryAction.do"); |
79 | } |
|
80 | 0 | } |
81 | ||
82 | public void destroy() { |
|
83 | 0 | this.filterConfig = null; |
84 | 0 | } |
85 | ||
86 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |