Annotation Type PermissionChecker


@Target(METHOD) @Retention(RUNTIME) public @interface PermissionChecker
Annotation that can be used to annotate a CDI bean method that checks if a SecurityIdentity holds a permission specified by the value(). For example:
 
 @Path("hello")
 public class HelloResource {

     @PermissionsAllowed("speak")
     @GET
     public String sayHello() {
         return "Hello World!";
     }

     @PermissionChecker("speak")
     public boolean canSpeak(SecurityIdentity identity) {
         return "speaker".equals(identity.getPrincipal().getName());
     }
 }
 
 
The permission checker methods can include any of secured method parameters (matched by name). Consider the following secured method:
 
 @PermissionsAllowed("update")
 public String updateString(String a, String b, String c, String d) {
     ...
 }
 
 
The permission checker that grants access to the updateString method can inject any arguments it requires and optionally even SecurityIdentity:
 
 @PermissionChecker("update")
 public boolean canUpdate(String c, String a, SecurityIdentity identity) {
     ...
 }
 
 
The permission checker method parameters are matched with the secured method parameters in exactly same fashion as are constructor parameters of a custom permission. Please see PermissionsAllowed.params() for more information.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Specifies a permission this checker grants.
  • Element Details