Results 1 to 6 of 6

Thread: How do I log access denied (403) error ?

  1. #1
    Join Date
    Sep 2004
    Location
    Ostrava, Czech Republic
    Posts
    1

    Default How do I log access denied (403) error ?

    Hi,

    when authenticated user tries to access area secured by FilterSecurityInterceptor without having the required role, Acegi generates the "Access denied" error (403). This is fine, I have the application server to catch the error and show the error page. But it would be nice to have the error logged as well.

    Is there any way to achieve that? I thought of some similar solution like LoggerListener for authentication failures...

    Thanks,
    Pavel

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    You can do it today by subclassing SecurityEnforcementFilter and overriding sendAccessDeniedError(ServletRequest, ServletResponse).

    If other people want this feature built into Acegi Security, please speak up and I'll be pleased to add it.

  3. #3

    Default

    +1 to include feature

  4. #4

    Default

    Regarding this topic. I need a way to be able to externally call a controller so that my error page gets decorated by Sitemesh. Currently, using <error-page> tag in web.xml to trap the 403 returns the error page undecorated. So since that seems to be a Sitemesh bug, I tried this way to subclass the SecurityEnforcementFilter's sendAccessDeniedError method with the following code in it, but I still get the error page undecorated. Is there any way around this?

    Code:
    protected void sendAccessDeniedError&#40;ServletRequest request, ServletResponse response&#41; throws IOException &#123;
    		try &#123;
    		request.getRequestDispatcher&#40;"/browse/error.htm"&#41;.forward&#40;request, response&#41;;
    		&#125; catch &#40;ServletException se&#41; &#123;&#125;
    	&#125;

  5. #5

    Default

    I guess one way to do it is to forward to a dummy page that has a meta refresh tag that calls your error page. Then the decorators will get applied since the client is making the request.

  6. #6
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    I've just added to CVS a new package: net.sf.acegisecurity.intercept.event. It contains a variety of events which are published by AbstractSecurityInterceptor. There is also a LoggerListener which outputs the events to Commons Logging. Hopefully this will meet your requirements.

Similar Threads

  1. ERROR: Context initialization failed
    By makhlo in forum Architecture
    Replies: 8
    Last Post: Jul 11th, 2008, 01:41 AM
  2. Context initialization failed
    By kanonmicke in forum Container
    Replies: 7
    Last Post: Sep 29th, 2005, 12:35 AM
  3. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  4. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM
  5. Replies: 4
    Last Post: Nov 5th, 2004, 03:59 AM

Posting Permissions

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