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.private voidfindHierarchy(Map<String, String> policyMap, Map<String, Integer> subjectHierarchyMap, List<String> set, String child) private StringgetKeySuffix(int i) intgetNameWithDomain(String domain, String name) getParamsToken(String value) getParamsToken Get ParamsToken from Assertion.ValuegetSubjectHierarchyMap(List<List<String>> policies) booleanhasSection(String sec) hasSection checks if the section exists in the model.private booleanloadAssertion(Model model, Config cfg, String sec, String key) 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.private voidloadSection(Model model, Config cfg, String sec) private voidloadSections(Config cfg) Helper function for loadModel and loadModelFromTextstatic 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.private StringsaveSectionToText(String sec) saveSectionToText saves the section to the text.voidSetLogger sets the model's logger.voidsort policies by priority valuevoidsort policies by hieraichy maptoText()private voidwriteString(StringBuilder s, String sec, Map<String, String> tokenPatterns) Methods inherited from class 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 -
domainIndex
private int domainIndex -
defaultDomain
-
defaultSeparator
-
paramsPattern
-
-
Constructor Details
-
Model
public Model()
-
-
Method Details
-
getModCount
public int getModCount() -
loadAssertion
-
getParamsToken
-
addDef
-
getKeySuffix
-
loadSection
-
loadSections
Helper function for loadModel and loadModelFromText- Parameters:
cfg- the configuration parser
-
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
-
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.
-
saveSectionToText
-
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
-
findHierarchy
-
getNameWithDomain
-
toText
-
writeString
-