Annotation Interface ResourceRole


@Target(TYPE) @Retention(RUNTIME) public @interface ResourceRole
Indicates that annotated interface is a "Resource Role". Resource role is a container that holds resource policies.

Resource policies define permissions for any system resource: screen, entity read or create operation, entity attribute, etc.

Annotated interfaces are parsed by the AnnotatedResourceRoleProvider and ResourceRole objects are created using the information from the annotated interface.

Role definition example:

 @ResourceRole(code = "orderView", name = "Order view")
 public interface OrderViewRole {

     @MenuPolicy(menuIds = {"application", "application-orders"})
     @ScreenPolicy(screenIds = {"sample_Order.browse", "sample_Order.edit"})
     @EntityPolicy(entityClass = Order.class,
         actions = {EntityPolicyAction.CREATE, EntityPolicyAction.READ})
     @EntityAttributePolicy(entityClass = Order.class,
         attributes = {"number", "date"},
         actions = {EntityAttributePolicyAction.UPDATE})
     void order();

     @ScreenPolicy(screenClasses = {CustomerBrowse.class, CustomerEdit.class})
     @EntityPolicy(entityClass = Customer.class,
         actions = {EntityPolicyAction.ALL})
     @EntityAttributePolicy(entityClass = Customer.class,
         attributes = {"*"},
         actions = {EntityAttributePolicyAction.UPDATE})
     void customer();
 }
 

Role interface may have any number of methods. Methods can have any names, methods are used only to group policies logically. Policies may be grouped by entity they relate (as in the example above) or by type (one method will have annotations for screen policies, another one for entity policies, etc.).

Method return type matters only for methods with ExplicitResourcePolicies annotations.

See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Role code is an unique role identifier.
    Role name.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Role description
    Role security scope.
  • Element Details

    • name

      String name
      Role name.
    • code

      String code
      Role code is an unique role identifier. It is used for linking the role with the user.
    • description

      String description
      Role description
      Default:
      ""
    • scope

      String[] scope
      Role security scope.
      Default:
      {"UI", "API"}