Package org.casbin.jcasbin.main
Class SyncedCachedEnforcer
java.lang.Object
org.casbin.jcasbin.main.CoreEnforcer
org.casbin.jcasbin.main.ManagementEnforcer
org.casbin.jcasbin.main.Enforcer
org.casbin.jcasbin.main.SyncedEnforcer
org.casbin.jcasbin.main.SyncedCachedEnforcer
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.SyncedCachedEnforcer(String modelPath) Initializes an enforcer with a model file.SyncedCachedEnforcer(String modelPath, String policyFile) Initializes an enforcer with a model file and a policy file.SyncedCachedEnforcer(String modelPath, String policyFile, boolean enableLog) Initializes an enforcer with a model file, a policy file, and a logging flag.SyncedCachedEnforcer(String modelPath, Adapter adapter) Initializes an enforcer with a model file and a database adapter.Initializes an enforcer with a model.SyncedCachedEnforcer(Model m, Adapter adapter) Initializes an enforcer with a model and a database adapter. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddPolicies(String[][] rules) Adds multiple policies while checking and removing the cache.booleanaddPolicies(List<List<String>> rules) Adds multiple policies while checking and removing the cache.booleanAdds a single policy while checking and removing the cache.voidbuildIncrementalRoleLinks(Model.PolicyOperations op, String ptype, List<List<String>> rules) buildIncrementalRoleLinks provides incremental build the role inheritance relations.voidenableCache(boolean enable) Enables or disables caching.booleanPerforms an enforcement check based on given parameters, using the cache.getCacheKey(Object... params) Retrieves a cache key from the given parameters.voidInvalidates the cache by clearing it.voidLoads the policy, clearing the cache if enabled.booleanremovePolicies(String[][] rules) Removes multiple policies while checking and removing the cache.booleanremovePolicies(List<List<String>> rules) Removes multiple policies while checking and removing the cache.booleanremovePolicy(String... params) Removes a single policy while checking and removing the cache.voidSets a custom cache.voidsetExpireTime(Duration expireTime) Sets the cache expiration time.Methods inherited from class org.casbin.jcasbin.main.SyncedEnforcer
addGroupingPolicies, addGroupingPolicies, addGroupingPolicy, addGroupingPolicy, addNamedGroupingPolicies, addNamedGroupingPolicies, addNamedGroupingPolicy, addNamedGroupingPolicy, addNamedPolicies, addNamedPoliciesEx, addNamedPolicy, addNamedPolicy, addPermissionForUser, addPermissionForUser, addPolicy, addRoleForUser, addRoleForUserInDomain, batchEnforce, batchEnforceWithMatcher, buildRoleLinks, clearPolicy, deletePermission, deletePermission, deletePermissionForUser, deletePermissionForUser, deletePermissionsForUser, deleteRole, deleteRoleForUser, deleteRoleForUserInDomain, deleteRolesForUser, deleteUser, enforceEx, enforceExWithMatcher, enforceWithMatcher, getAllActions, getAllNamedActions, getAllNamedObjects, getAllNamedRoles, getAllObjects, getAllRoles, getAllSubjects, getFilteredGroupingPolicy, getFilteredNamedGroupingPolicy, getFilteredNamedPolicy, getFilteredPolicy, getGroupingPolicy, getImplicitPermissionsForUser, getImplicitRolesForUser, getNamedGroupingPolicy, getNamedImplicitPermissionsForUser, getNamedPermissionsForUser, getNamedPolicy, getPermissionsForUser, getPermissionsForUserInDomain, getPolicy, getRolesForUser, getRolesForUserInDomain, getUsersForRole, getUsersForRoleInDomain, hasGroupingPolicy, hasGroupingPolicy, hasNamedGroupingPolicy, hasNamedGroupingPolicy, hasNamedPolicy, hasNamedPolicy, hasPermissionForUser, hasPermissionForUser, hasPolicy, hasPolicy, hasRoleForUser, isAutoLoadingRunning, loadFilteredPolicy, removeFilteredGroupingPolicy, removeFilteredNamedGroupingPolicy, removeFilteredNamedPolicy, removeFilteredPolicy, removeGroupingPolicies, removeGroupingPolicies, removeGroupingPolicy, removeGroupingPolicy, removeNamedGroupingPolicies, removeNamedGroupingPolicies, removeNamedGroupingPolicy, removeNamedGroupingPolicy, removeNamedPolicies, removeNamedPolicy, removeNamedPolicy, removePolicy, savePolicy, setWatcher, startAutoLoadPolicy, stopAutoLoadPolicy, updateGroupingPolicy, updateNamedGroupingPolicy, updateNamedPolicy, updatePolicyMethods inherited from class org.casbin.jcasbin.main.Enforcer
getImplicitPermissionsForUserInDomain, getImplicitUsersForRole, updatePermissionForUserMethods inherited from class org.casbin.jcasbin.main.ManagementEnforcer
addFunction, getAllNamedSubjects, getPermittedActionsMethods inherited from class org.casbin.jcasbin.main.CoreEnforcer
addNamedDomainLinkConditionFunc, addNamedDomainMatchingFunc, addNamedLinkConditionFunc, addNamedMatchingFunc, buildConditionalRoleLinks, enableAcceptJsonRequest, enableAutoBuildRoleLinks, enableAutoSave, enableEnforce, enableLog, getAdapter, getAviatorEval, getModel, getNamedRoleManager, getRmMap, getRoleManager, isAutoNotifyDispatcher, isAutoNotifyWatcher, isFiltered, loadModel, mustUseDispatcher, newModel, newModel, newModel, resetExpressionEvaluator, setAdapter, setAutoNotifyDispatcher, setAutoNotifyWatcher, setAviatorEvaluator, setDispatcher, setEffector, setModel, setNamedDomainLinkConditionFuncParams, setNamedLinkConditionFuncParams, setNamedRoleManager, setRoleManager, setRoleManager, validateEnforce
-
Constructor Details
-
SyncedCachedEnforcer
public SyncedCachedEnforcer()Default constructor. Initializes a new SyncedCachedEnforcer with a default cache. -
SyncedCachedEnforcer
Initializes an enforcer with a model file and a policy file.- Parameters:
modelPath- The path of the model file.policyFile- The path of the policy file.
-
SyncedCachedEnforcer
Initializes an enforcer with a model file and a database adapter.- Parameters:
modelPath- The path of the model file.adapter- The adapter for the database.
-
SyncedCachedEnforcer
Initializes an enforcer with a model and a database adapter.- Parameters:
m- The model.adapter- The adapter for the database.
-
SyncedCachedEnforcer
Initializes an enforcer with a model.- Parameters:
m- The model.
-
SyncedCachedEnforcer
Initializes an enforcer with a model file.- Parameters:
modelPath- The path of the model file.
-
SyncedCachedEnforcer
Initializes an enforcer with a model file, a policy file, and a logging flag.- Parameters:
modelPath- The path of the model file.policyFile- The path of the policy file.enableLog- Whether to enable logging for Casbin.
-
-
Method Details
-
enableCache
public void enableCache(boolean enable) Enables or disables caching.- Parameters:
enable- Whether to enable caching.
-
enforce
Performs an enforcement check based on given parameters, using the cache.- Overrides:
enforcein classSyncedEnforcer- Parameters:
rvals- Parameters for the enforcement check.- Returns:
- The result of the enforcement check.
-
loadPolicy
public void loadPolicy()Loads the policy, clearing the cache if enabled.- Overrides:
loadPolicyin classSyncedEnforcer
-
addPolicy
Adds a single policy while checking and removing the cache.- Overrides:
addPolicyin classSyncedEnforcer- Parameters:
params- Policy parameters.- Returns:
- Whether the addition was successful.
-
addPolicies
Adds multiple policies while checking and removing the cache.- Overrides:
addPoliciesin classSyncedEnforcer- Parameters:
rules- Policy rules.- Returns:
- Whether the addition was successful.
-
addPolicies
Adds multiple policies while checking and removing the cache.- Overrides:
addPoliciesin classSyncedEnforcer- Parameters:
rules- Policy rules.- Returns:
- Whether the addition was successful.
-
removePolicy
Removes a single policy while checking and removing the cache.- Overrides:
removePolicyin classSyncedEnforcer- Parameters:
params- Policy parameters.- Returns:
- Whether the removal was successful.
-
removePolicies
Removes multiple policies while checking and removing the cache.- Overrides:
removePoliciesin classSyncedEnforcer- Parameters:
rules- Policy rules.- Returns:
- Whether the removal was successful.
-
removePolicies
Removes multiple policies while checking and removing the cache.- Overrides:
removePoliciesin classSyncedEnforcer- Parameters:
rules- Policy rules.- Returns:
- Whether the removal was successful.
-
setExpireTime
Sets the cache expiration time.- Parameters:
expireTime- The expiration time.
-
setCache
Sets a custom cache.- Parameters:
cache- The custom cache.
-
getCacheKey
Retrieves a cache key from the given parameters.- Parameters:
params- The parameters for generating the key.- Returns:
- The generated cache key as a string.
-
invalidateCache
public void invalidateCache()Invalidates the cache by clearing it. -
buildIncrementalRoleLinks
public void buildIncrementalRoleLinks(Model.PolicyOperations op, String ptype, List<List<String>> rules) buildIncrementalRoleLinks provides incremental build the role inheritance relations.- Parameters:
op- Policy operations.ptype- policy type.rules- the rules.
-