title: Spring MVC + Before Advice check security
body: <p>I'm testing Spring AOP framework and have the following question.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>package danny.test.controllers;
  
  @Controller
  public class MyController{
  
  @Autowired
  private DaoService service;
  
  @RequestMapping(value="/save",method = RequestMethod.POST)
        public String addUser(@Valid MyClass myClass, BindingResult result){
  
  service.save(myClass);
  
  return "Ok";
  }
  </code></pre>
  
  <p>I would like to create before Advice aspect to check user security in user session. </p>
  
  <pre><code>@Aspect
  public class Profiler {
  
      @Pointcut("execution(* danny.test.services.DaoServices.*.*(..))")
      public void methods(){}
  
      @Before("methods()")
      public void checkSecurity() throws Throwable{
          //check session if user is authenticated....
      }
  
  }
  </code></pre>
  
  <p>What I don't know what to do is to cancel execution of DaoServices.save method if the user is not authenticated and cause controller to return any other value instead of "ok". </p>
  
  <p>Can i do it? 
  Can someone point me to such example? 
  Can I use @Around advice for such actions?</p>