Package org.casbin.jcasbin.rbac
Class GroupRoleManager
java.lang.Object
org.casbin.jcasbin.rbac.DefaultRoleManager
org.casbin.jcasbin.rbac.GroupRoleManager
- All Implemented Interfaces:
RoleManager
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.
-
Field Summary
Fields inherited from class org.casbin.jcasbin.rbac.DefaultRoleManager
allRoles, matchingFunc, maxHierarchyLevel
-
Constructor Summary
ConstructorsConstructorDescriptionGroupRoleManager
(int maxHierarchyLevel) GroupRoleManager is the constructor for creating an instance of the GroupRoleManager implementation. -
Method Summary
Methods inherited from class org.casbin.jcasbin.rbac.DefaultRoleManager
addDomainMatchingFunc, addLink, addMatchingFunc, clear, copyFrom, deleteLink, getRole, getRoles, getUsers, match, printRoles, removeRole, toString
-
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
hasLink determines whether role: name1 inherits role: name2. domain is a prefix to the roles.- Specified by:
hasLink
in interfaceRoleManager
- Overrides:
hasLink
in classDefaultRoleManager
- 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).
-