Bonjour,
J'ai un problème au niveau de la gestion de l'expiration de session. L'utilisateur se connecte à l'application et peut naviguer sans problème. si cette personne se déconnecte et je reconnecte il n'y a pas de problème elle peut a nouveau naviguer sans problème.
Ensuite si la personne se connecte et n'utilise plus la session ouverte durant un certain temps alors la session est expiré. si on clique sur un des lien de la page alors l'utilisateur est redirigé vers la page de login. Le problème et que cette fois si elle s'identifie (de façon correcte) et bien le navigateur affiche le message suite :
Boucle de redirection
Firefox a détecté que le serveur redirige la demande pour cette adresse d'une manière qui n'aboutira pas.
Le navigateur a arrêté d'attendre une réponse du site. Le site crée une redirection de telle sorte que la requête ne peut jamais aboutir.
* Avez-vous désactivé ou bloqué les cookies nécessaires pour ce site ?
* NOTE : Si le problème n'est pas résolu en acceptant les cookies de ce site, il s'agit probablement d'un problème de configuration du serveur et non de votre ordinateur.
Et voici mon log :
log4j:ERROR Attempted to append to closed appender named [administrationFileAppender].
2008-12-26 16:19:34,883 [] DEBUG com.archipel.administration.web.servlet.SessionTimeoutFilter: reqPath=/ArchiPEL/Administration/webui/login.faces
log4j:ERROR Attempted to append to closed appender named [administrationFileAppender].
2008-12-26 16:19:39,615 [] DEBUG com.archipel.administration.web.servlet.SessionTimeoutFilter: reqPath=/ArchiPEL/Administration//webui/acceptors/Acceptors.faces
log4j:ERROR Attempted to append to closed appender named [administrationFileAppender].
2008-12-26 16:19:39,616 [] DEBUG com.archipel.administration.web.servlet.SessionTimeoutFilter: reqPath=/ArchiPEL/Administration//webui/acceptors/Acceptors.faces
log4j:ERROR Attempted to append to closed appender named [administrationFileAppender].
2008-12-26 16:19:39,616 [] ERROR com.archipel.administration.web.servlet.SessionTimeoutFilter: Invalid session. Redirecting to acceptor page.
log4j:ERROR Attempted to append to closed appender named [administrationFileAppender].
2008-12-26 16:19:39,691 [] DEBUG com.archipel.administration.web.servlet.SessionTimeoutFilter: reqPath=/ArchiPEL/Administration/webui/acceptors/Acceptors.faces
log4j:ERROR Attempted to append to closed appender named [administrationFileAppender].
2008-12-26 16:19:39,691 [] DEBUG com.archipel.administration.web.servlet.SessionTimeoutFilter: reqPath=/ArchiPEL/Administration/webui/acceptors/Acceptors.faces
log4j:ERROR Attempted to append to closed appender named [administrationFileAppender].
2008-12-26 16:19:39,691 [] ERROR com.archipel.administration.web.servlet.SessionTimeoutFilter: Invalid session. Redirecting to acceptor page.
log4j:ERROR Attempted to append to closed appender named [administrationFileAppender].
2008-12-26 16:19:39,784 [] DEBUG com.archipel.administration.web.servlet.SessionTimeoutFilter: reqPath=/ArchiPEL/Administration/webui/acceptors/Acceptors.faces
log4j:ERROR Attempted to append to closed appender named [administrationFileAppender].
2008-12-26 16:19:39,785 [] DEBUG com.archipel.administration.web.servlet.SessionTimeoutFilter: reqPath=/ArchiPEL/Administration/webui/acceptors/Acceptors.faces
log4j:ERROR Attempted to append to closed appender named [administrationFileAppender].
2008-12-26 16:19:39,785 [] ERROR com.archipel.administration.web.servlet.SessionTimeoutFilter: Invalid session. Redirecting to acceptor page.
log4j:ERROR Attempted to append to closed appender named [administrationFileAppender].
2008-12-26 16:19:39,854 [] DEBUG com.archipel.administration.web.servlet.SessionTimeoutFilter: reqPath=/ArchiPEL/Administration/webui/acceptors/Acceptors.faces
log4j:ERROR Attempted to append to closed appender named [administrationFileAppender].
2008-12-26 16:19:39,855 [] DEBUG com.archipel.administration.web.servlet.SessionTimeoutFilter: reqPath=/ArchiPEL/Administration/webui/acceptors/Acceptors.faces
log4j:ERROR Attempted to append to closed appender named [administrationFileAppender].
2008-12-26 16:19:39,855 [] ERROR com.archipel.administration.web.servlet.SessionTimeoutFilter: Invalid session. Redirecting to acceptor page.
code du filtre:
Et voici la configuration de mon fichier web.xmlCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 public class SessionTimeoutFilter implements Filter { private final Logger logger = Logger.getLogger(SessionTimeoutFilter.class); private static final String[] ALL_ACCESS_PAGE = new String[]{"login", "loginError"}; /**Filter initialization. * @param filterConfig * @throws javax.servlet.ServletException */ @Override public void init(FilterConfig filterConfig) throws ServletException { } @Override public void destroy() { } public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { if ((request instanceof HttpServletRequest) && (response instanceof HttpServletResponse)) { HttpServletRequest hRequest = (HttpServletRequest) request; HttpServletResponse hResponse = (HttpServletResponse) response; if (checkResource(hRequest)) { if (checkSession(hRequest)) { String timeoutUrl = hRequest.getContextPath() + "/webui/login.faces"; logger.error("Invalid session. Redirecting to login page."); hResponse.sendRedirect(timeoutUrl); return; } if (null == hRequest.getSession().getAttribute("NewSessionBean")) { if (checkResource(hRequest)) { String timeoutUrl = hRequest.getContextPath() + "/webui/acceptors/Acceptors.faces"; logger.error("Invalid session. Redirecting to acceptor page."); hResponse.sendRedirect(timeoutUrl); return; } } } filterChain.doFilter(request, response); } } private boolean checkResource(HttpServletRequest request) { String requestPath = request.getRequestURI(); logger.debug("reqPath=" + requestPath); return !(requestPath.contains("login.faces") || requestPath.contains("loginError.faces") || requestPath.contains("login.jsp") || requestPath.contains("loginError.jsp")); } private boolean checkSession(HttpServletRequest request) { return request.getRequestedSessionId() != null && !request.isRequestedSessionIdValid(); }
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47<filter> <filter-name>SessionTimeoutFilter</filter-name> <filter-class> com.archipel.administration.web.servlet.SessionTimeoutFilter </filter-class> </filter> <filter-mapping> <filter-name>SessionTimeoutFilter</filter-name> <servlet-name>Faces Servlet</servlet-name> </filter-mapping> <session-config> <session-timeout>2</session-timeout> </session-config> <welcome-file-list> <welcome-file>/webui/index.jsp</welcome-file> </welcome-file-list> <security-constraint> <display-name>normal</display-name> <web-resource-collection> <web-resource-name>normal</web-resource-name> <url-pattern>*.jsp</url-pattern> <url-pattern>*.faces</url-pattern> </web-resource-collection> <auth-constraint> <role-name>Administrator</role-name> <role-name>ProductionManager</role-name> <role-name>AccountManager</role-name> <role-name>Maintainer</role-name> <role-name>FinancialRiskManager</role-name> <role-name>TerminalPoolManager</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint> <login-config> <auth-method>FORM</auth-method> <realm-name>ArchiPELRealm</realm-name> <form-login-config> <form-login-page>/webui/login.faces</form-login-page> <form-error-page>/webui/loginError.faces</form-error-page> </form-login-config> </login-config>