Announcement Announcement Module
Collapse
No announcement yet.
Problem adding pointcut at annotation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


    • #3
      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));

      Comment


      • #4
        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)?

        Comment

        Working...
        X