Spring SecuritywithJSFのタイムアウトに関して次の問題があります。
要求されたページが保護されている場合(つまり、認証されたユーザーのみに許可されている場合)にユーザーがinvalidSessionUrlにリダイレクトされるように、セッション管理フィルターをカスタマイズしました。SpringSecurityが提供するセッション管理フィルターに入れたカスタムコードは次のとおりです。
if (invalidSessionUrl != null) {
String pagSolicitada = UtilSpringSecurity.extraerPagina(request);
if ( UtilSpringSecurity.paginaAutenticada(pagSolicitada ) ) {
request.getSession();
redirectStrategy.sendRedirect(request, response, invalidSessionUrl);
return;
}
//the requested page doesn't require the user to be authenticated
//so i just skip this filter and continue with the filter chain
chain.doFilter(request, response);
return;
}
メソッド「UtilSpringSecurity.extraerPagina(request)」は、要求されたページを次のように返します。
public static String extraerPagina (HttpServletRequest request) {
String uri = request.getRequestURI().toLowerCase();
String cPath = request.getContextPath().toLowerCase();
// uri = cPath + pagina
int longCPath = cPath.length();
String pagina = uri.substring(longCPath);
return pagina;
}
また、メソッド「UtilSpringSecurity.paginaAutenticada(pagSolicitada)」は、パラメータがユーザーの認証を必要とするページである場合にtrueを返します(私はIFを使用してチェックを行い、xmlセキュリティ構成ファイルのintercept-url要素を考慮します。属性access="isAuthenticated()"
):
public static boolean paginaAutenticada (String pagina) {
if (pagina.startsWith("/faces/paginas/administracion/") || pagina.startsWith("/faces/paginas/barco/") ) {
return true;
}
return false;
}
このソリューションは機能しますが、問題が1つだけあります。
セッションのタイムアウトが切れるまでブラウザをページでアイドル状態のままにして、同じページをリクエストすると、「viewExpiredException」が発生します。これは、フィルターが正常に機能し、invalidSessionUrlへのリダイレクトをバイパスしたためですが、とにかくセッションが期限切れになると、同じページを再レンダリングしようとすると例外が発生します。
セッションタイムアウトの期限が切れたときに他のセキュリティで保護されていないページを要求すると、正常に機能し、ページに正しくリダイレクトされ、viewExpiredExceptionが発生しません。
誰もがこれを解決する方法を知っていますか?
前もって感謝します。