Results 1 to 4 of 4

Thread: Problem adding pointcut at annotation

  1. #1

    Question Problem adding pointcut at annotation

    Hi All,

    I'm trying to use Spring Security to do authorization, and through the JSR-250 annotations. I need to create a before advice where the pointcut would be the RolesAllowed annotation (for any method annotated with it).

    I've been going through what examples I have found on the web so far, but to no avail:

    Note: I'm replacing the (at) symbol for annotations to # because I don't have 15 posts yet and it's interpreting them as URLs

    Code:
    #Before("execution(#javax.annotation.security.RolesAllowed * *.*(..))")
    //#Before("execution(* *.*(..)) && #annotation(javax.annotation.security.RolesAllowed)")
    public void authenticate(){
    	System.out.println("In authentication advice");
    }
    and the method...

    Code:
    #RolesAllowed( {"ROLE_OPERATOR"} )
    public String doSomething(String input) {
           return input;
    }
    Thanks in advance for any help!

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

    Default

    Why would you need to create your own? Spring already has an infrastructure in place for that which is a simple matter of configuration?!
    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

    Default

    What I'm trying to do with the aspect is create a UsernamePasswordAuthenticationToken. I have an AuthenticationManager created and I'm using the LdapAuthenticationProvider.

    The main line of code in the aspect is this:

    SecurityContextHolder.getContext().setAuthenticati on(authManager.authenticate(token));

  4. #4

    Default

    Is the issue that the pointcut does work, but instead of the aspect executing before the pointcut/authorization is performed by Spring, that it's going to execute after (but still before the method)?

Posting Permissions

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