Class Policy
java.lang.Object
org.casbin.jcasbin.model.Policy
- Direct Known Subclasses:
Model
Policy represents the whole access control policy user defined.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddPolicies adds policy rules to the model.booleanaddPolicy adds a policy rule to the model.voidbuildConditionalRoleLinks(Map<String, ConditionalRoleManager> condRmMap) buildConditionalRoleLinks initializes the roles in RBAC.voidbuildIncrementalConditionalRoleLinks(Map<String, ConditionalRoleManager> condRmMap, Model.PolicyOperations op, String sec, String ptype, List<List<String>> rules) buildIncrementalConditionalRoleLinks provides incremental build the role inheritance relations.voidbuildIncrementalRoleLinks(Map<String, RoleManager> rmMap, Model.PolicyOperations op, String sec, String ptype, List<List<String>> rules) voidbuildRoleLinks(Map<String, RoleManager> rmMap) buildRoleLinks initializes the roles in RBAC.voidclearPolicy clears all current policy.getFilteredPolicy(String sec, String ptype, int fieldIndex, String... fieldValues) getFilteredPolicy gets rules based on field filters from a policy.getPolicy gets all rules in a policy.getValuesForFieldInPolicy(String sec, String ptype, int fieldIndex) getValuesForFieldInPolicy gets all values for a field for all rules in a policy, duplicated values are removed.booleanbooleanhasPolicy determines whether a model has the specified policy rule.voidprintPolicy prints the policy to log.booleanremoveFilteredPolicy(String sec, String ptype, int fieldIndex, String... fieldValues) removeFilteredPolicy removes policy rules based on field filters from the model.removeFilteredPolicyReturnsEffects(String sec, String ptype, int fieldIndex, String... fieldValues) removeFilteredPolicyReturnsEffects removes policy rules based on field filters from the model.booleanremovePolicies removes rules from the current policy.booleanremovePolicy(String sec, String ptype, List<String> rule) removePolicy removes a policy rule from the model.savePolicyToText saves the policy to the text.booleanUpdatePolicy updates a policy rule from the model.
-
Field Details
-
model
-
-
Constructor Details
-
Policy
public Policy()
-
-
Method Details
-
buildRoleLinks
buildRoleLinks initializes the roles in RBAC.- Parameters:
rmMap- the role manager map.
-
printPolicy
public void printPolicy()printPolicy prints the policy to log. -
savePolicyToText
savePolicyToText saves the policy to the text.- Returns:
- the policy text.
-
clearPolicy
public void clearPolicy()clearPolicy clears all current policy. -
getPolicy
-
getFilteredPolicy
public List<List<String>> getFilteredPolicy(String sec, String ptype, int fieldIndex, String... fieldValues) getFilteredPolicy gets rules based on field filters from a policy.- Parameters:
sec- the section, "p" or "g".ptype- the policy type, "p", "p2", .. or "g", "g2", ..fieldIndex- the policy rule's start index to be matched.fieldValues- the field values to be matched, value "" means not to match this field.- Returns:
- the filtered policy rules of section sec and policy type ptype.
-
hasPolicy
-
addPolicy
-
addPolicies
-
updatePolicy
UpdatePolicy updates a policy rule from the model.- Parameters:
sec- the section, "p" or "g".ptype- the policy type, "p", "p2", .. or "g", "g2", ..oldRule- the old rule.newRule- the new rule.- Returns:
- succeeds or not.
-
removePolicy
-
removePolicies
-
removeFilteredPolicyReturnsEffects
public List<List<String>> removeFilteredPolicyReturnsEffects(String sec, String ptype, int fieldIndex, String... fieldValues) removeFilteredPolicyReturnsEffects removes policy rules based on field filters from the model.- Parameters:
sec- the section, "p" or "g".ptype- the policy type, "p", "p2", .. or "g", "g2", ..fieldIndex- the policy rule's start index to be matched.fieldValues- the field values to be matched, value "" means not to match this field.- Returns:
- succeeds(effects.size () > 0) or not.
-
removeFilteredPolicy
public boolean removeFilteredPolicy(String sec, String ptype, int fieldIndex, String... fieldValues) removeFilteredPolicy removes policy rules based on field filters from the model.- Parameters:
sec- the section, "p" or "g".ptype- the policy type, "p", "p2", .. or "g", "g2", ..fieldIndex- the policy rule's start index to be matched.fieldValues- the field values to be matched, value "" means not to match this field.- Returns:
- succeeds or not.
-
getValuesForFieldInPolicy
getValuesForFieldInPolicy gets all values for a field for all rules in a policy, duplicated values are removed.- Parameters:
sec- the section, "p" or "g".ptype- the policy type, "p", "p2", .. or "g", "g2", ..fieldIndex- the policy rule's index.- Returns:
- the field values specified by fieldIndex.
-
buildIncrementalRoleLinks
public void buildIncrementalRoleLinks(Map<String, RoleManager> rmMap, Model.PolicyOperations op, String sec, String ptype, List<List<String>> rules) -
hasPolicies
-
buildIncrementalConditionalRoleLinks
public void buildIncrementalConditionalRoleLinks(Map<String, ConditionalRoleManager> condRmMap, Model.PolicyOperations op, String sec, String ptype, List<List<String>> rules) buildIncrementalConditionalRoleLinks provides incremental build the role inheritance relations.- Parameters:
condRmMap- a map of conditional role managers used for role link management.op- the operation to perform, such as adding or removing role links.sec- the section of the policy, typically "g" for role inheritance.ptype- the policy type, which specifies the kind of roles being managed.rules- the rules that define the role links to be built.
-
buildConditionalRoleLinks
buildConditionalRoleLinks initializes the roles in RBAC.- Parameters:
condRmMap- a map of conditional role managers that manage the role links and their conditions.
-