Announcement Announcement Module
Collapse
No announcement yet.
Cannot send error with Custom LoginUrlAuthenticationEntryPoint Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 05:37 PM.

  • #2
    Nevermind, the problem was the specific error code I was sending.

    Comment

    Working...
    X