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
-
Element Details
-
value
String valueSpecifies a permission this checker grants.- Returns:
- name of the permission this checker grants
- See Also:
-