Security Annotations

Two security annotations are provided as an alternative to the security checks methods provided by the AuthorizationManager interface.

They can be used to secure methods at any client side component or widget, since all the annotations are processed at compile-time by the Errai's code processor.

  • @ResourceCheck
import static org.uberfire.shared.authz.ProjectConstants.*;

@ResourceCheck(type=PROJECT, action=CREATE)
public void newProject() { this );

Every time the method newProject is called the security check defined in the annotation is processed, causing the method body to be executed only if the permission is granted.

  • @PermissionCheck

Annotation checks are supported for plain permissions as well.

public void showSalesReport() {;


Both annotations provide callback support:

@ResourceCheck(type=PROJECT, action=CREATE,
public void newProject() {;

public void onCreateGranted() {
    GWT.log("Project creation allowed");

public void onCreateDenied() {
    GWT.log("Project creation NOT allowed");

Callbacks can be used to add extra processing logic.

The example above without annotations:

AuthorizationManager authzManager;

public void newProject() {
    if (authzManager.authorize(PROJECT, CREATE)) {;
    else {


The security annotations are can only be used under certain conditions:

  • Only work on client side code
  • Only work on CDI managed beans
  • Only can be added to methods that return "void"
  • Only work if the method is called from an external component.
  • For inner component calls the solution is to use a delegate or a "self" instance.

results matching ""

    No results matching ""