Jan 10th, 2007, 12:16 PM
Upon AccessDeniedException Get URL Accessed
I have setup Acegi, but when I get an AccessDeniedException and the handler calls the configured JSP page, I would like to know what URL caused the problem. Is this available in the active scope of the SecurityContext? The call to request.getRequestURL() or getRequestURI() only returns the name of the JSP that I have configured to handle the exception.
Jan 10th, 2007, 02:53 PM
I don't think you know this information, you'd have to code this yourself.
Jan 30th, 2007, 12:54 PM
Thanks for the help. I'll take a deeper look into it when I get some more time.
Feb 27th, 2007, 11:06 AM
Ok, getting back to this it seems one has to implement the org.acegisecurity.ui.AccessDeniedHandler interface or override the actual implementation class being used (AccessDeniedHandlerImpl). Inside the implementation one can get access to the necessary information then implement home grown logic (prob not recommended) or call the acegi superclass' handle method (making sure to call the superclass after doing nec. work since the superclass commits the response). Once done, make sure to configure the handler in the Spring XML configuration if using Acegi within Spring (prob the handler for an ExceptionTranslationFilter). Pretty straightforward, hth