Class GroupRoleManager

java.lang.Object
org.casbin.jcasbin.rbac.DefaultRoleManager
org.casbin.jcasbin.rbac.GroupRoleManager
All Implemented Interfaces:
RoleManager

public class GroupRoleManager extends DefaultRoleManager
GroupRoleManager is used for authorization if the user's group is the role who has permission, but the group information is in the default format (policy start with "g") and the role information is in named format (policy start with "g2", "g3", ...). e.g. p, admin, domain1, data1, read g, alice, group1 g2, group1, admin, domain1 As for the previous example, alice should have the permission to read data1, but if we use the DefaultRoleManager, it will return false. GroupRoleManager is to handle this situation.
  • Constructor Details

    • GroupRoleManager

      public GroupRoleManager(int maxHierarchyLevel)
      GroupRoleManager is the constructor for creating an instance of the GroupRoleManager implementation.
      Parameters:
      maxHierarchyLevel - the maximized allowed RBAC hierarchy level.
  • Method Details

    • hasLink

      public boolean hasLink(String name1, String name2, String... domain)
      hasLink determines whether role: name1 inherits role: name2. domain is a prefix to the roles.
      Specified by:
      hasLink in interface RoleManager
      Overrides:
      hasLink in class DefaultRoleManager
      Parameters:
      name1 - the first role (or a user).
      name2 - the second role.
      domain - the domain the roles belong to.
      Returns:
      whether name1 inherits name2 (name1 has role name2).