Package org.casbin.jcasbin.rbac
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.
-
-
Field Summary
-
Fields inherited from class org.casbin.jcasbin.rbac.DefaultRoleManager
allRoles, matchingFunc, maxHierarchyLevel
-
-
Constructor Summary
Constructors Constructor Description GroupRoleManager(int maxHierarchyLevel)
GroupRoleManager is the constructor for creating an instance of the GroupRoleManager implementation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasLink(java.lang.String name1, java.lang.String name2, java.lang.String... domain)
hasLink determines whether role: name1 inherits role: name2.-
Methods inherited from class org.casbin.jcasbin.rbac.DefaultRoleManager
addDomainMatchingFunc, addLink, addMatchingFunc, clear, copyFrom, deleteLink, getRole, getRoles, getUsers, match, printRoles, removeRole, toString
-
-
-
-
Method Detail
-
hasLink
public boolean hasLink(java.lang.String name1, java.lang.String name2, java.lang.String... domain)
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).
-
-