This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <beans> | |
| ... | |
| <bean class="security.SecurityAspect" /> | |
| <aop:aspectj-autoproxy /> | |
| </beans> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | @Aspect | |
| @Component | |
| public class SecuredAspect { | |
| @Pointcut("@annotation(annotation)") | |
| @SuppressWarnings("unused") | |
| private void secured(Secured annotation) { | |
| } | |
| @Around("secured(annotation)") | |
| public Object aroundCachedMethods(ProceedingJoinPoint thisJoinPoint, Secured annotation) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | @Target({ ElementType.METHOD }) | |
| @Retention(RetentionPolicy.RUNTIME) | |
| @Inherited | |
| @Documented | |
| public @interface Secured { | |
| Boolean admin() default false; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | @Controller | |
| public class MyController { | |
| @Secured(admin = true) | |
| @RequestMapping(value="/show_users.html", method = RequestMethod.GET) | |
| public String showAllUsers(Model model) { | |
| ... | |
| } | |
| ... | |
| } | 
NewerOlder