Package org.casbin.jcasbin.rbac
Class DomainManager
java.lang.Object
org.casbin.jcasbin.rbac.DomainManager
- All Implemented Interfaces:
RoleManager
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private BiPredicate
<String, String> private SyncedLRUCache
<String, Boolean> private BiPredicate
<String, String> private int
private Map
<String, DefaultRoleManager> -
Constructor Summary
ConstructorsConstructorDescriptionDomainManager
(int maxHierarchyLevel) DomainManager
(int maxHierarchyLevel, BiPredicate<String, String> matchingFunc, BiPredicate<String, String> domainMatchingFunc) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDomainMatchingFunc
(String name, BiPredicate<String, String> domainMatchingFunc) void
addLink adds the inheritance link between two roles.void
addMatchingFunc
(String name, BiPredicate<String, String> matchingFunc) void
clear()
Clear clears all stored data and resets the role manager to the initial state.void
deleteLink
(String name1, String name2, String... domain) deleteLink deletes the inheritance link between two roles.private String
domainName
(String... domain) private DefaultRoleManager
getRoleManager
(String domain, boolean store) getRoles gets the roles that a user inherits.getUsers gets the users that inherits a role.boolean
hasLink determines whether a link exists between two roles.private boolean
void
printRoles prints all the roles to log.private void
rebuild()
rebuild clears the map of RoleManagerstoString()
-
Field Details
-
DEFAULT_DOMAIN
- See Also:
-
rmMap
-
maxHierarchyLevel
private int maxHierarchyLevel -
matchingFunc
-
domainMatchingFunc
-
domainMatchingFuncCache
-
-
Constructor Details
-
DomainManager
public DomainManager(int maxHierarchyLevel) -
DomainManager
public DomainManager(int maxHierarchyLevel, BiPredicate<String, String> matchingFunc, BiPredicate<String, String> domainMatchingFunc)
-
-
Method Details
-
addMatchingFunc
-
addDomainMatchingFunc
-
rebuild
private void rebuild()rebuild clears the map of RoleManagers -
domainName
-
getRoleManager
-
match
-
clear
public void clear()Description copied from interface:RoleManager
Clear clears all stored data and resets the role manager to the initial state.- Specified by:
clear
in interfaceRoleManager
-
addLink
Description copied from interface:RoleManager
addLink adds the inheritance link between two roles. role: name1 and role: name2. domain is a prefix to the roles.- Specified by:
addLink
in interfaceRoleManager
- Parameters:
name1
- the first role (or user).name2
- the second role.domain
- the domain the roles belong to.
-
deleteLink
Description copied from interface:RoleManager
deleteLink deletes the inheritance link between two roles. role: name1 and role: name2. domain is a prefix to the roles.- Specified by:
deleteLink
in interfaceRoleManager
- Parameters:
name1
- the first role (or user).name2
- the second role.domain
- the domain the roles belong to.
-
hasLink
Description copied from interface:RoleManager
hasLink determines whether a link exists between two roles. role: name1 inherits role: name2. domain is a prefix to the roles.- Specified by:
hasLink
in interfaceRoleManager
- 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).
-
getRoles
Description copied from interface:RoleManager
getRoles gets the roles that a user inherits. domain is a prefix to the roles.- Specified by:
getRoles
in interfaceRoleManager
- Parameters:
name
- the user (or a role).domain
- the domain the roles belong to.- Returns:
- the roles.
-
getUsers
Description copied from interface:RoleManager
getUsers gets the users that inherits a role.- Specified by:
getUsers
in interfaceRoleManager
- Parameters:
name
- the role.domain
- is a prefix to the users (can be used for other purposes).- Returns:
- the users.
-
toString
-
printRoles
public void printRoles()Description copied from interface:RoleManager
printRoles prints all the roles to log.- Specified by:
printRoles
in interfaceRoleManager
-