Ben,
As I understand it, in the AbstractProcessingFilter, if the URL is for authentication, then the filter chain is not continued and the response is redirected on successful authentication.
I know that onSuccessfulAuthentication method can be overridden by a inherited class to do extra processing after authentication.
But, I would still like to continue the filter chain because tapestry can assign server state (like associating user) further down the chain on authentication and the response of which can be ignored by redirecting to another url in the filter.
2. Also, the login URL is not uniquely available since tapestry uses the same URL for all form requests (/app) and the fact that it is a login form is given as a hidden field in the form post data. So, I cant use j_acegi_security_check as the URL for filtering. I suggest to have a separate method requiresAuthentication(ServletRequest request) which can be overridden by inheriting classes of AbstractProcessingFilter.
This would involve the following change in the doFilter method for which I was planning to extend AuthenticationProcessingFilter. Please give me your suggestions if there is a better approach to the same.
---------------------------------------
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
if (!(request instanceof HttpServletRequest)) {
throw new ServletException("Can only process HttpServletRequest");
}
if (!(response instanceof HttpServletResponse)) {
throw new ServletException("Can only process HttpServletResponse");
}
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
/*---CHANGED THIS:: if (httpRequest.getRequestURL().toString().endsWith(h ttpRequest
.getContextPath() + filterProcessesUrl))
*/
// CHANGED TO:
if (requiresAuthentication(request)) // This checks for the post parameter
{
if (logger.isDebugEnabled()) {
logger.debug("Request is to process authentication");
}
onPreAuthentication(httpRequest, httpResponse);
Authentication authResult;
try {
authResult = attemptAuthentication(httpRequest);
} catch (AuthenticationException failed) {
// Authentication failed
unsuccessfulAuthentication(httpRequest, httpResponse, failed);
return;
}
// Authentication success
//ADDED THIS ::: ----------------------------------------------
chain.doFilter(request,response);
//------------------------------------------------------------------
successfulAuthentication(httpRequest, httpResponse, authResult);
return;
}
chain.doFilter(request, response);
}
Regards,
John


