Announcement Announcement Module
Collapse
No announcement yet.
Exception not seen by ExceptionHandler Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception not seen by ExceptionHandler

    Hi all.

    Im still new to the springframework and acegi.
    I have this problem. In my App I have a class that implements HandlerExceptionResolver to catch all exceptions and display the modelview what I want for different exceptions(Using ResourceBundleMessageSource). It works perfectly for all my exceptions(Database,Access denied,etc) except if the user enters a url he's not supose to view I get the 403 forbidden page. Im not sure if the FilterSecurityInterceptor throws a exception. My Exception Handler does not see any exception. Thus, I just want to specify my custom error modelview when a user enters a forbidden URL.

    I anyone can please help or put me in a direction to what I should do.
    Thanks

  • #2
    FilterSecurityInterceptor, if there is an AccessDeniedException in deciding whether to allow a given URI to be called, will never pass to the underlaying servlets (including HandlerExceptionResolver).

    Your easiest solution for a custom error page for 403 errors is to override this method in FilterSecurityInterceptor with a standard redirect:

    Code:
        protected void sendAccessDeniedError(FilterInvocation fi,
            AccessDeniedException accessDenied)
            throws ServletException, IOException {
            ((HttpServletRequest) fi.getRequest()).getSession().setAttribute(ACEGI_SECURITY_ACCESS_DENIED_EXCEPTION_KEY,
                accessDenied);
            ((HttpServletResponse) fi.getResponse()).sendError(HttpServletResponse.SC_FORBIDDEN,
                accessDenied.getMessage()); // 403
        }

    Comment


    • #3
      Thanks Ben. Were also thinking that wil be the easiest solution.

      Comment

      Working...
      X