Package org.casbin.jcasbin.rbac
Class ConditionalRoleManager
java.lang.Object
org.casbin.jcasbin.rbac.DefaultRoleManager
org.casbin.jcasbin.rbac.ConditionalRoleManager
- All Implemented Interfaces:
RoleManager
-
Field Summary
Fields inherited from class org.casbin.jcasbin.rbac.DefaultRoleManager
allRoles, matchingFunc, maxHierarchyLevel
-
Constructor Summary
ConstructorsConstructorDescriptionConditionalRoleManager
(int maxHierarchyLevel) ConditionalRoleManager
(int maxHierarchyLevel, BiPredicate<String, String> matchingFunc, BiPredicate<String, String> domainMatchingFunc) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDomainLinkConditionFunc
(String userName, String roleName, String domain, Function<String[], Boolean> fn) addDomainLinkConditionFunc is based on userName, roleName, domain, add LinkConditionFuncvoid
addLinkConditionFunc is based on userName, roleName, add LinkConditionFuncgetDomainLinkConditionFunc
(String userName, String roleName, String domain) getDomainLinkConditionFunc get LinkConditionFunc based on userName, roleName, domaingetLinkConditionFunc
(String userName, String roleName) getLinkConditionFunc get LinkConditionFunc based on userName, roleNamegetLinkConditionFuncParams
(String userName, String roleName, String[] domain) getLinkConditionFuncParams gets parameters of LinkConditionFunc based on userName, roleName, domainboolean
boolean
hasLink determines whether role: name1 inherits role: name2.boolean
void
setDomainLinkConditionFuncParams
(String userName, String roleName, String domain, String... params) SetDomainLinkConditionFuncParams sets parameters of LinkConditionFunc based on userName, roleName, domainvoid
setLinkConditionFuncParams
(String userName, String roleName, String... params) SetLinkConditionFuncParams sets parameters of LinkConditionFunc based on userName, roleName, domainMethods inherited from class org.casbin.jcasbin.rbac.DefaultRoleManager
addDomainMatchingFunc, addLink, addMatchingFunc, clear, copyFrom, deleteLink, getRole, getRoles, getUsers, match, printRoles, removeRole, toString
-
Constructor Details
-
ConditionalRoleManager
public ConditionalRoleManager(int maxHierarchyLevel) -
ConditionalRoleManager
public ConditionalRoleManager(int maxHierarchyLevel, BiPredicate<String, String> matchingFunc, BiPredicate<String, String> domainMatchingFunc)
-
-
Method Details
-
hasLink
Description copied from class:DefaultRoleManager
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.domains
- the domain the roles belong to.- Returns:
- whether name1 inherits name2 (name1 has role name2).
-
hasLinkHelper
-
getNextRoles
-
getLinkConditionFunc
getLinkConditionFunc get LinkConditionFunc based on userName, roleName- Parameters:
userName
- the name of the user for whom the link condition function is retrieved.roleName
- the name of the role for which the link condition function is retrieved.- Returns:
- the link condition function that determines the validity of the link for the given user and role.
-
getDomainLinkConditionFunc
public Function<String[],Boolean> getDomainLinkConditionFunc(String userName, String roleName, String domain) getDomainLinkConditionFunc get LinkConditionFunc based on userName, roleName, domain- Parameters:
userName
- the name of the user for whom the link condition function is retrieved.roleName
- the name of the role for which the link condition function is retrieved.domain
- the domain associated with the link condition function.- Returns:
- the link condition function that determines the validity of the link for the given user, role, and domain, or null if either the user or role does not exist.
-
getLinkConditionFuncParams
getLinkConditionFuncParams gets parameters of LinkConditionFunc based on userName, roleName, domain- Parameters:
userName
- the name of the user whose link condition function parameters are retrieved.roleName
- the name of the role whose link condition function parameters are retrieved.domain
- an array of domain names associated with the link condition function.- Returns:
- a list of parameters for the link condition function, or null if no parameters are found.
-
addLinkConditionFunc
addLinkConditionFunc is based on userName, roleName, add LinkConditionFunc- Parameters:
userName
- the name of the user for whom the link condition function is being added.roleName
- the name of the role associated with the link condition function.fn
- the link condition function to be added, which takes an array of strings and returns a boolean.
-
addDomainLinkConditionFunc
public void addDomainLinkConditionFunc(String userName, String roleName, String domain, Function<String[], Boolean> fn) addDomainLinkConditionFunc is based on userName, roleName, domain, add LinkConditionFunc- Parameters:
userName
- the name of the user for whom the link condition function is being added.roleName
- the name of the role associated with the link condition function.domain
- the domain for which the link condition function is applicable.fn
- the link condition function to be added, which takes an array of strings and returns a boolean.
-
setLinkConditionFuncParams
SetLinkConditionFuncParams sets parameters of LinkConditionFunc based on userName, roleName, domain- Parameters:
userName
- the name of the user for whom the link condition function parameters are being set.roleName
- the name of the role associated with the link condition function.params
- the parameters to be set for the link condition function.
-
setDomainLinkConditionFuncParams
public void setDomainLinkConditionFuncParams(String userName, String roleName, String domain, String... params) SetDomainLinkConditionFuncParams sets parameters of LinkConditionFunc based on userName, roleName, domain- Parameters:
userName
- the name of the user for whom the link condition function parameters are being set.roleName
- the name of the role associated with the link condition function.domain
- the domain related to the link condition function.params
- the parameters to be set for the link condition function.
-