Results 1 to 4 of 4

Thread: Best way to display the cause of AccessDeniedException?

  1. #1
    Join Date
    Aug 2008
    Posts
    5

    Default Best way to display the cause of AccessDeniedException?

    [please replace (at) with the at sign i.e. shift-2 on your keyboard on the below, apparently I can't use shift-2 for my first 15 posts because its a URL]

    Hi All,

    I'm wondering if there is a way to get the name of the method or some information about the call that generated the AccessDeniedException from an (at)Secured annotation.

    Ideally, I'd like to be able to display this info to the user something like this...
    Code:
    try {
     securedMethod1()
     securedMethod2()
     securedMethod3()
     securedMethod4()
     securedMethod5()
    } catch (AccessDeniedException ade) {
     System.out.println("Access was denied when attempting to call: " + ade.???);
    }
    where ??? is what I use to determine which object/method call triggered the AccessDeniedException

    -G

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    From a security point of view you don't want to show that information to a user.... With that information your user gains knowledge about the internals of your application, if there is one thing that you don't want your users to know it is the internals of your application.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    The security interceptor will publish an AuthorizationFailureEvent here:

    http://static.springframework.org/sp...eptor.html#265

    If you subscribe to these, you can extract the relevant information. The secured object is a MethodInvocation instance, which will contain the Method object.

  4. #4
    Join Date
    Aug 2008
    Posts
    5

    Default

    @Marten,

    If I was working on a web app I'd be inclined to agree with you, however in this case the app is swing based and supportability as important or even more so then security, so having something the user can screenshot that tells us exactly what happened will help a lot.

    @Luke

    Thanks, that looks like exactly what I'm looking for...
    Cheers

    -G

Posting Permissions

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