public class CachedEnforcer extends Enforcer
| Constructor and Description |
|---|
CachedEnforcer()
Default constructor for CachedEnforcer.
|
CachedEnforcer(Model m)
Initializes an enforcer with a model.
|
CachedEnforcer(Model m,
Adapter adapter)
Initializes an enforcer with a model and a database adapter.
|
CachedEnforcer(java.lang.String modelPath)
Initializes an enforcer with a model file.
|
CachedEnforcer(java.lang.String modelPath,
Adapter adapter)
Initializes an enforcer with a model file and a database adapter.
|
CachedEnforcer(java.lang.String modelPath,
java.lang.String policyFile)
Initializes an enforcer with a model file and a policy file.
|
CachedEnforcer(java.lang.String modelPath,
java.lang.String policyFile,
boolean enableLog)
Initializes an enforcer with a model file, a policy file, and a logging flag.
|
| Modifier and Type | Method and Description |
|---|---|
void |
buildIncrementalRoleLinks(Model.PolicyOperations op,
java.lang.String ptype,
java.util.List<java.util.List<java.lang.String>> rules)
buildIncrementalRoleLinks provides incremental build the role inheritance relations.
|
void |
clearPolicy()
Clears all policies from the enforcer.
|
boolean |
enforce(java.lang.Object... rvals)
Enforces a policy based on the given request values.
|
Cache |
getCache()
Retrieves the current cache used by this CachedEnforcer.
|
java.lang.String |
getCacheKey(java.lang.Object... params)
Retrieves a cache key from the given parameters.
|
void |
invalidateCache()
Invalidates all cached decisions.
|
void |
loadPolicy()
Loads policies into the enforcer.
|
boolean |
removePolicies(java.util.List<java.util.List<java.lang.String>> rules)
Removes multiple policies from the enforcer.
|
boolean |
removePolicies(java.lang.String[][] rules)
Removes multiple policies from the enforcer.
|
boolean |
removePolicy(java.lang.String... params)
Removes a policy from the enforcer.
|
void |
setCache(Cache cache)
Sets a custom cache implementation.
|
void |
setExpireTime(java.time.Duration expireTime)
Sets the expiration time for cached items.
|
addPermissionForUser, addPermissionForUser, addRoleForUser, addRoleForUserInDomain, batchEnforce, batchEnforceWithMatcher, deletePermission, deletePermission, deletePermissionForUser, deletePermissionForUser, deletePermissionsForUser, deleteRole, deleteRoleForUser, deleteRoleForUserInDomain, deleteRolesForUser, deleteUser, getImplicitPermissionsForUser, getImplicitPermissionsForUserInDomain, getImplicitRolesForUser, getImplicitUsersForRole, getNamedImplicitPermissionsForUser, getPermissionsForUser, getPermissionsForUserInDomain, getRolesForUser, getRolesForUserInDomain, getUsersForRole, getUsersForRoleInDomain, hasPermissionForUser, hasPermissionForUser, hasRoleForUser, updatePermissionForUseraddFunction, addGroupingPolicies, addGroupingPolicies, addGroupingPolicy, addGroupingPolicy, addNamedGroupingPolicies, addNamedGroupingPolicies, addNamedGroupingPolicy, addNamedGroupingPolicy, addNamedPolicies, addNamedPoliciesEx, addNamedPolicy, addNamedPolicy, addPolicies, addPolicies, addPolicy, addPolicy, getAllActions, getAllNamedActions, getAllNamedObjects, getAllNamedRoles, getAllNamedSubjects, getAllObjects, getAllRoles, getAllSubjects, getFilteredGroupingPolicy, getFilteredNamedGroupingPolicy, getFilteredNamedPolicy, getFilteredPolicy, getGroupingPolicy, getNamedGroupingPolicy, getNamedPolicy, getPermittedActions, getPolicy, hasGroupingPolicy, hasGroupingPolicy, hasNamedGroupingPolicy, hasNamedGroupingPolicy, hasNamedPolicy, hasNamedPolicy, hasPolicy, hasPolicy, removeFilteredGroupingPolicy, removeFilteredNamedGroupingPolicy, removeFilteredNamedPolicy, removeFilteredPolicy, removeGroupingPolicies, removeGroupingPolicies, removeGroupingPolicy, removeGroupingPolicy, removeNamedGroupingPolicies, removeNamedGroupingPolicies, removeNamedGroupingPolicy, removeNamedGroupingPolicy, removeNamedPolicies, removeNamedPolicy, removeNamedPolicy, removePolicy, updateGroupingPolicy, updateNamedGroupingPolicy, updateNamedPolicy, updatePolicyaddNamedDomainLinkConditionFunc, addNamedDomainMatchingFunc, addNamedLinkConditionFunc, addNamedMatchingFunc, buildConditionalRoleLinks, buildRoleLinks, enableAcceptJsonRequest, enableAutoBuildRoleLinks, enableAutoSave, enableEnforce, enableLog, enforceEx, enforceExWithMatcher, enforceWithMatcher, getAdapter, getAviatorEval, getModel, getNamedRoleManager, getRmMap, getRoleManager, isAutoNotifyDispatcher, isAutoNotifyWatcher, isFiltered, loadFilteredPolicy, loadModel, mustUseDispatcher, newModel, newModel, newModel, resetExpressionEvaluator, savePolicy, setAdapter, setAutoNotifyDispatcher, setAutoNotifyWatcher, setAviatorEvaluator, setDispatcher, setEffector, setModel, setNamedDomainLinkConditionFuncParams, setNamedLinkConditionFuncParams, setNamedRoleManager, setRoleManager, setRoleManager, setWatcher, validateEnforcepublic CachedEnforcer()
public CachedEnforcer(java.lang.String modelPath,
java.lang.String policyFile)
modelPath - The path of the model file.policyFile - The path of the policy file.public CachedEnforcer(java.lang.String modelPath,
Adapter adapter)
modelPath - The path of the model file.adapter - The adapter for the database.public CachedEnforcer(Model m, Adapter adapter)
m - The model.adapter - The adapter for the database.public CachedEnforcer(Model m)
m - The model.public CachedEnforcer(java.lang.String modelPath)
modelPath - The path of the model file.public CachedEnforcer(java.lang.String modelPath,
java.lang.String policyFile,
boolean enableLog)
modelPath - The path of the model file.policyFile - The path of the policy file.enableLog - Whether to enable logging for Casbin.public Cache getCache()
public boolean enforce(java.lang.Object... rvals)
enforce in class CoreEnforcerrvals - The request values, usually in the format of (sub, obj, act).public void loadPolicy()
loadPolicy in class CoreEnforcerpublic boolean removePolicy(java.lang.String... params)
removePolicy in class ManagementEnforcerparams - The parameters of the policy to be removed.public boolean removePolicies(java.util.List<java.util.List<java.lang.String>> rules)
removePolicies in class ManagementEnforcerrules - The list of policies to be removed.public boolean removePolicies(java.lang.String[][] rules)
removePolicies in class ManagementEnforcerrules - The list of policies to be removed.public void setExpireTime(java.time.Duration expireTime)
expireTime - The duration after which cached items will expire.public void setCache(Cache cache)
cache - The cache instance to use.public java.lang.String getCacheKey(java.lang.Object... params)
params - The parameters for generating the key.public void invalidateCache()
public void clearPolicy()
clearPolicy in class CoreEnforcerpublic void buildIncrementalRoleLinks(Model.PolicyOperations op, java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
op - Policy operations.ptype - policy type.rules - the rules.Copyright © 2017–2025. All rights reserved.