/** * Calls the parent class {@code handle()} method to forward or redirect to the target * URL, and then calls {@code clearAuthenticationAttributes()} to remove any leftover * session data. */ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { handle(request, response, authentication); clearAuthenticationAttributes(request); }
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException { SavedRequest savedRequest = this.requestCache.getRequest(request, response); if(savedRequest == null) { //super.onAuthenticationSuccess(request, response, authentication); handle(request, response, authentication); super.clearAuthenticationAttributes(request); } else { String targetUrlParameter = this.getTargetUrlParameter(); if(!this.isAlwaysUseDefaultTargetUrl() && (targetUrlParameter == null || !StringUtils.hasText(request.getParameter(targetUrlParameter)))) { this.clearAuthenticationAttributes(request); String targetUrl = savedRequest.getRedirectUrl(); this.logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl); //this.getRedirectStrategy().sendRedirect(request, response, targetUrl); } else { this.requestCache.removeRequest(request, response); //super.onAuthenticationSuccess(request, response, authentication); handle(request, response, authentication); super.clearAuthenticationAttributes(request); } } }