Class ConditionalRoleManager

java.lang.Object
org.casbin.jcasbin.rbac.DefaultRoleManager
org.casbin.jcasbin.rbac.ConditionalRoleManager
All Implemented Interfaces:
RoleManager

public class ConditionalRoleManager extends DefaultRoleManager
  • Constructor Details

    • ConditionalRoleManager

      public ConditionalRoleManager(int maxHierarchyLevel)
    • ConditionalRoleManager

      public ConditionalRoleManager(int maxHierarchyLevel, BiPredicate<String,String> matchingFunc, BiPredicate<String,String> domainMatchingFunc)
  • Method Details

    • hasLink

      public boolean hasLink(String name1, String name2, String... domains)
      Description copied from class: DefaultRoleManager
      hasLink determines whether role: name1 inherits role: name2. domain is a prefix to the roles.
      Specified by:
      hasLink in interface RoleManager
      Overrides:
      hasLink in class DefaultRoleManager
      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(String targetName, Map<String,Role> roles, int level, String... domains)
    • getNextRoles

      public boolean getNextRoles(Role currentRole, Role nextRole, String[] domains, Map<String,Role> nextRoles)
    • getLinkConditionFunc

      public Function<String[],Boolean> getLinkConditionFunc(String userName, 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 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

      public List<String> getLinkConditionFuncParams(String userName, String roleName, 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(String userName, String roleName, Function<String[],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(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

      public void setLinkConditionFuncParams(String userName, String roleName, 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(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.