Hi
I'm sure there are other solutions, but here's mine:
Code:
public class AjaxAwareAuthenticationEntryPoint extends AuthenticationProcessingFilterEntryPoint
{
public void commence(ServletRequest request, ServletResponse response, AuthenticationException authException) throws IOException, ServletException
{
if (((HttpServletRequest)request).getServletPath().equals("/ajax")) {
((HttpServletResponse)response).sendError(601, "");
} else {
super.commence(request, response, authException);
}
}
}
The idea - all Ajax request must be identifiable so SpringSecurity can handle them in a special way (to send HTTP return code instead of redirect/forward to login page).
and in JQuery (actually DOJO, but the idea is common), you use:
Code:
error: function(responseObject, ioArgs) {
if (responseObject.status == 601) {
// reload entire page - this leads to login page
window.location.reload();
} else {
dojo.byId('wait').style.display = 'none';
}
}
regards
Grzegorz Grzybek