Results 1 to 2 of 2

Thread: Cannot send error with Custom LoginUrlAuthenticationEntryPoint

  1. #1

    Default Cannot send error with Custom LoginUrlAuthenticationEntryPoint

    Hi, I have extended LoginUrlAuthenticationEntryPoint in order to send an Error code in certain situations instead of redirecting to the login page, but the error status is not being set.

    Code:
    public class AjaxAwareAuthenticationEntryPoint extends LoginUrlAuthenticationEntryPoint {
    	
    	private static final Logger logger = LoggerFactory.getLogger(AjaxAwareAuthenticationEntryPoint.class);
    
    	@Override
    	public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) 
    			throws IOException, ServletException {
    	
    		if(request.getHeader("ajax") != null) {
    
    			response.sendError(HttpStatus.SC_REQUEST_TIMEOUT);
    		}
    		else {
    			super.commence(request, response, authException);
    		}
    	}
    }
    I am setting up the header in an ajax request from the client, the header is being set properly and response.sendError, but I never get the error code on the other end.

    I am injecting the custom entry point in the <http> element of the spring security namespace.

    I am using JQuery on the client side.

    What am I doing wrong?

    Thanks,
    Angel
    Last edited by Angel; May 17th, 2010 at 04:37 PM.

  2. #2

    Default

    Nevermind, the problem was the specific error code I was sending.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •