+ targetUrl);
+ targetUrl, authentication);
    public void doFilter(ServletRequest request, ServletResponse response,        FilterChain chain) throws IOException, ServletException {        if (!(request instanceof HttpServletRequest)) {            throw new ServletException("HttpServletRequest required");        }        if (!(response instanceof HttpServletResponse)) {            throw new ServletException("HttpServletResponse required");        }        FilterInvocation fi = new FilterInvocation(request, response, chain);        try {            filterSecurityInterceptor.invoke(fi);            if (logger.isDebugEnabled()) {                logger.debug("Chain processed normally");            }        } catch (AuthenticationException authentication) {            HttpServletRequest httpRequest = (HttpServletRequest) request;            int port = portResolver.getServerPort(request);            boolean includePort = true;            if ("http".equals(request.getScheme().toLowerCase())                && (port == 80)) {                includePort = false;            }            if ("https".equals(request.getScheme().toLowerCase())                && (port == 443)) {                includePort = false;            }            String targetUrl = request.getScheme() + "://"                + request.getServerName() + ((includePort) ? (":" + port) : "")                + httpRequest.getContextPath() + fi.getRequestUrl();            if (logger.isDebugEnabled()) {                logger.debug(                    "Authentication failed - adding target URL to Session: "                    + targetUrl);            }            ((HttpServletRequest) request).getSession().setAttribute(AbstractProcessingFilter.ACEGI_SECURITY_TARGET_URL_KEY,                targetUrl);            authenticationEntryPoint.commence(request, response);        } catch (AccessDeniedException accessDenied) {            if (logger.isDebugEnabled()) {                logger.debug(                    "Access is denied - sending back forbidden response");            }            ((HttpServletResponse) response).sendError(HttpServletResponse.SC_FORBIDDEN); // 403        } catch (Throwable otherException) {            throw new ServletException(otherException);        }    }