Announcement Announcement Module
No announcement yet.
Problem adding pointcut at annotation Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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

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

    #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?!


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


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