SecurityContextHolder.getContext().setAuthentication(null);
    protected void sendStartAuthentication(FilterInvocation fi,        AuthenticationException reason) throws ServletException, IOException {        HttpServletRequest request = (HttpServletRequest) fi.getRequest();        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) : "") +            request.getContextPath() + fi.getRequestUrl();        if (logger.isDebugEnabled()) {            logger.debug(                "Authentication entry point being called; target URL added to Session: " +                targetUrl);        }        if (createSessionAllowed) {            ((HttpServletRequest) request).getSession().setAttribute(AbstractProcessingFilter.ACEGI_SECURITY_TARGET_URL_KEY,                targetUrl);        }        authenticationEntryPoint.commence(request,            (HttpServletResponse) fi.getResponse(), reason);    }