title: Play framework 2.2: How to get current controller and action in java
body: <p>In my application authentication scheme is based on user and role. users with particular role have access to particular action method.</p>
  
  <p>To implement this I have done following</p>
  
  <p>1.Write custom action</p>
  
  <pre><code>public class Authorization extends play.mvc.Action.Simple {
      public Promise&lt;Result&gt; call(Context ctx) throws Throwable {
          //check access
          return delegate.call(ctx);
      }
  }
  </code></pre>
  
  <p>2.Annotate controller with action</p>
  
  <pre><code>@With(actions.Authorization.class)
  public class Upload extends Controller {
      ....
  }
  </code></pre>
  
  <p>In my action I have access to user which is in session. I want to get current controller and action so that I can authenticate user. Is there any way to this?</p>
  
  <p>I have read about creating custom annotation with params and in each controller pass parameters to identify the action. But it seems to much work and error prone if by mistake i write wrong action name while copy paste.</p>
  
  <p>Thanks</p>