Package org.casbin.jcasbin.model
Class Model
java.lang.Object
org.casbin.jcasbin.model.Policy
org.casbin.jcasbin.model.Model
Model represents the whole access control model.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddDef adds an assertion to the model.intgetNameWithDomain(String domain, String name) getSubjectHierarchyMap(List<List<String>> policies) booleanhasSection(String sec) hasSection checks if the section exists in the model.voidloadModel loads the model from model CONF file.voidloadModelFromConfig loads the model from the configuration.voidloadModelFromText(String text) loadModelFromText loads the model from the text.static ModelnewModel()NewModel creates an empty model.static ModelnewModelFromFile(String path) NewModelFromString creates a model from a string which contains model text.static ModelnewModelFromString(String text) NewModelFromString creates a model from a string which contains model text.voidprintModel prints the model to the log.saveModelToText saves the model to the text.voidSetLogger sets the model's logger.voidsort policies by priority valuevoidsort policies by hieraichy maptoText()Methods inherited from class org.casbin.jcasbin.model.Policy
addPolicies, addPolicy, buildConditionalRoleLinks, buildIncrementalConditionalRoleLinks, buildIncrementalRoleLinks, buildRoleLinks, clearPolicy, getFilteredPolicy, getPolicy, getValuesForFieldInPolicy, hasPolicies, hasPolicy, printPolicy, removeFilteredPolicy, removeFilteredPolicyReturnsEffects, removePolicies, removePolicy, savePolicyToText, updatePolicy
-
Field Details
-
sectionNameMap
-
requiredSections
-
modCount
protected int modCount
-
-
Constructor Details
-
Model
public Model()
-
-
Method Details
-
getModCount
public int getModCount() -
addDef
addDef adds an assertion to the model.- Parameters:
sec- the section, "p" or "g".key- the policy type, "p", "p2", .. or "g", "g2", ..value- the policy rule, separated by ", ".- Returns:
- succeeds or not.
-
setLogger
SetLogger sets the model's logger.- Parameters:
logger- the logger to be set for the model.
-
newModel
NewModel creates an empty model.- Returns:
- a new instance of the Model.
-
newModelFromFile
NewModelFromString creates a model from a string which contains model text.- Parameters:
path- the path of the model file.- Returns:
- the model loaded from file.
-
newModelFromString
NewModelFromString creates a model from a string which contains model text.- Parameters:
text- the path of the file.- Returns:
- the model loaded from text.
-
loadModel
loadModel loads the model from model CONF file.- Parameters:
path- the path of the model file.
-
loadModelFromText
loadModelFromText loads the model from the text.- Parameters:
text- the model text.
-
loadModelFromConfig
loadModelFromConfig loads the model from the configuration.- Parameters:
cfg- the model text.
-
hasSection
hasSection checks if the section exists in the model.- Parameters:
sec- the section name to check, such as "p" or "g".- Returns:
- whether the section exists in the model.
-
saveModelToText
saveModelToText saves the model to the text.- Returns:
- the model text.
-
printModel
public void printModel()printModel prints the model to the log. -
sortPoliciesByPriority
public void sortPoliciesByPriority()sort policies by priority value -
sortPoliciesBySubjectHieraichy
public void sortPoliciesBySubjectHieraichy()sort policies by hieraichy map -
getSubjectHierarchyMap
-
getNameWithDomain
-
toText
-