Package org.casbin.jcasbin.rbac
Class ConditionalRoleManager
- java.lang.Object
-
- org.casbin.jcasbin.rbac.DefaultRoleManager
-
- org.casbin.jcasbin.rbac.ConditionalRoleManager
-
- All Implemented Interfaces:
RoleManager
public class ConditionalRoleManager extends DefaultRoleManager
-
-
Field Summary
-
Fields inherited from class org.casbin.jcasbin.rbac.DefaultRoleManager
allRoles, matchingFunc, maxHierarchyLevel
-
-
Constructor Summary
Constructors Constructor Description ConditionalRoleManager(int maxHierarchyLevel)ConditionalRoleManager(int maxHierarchyLevel, java.util.function.BiPredicate<java.lang.String,java.lang.String> matchingFunc, java.util.function.BiPredicate<java.lang.String,java.lang.String> domainMatchingFunc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDomainLinkConditionFunc(java.lang.String userName, java.lang.String roleName, java.lang.String domain, java.util.function.Function<java.lang.String[],java.lang.Boolean> fn)addDomainLinkConditionFunc is based on userName, roleName, domain, add LinkConditionFuncvoidaddLinkConditionFunc(java.lang.String userName, java.lang.String roleName, java.util.function.Function<java.lang.String[],java.lang.Boolean> fn)addLinkConditionFunc is based on userName, roleName, add LinkConditionFuncjava.util.function.Function<java.lang.String[],java.lang.Boolean>getDomainLinkConditionFunc(java.lang.String userName, java.lang.String roleName, java.lang.String domain)getDomainLinkConditionFunc get LinkConditionFunc based on userName, roleName, domainjava.util.function.Function<java.lang.String[],java.lang.Boolean>getLinkConditionFunc(java.lang.String userName, java.lang.String roleName)getLinkConditionFunc get LinkConditionFunc based on userName, roleNamejava.util.List<java.lang.String>getLinkConditionFuncParams(java.lang.String userName, java.lang.String roleName, java.lang.String[] domain)getLinkConditionFuncParams gets parameters of LinkConditionFunc based on userName, roleName, domainbooleangetNextRoles(Role currentRole, Role nextRole, java.lang.String[] domains, java.util.Map<java.lang.String,Role> nextRoles)booleanhasLink(java.lang.String name1, java.lang.String name2, java.lang.String... domains)hasLink determines whether role: name1 inherits role: name2.booleanhasLinkHelper(java.lang.String targetName, java.util.Map<java.lang.String,Role> roles, int level, java.lang.String... domains)voidsetDomainLinkConditionFuncParams(java.lang.String userName, java.lang.String roleName, java.lang.String domain, java.lang.String... params)SetDomainLinkConditionFuncParams sets parameters of LinkConditionFunc based on userName, roleName, domainvoidsetLinkConditionFuncParams(java.lang.String userName, java.lang.String roleName, java.lang.String... params)SetLinkConditionFuncParams sets parameters of LinkConditionFunc based on userName, roleName, domain-
Methods inherited from class org.casbin.jcasbin.rbac.DefaultRoleManager
addDomainMatchingFunc, addLink, addMatchingFunc, clear, copyFrom, deleteLink, getRole, getRoles, getUsers, match, printRoles, removeRole, toString
-
-
-
-
Constructor Detail
-
ConditionalRoleManager
public ConditionalRoleManager(int maxHierarchyLevel)
-
ConditionalRoleManager
public ConditionalRoleManager(int maxHierarchyLevel, java.util.function.BiPredicate<java.lang.String,java.lang.String> matchingFunc, java.util.function.BiPredicate<java.lang.String,java.lang.String> domainMatchingFunc)
-
-
Method Detail
-
hasLink
public boolean hasLink(java.lang.String name1, java.lang.String name2, java.lang.String... domains)Description copied from class:DefaultRoleManagerhasLink determines whether role: name1 inherits role: name2. domain is a prefix to the roles.- Specified by:
hasLinkin interfaceRoleManager- Overrides:
hasLinkin 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
public boolean hasLinkHelper(java.lang.String targetName, java.util.Map<java.lang.String,Role> roles, int level, java.lang.String... domains)
-
getNextRoles
public boolean getNextRoles(Role currentRole, Role nextRole, java.lang.String[] domains, java.util.Map<java.lang.String,Role> nextRoles)
-
getLinkConditionFunc
public java.util.function.Function<java.lang.String[],java.lang.Boolean> getLinkConditionFunc(java.lang.String userName, java.lang.String roleName)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 java.util.function.Function<java.lang.String[],java.lang.Boolean> getDomainLinkConditionFunc(java.lang.String userName, java.lang.String roleName, java.lang.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
public java.util.List<java.lang.String> getLinkConditionFuncParams(java.lang.String userName, java.lang.String roleName, java.lang.String[] domain)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
public void addLinkConditionFunc(java.lang.String userName, java.lang.String roleName, java.util.function.Function<java.lang.String[],java.lang.Boolean> fn)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(java.lang.String userName, java.lang.String roleName, java.lang.String domain, java.util.function.Function<java.lang.String[],java.lang.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
public void setLinkConditionFuncParams(java.lang.String userName, java.lang.String roleName, java.lang.String... params)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(java.lang.String userName, java.lang.String roleName, java.lang.String domain, java.lang.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.
-
-