Package org.casbin.jcasbin.main
Class DistributedEnforcer
- java.lang.Object
-
- org.casbin.jcasbin.main.CoreEnforcer
-
- org.casbin.jcasbin.main.InternalEnforcer
-
- org.casbin.jcasbin.main.ManagementEnforcer
-
- org.casbin.jcasbin.main.Enforcer
-
- org.casbin.jcasbin.main.SyncedEnforcer
-
- org.casbin.jcasbin.main.DistributedEnforcer
-
public class DistributedEnforcer extends SyncedEnforcer
DistributedEnforcer wraps SyncedEnforcer for dispatcher.
-
-
Field Summary
-
Fields inherited from class org.casbin.jcasbin.main.CoreEnforcer
acceptJsonRequest, adapter, autoBuildRoleLinks, autoNotifyDispatcher, autoNotifyWatcher, autoSave, condRmMap, dispatcher, fm, model, modelPath, rmMap, watcher
-
-
Constructor Summary
Constructors Constructor Description DistributedEnforcer()
DistributedEnforcer is the default constructor.DistributedEnforcer(java.lang.String modelPath)
DistributedEnforcer initializes an enforcer with a model file.DistributedEnforcer(java.lang.String modelPath, java.lang.String policyFile)
DistributedEnforcer initializes an enforcer with a model file and a policy file.DistributedEnforcer(java.lang.String modelPath, java.lang.String policyFile, boolean enableLog)
DistributedEnforcer initializes an enforcer with a model file, a policy file and an enable log flag.DistributedEnforcer(java.lang.String modelPath, Adapter adapter)
DistributedEnforcer initializes an enforcer with a database adapter.DistributedEnforcer(Model m)
DistributedEnforcer initializes an enforcer with a model.DistributedEnforcer(Model m, Adapter adapter)
DistributedEnforcer initializes an enforcer with a model and a database adapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.util.List<java.lang.String>>
addPolicySelf(java.util.function.BooleanSupplier shouldPersist, java.lang.String sec, java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
AddPolicySelf provides a method for dispatcher to add authorization rules to the current policy.void
clearPolicySelf(java.util.function.BooleanSupplier shouldPersist)
ClearPolicySelf provides a method for dispatcher to clear all rules from the current policy.java.util.List<java.util.List<java.lang.String>>
removeFilteredPolicySelf(java.util.function.BooleanSupplier shouldPersist, java.lang.String sec, java.lang.String ptype, int fieldIndex, java.lang.String... fieldValues)
RemoveFilteredPolicySelf provides a method for dispatcher to remove an authorization rule from the current policy, field filters can be specified.java.util.List<java.util.List<java.lang.String>>
removePolicySelf(java.util.function.BooleanSupplier shouldPersist, java.lang.String sec, java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
RemovePolicySelf provides a method for dispatcher to remove policies from current policy.boolean
updatePolicySelf(java.util.function.BooleanSupplier shouldPersist, java.lang.String sec, java.lang.String ptype, java.util.List<java.lang.String> oldRule, java.util.List<java.lang.String> newRule)
UpdatePolicySelf provides a method for dispatcher to update an authorization rule from the current policy.-
Methods inherited from class org.casbin.jcasbin.main.SyncedEnforcer
addGroupingPolicies, addGroupingPolicies, addGroupingPolicy, addGroupingPolicy, addNamedGroupingPolicies, addNamedGroupingPolicies, addNamedGroupingPolicy, addNamedGroupingPolicy, addNamedPolicies, addNamedPoliciesEx, addNamedPolicy, addNamedPolicy, addPermissionForUser, addPermissionForUser, addPolicies, addPolicies, addPolicy, addPolicy, addRoleForUser, addRoleForUserInDomain, batchEnforce, batchEnforceWithMatcher, buildRoleLinks, clearPolicy, deletePermission, deletePermission, deletePermissionForUser, deletePermissionForUser, deletePermissionsForUser, deleteRole, deleteRoleForUser, deleteRoleForUserInDomain, deleteRolesForUser, deleteUser, enforce, 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, loadPolicy, removeFilteredGroupingPolicy, removeFilteredNamedGroupingPolicy, removeFilteredNamedPolicy, removeFilteredPolicy, removeGroupingPolicies, removeGroupingPolicies, removeGroupingPolicy, removeGroupingPolicy, removeNamedGroupingPolicies, removeNamedGroupingPolicies, removeNamedGroupingPolicy, removeNamedGroupingPolicy, removeNamedPolicies, removeNamedPolicy, removeNamedPolicy, removePolicies, removePolicies, removePolicy, removePolicy, savePolicy, setWatcher, startAutoLoadPolicy, stopAutoLoadPolicy, updateGroupingPolicy, updateNamedGroupingPolicy, updateNamedPolicy, updatePolicy
-
Methods inherited from class org.casbin.jcasbin.main.Enforcer
getImplicitPermissionsForUserInDomain, getImplicitUsersForRole, updatePermissionForUser
-
Methods inherited from class org.casbin.jcasbin.main.ManagementEnforcer
addFunction, getAllNamedSubjects, getPermittedActions
-
Methods inherited from class org.casbin.jcasbin.main.InternalEnforcer
addPolicies, addPolicy, buildIncrementalRoleLinks, getDomainIndex, removeFilteredPolicy, removePolicies, removePolicy, updatePolicy
-
Methods inherited from class org.casbin.jcasbin.main.CoreEnforcer
addNamedDomainLinkConditionFunc, addNamedDomainMatchingFunc, addNamedLinkConditionFunc, addNamedMatchingFunc, buildConditionalRoleLinks, enableAcceptJsonRequest, enableAutoBuildRoleLinks, enableAutoSave, enableEnforce, enableLog, getAdapter, getAviatorEval, getModel, getNamedRoleManager, getRmMap, getRoleManager, initialize, isAutoNotifyDispatcher, isAutoNotifyWatcher, isFiltered, loadModel, mustUseDispatcher, newModel, newModel, newModel, resetExpressionEvaluator, setAdapter, setAutoNotifyDispatcher, setAutoNotifyWatcher, setAviatorEvaluator, setDispatcher, setEffector, setModel, setNamedDomainLinkConditionFuncParams, setNamedLinkConditionFuncParams, setNamedRoleManager, setRoleManager, setRoleManager, validateEnforce
-
-
-
-
Constructor Detail
-
DistributedEnforcer
public DistributedEnforcer()
DistributedEnforcer is the default constructor.
-
DistributedEnforcer
public DistributedEnforcer(java.lang.String modelPath, java.lang.String policyFile)
DistributedEnforcer 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.
-
DistributedEnforcer
public DistributedEnforcer(java.lang.String modelPath, Adapter adapter)
DistributedEnforcer initializes an enforcer with a database adapter.- Parameters:
modelPath
- the path of the model file.adapter
- the adapter.
-
DistributedEnforcer
public DistributedEnforcer(Model m, Adapter adapter)
DistributedEnforcer initializes an enforcer with a model and a database adapter.- Parameters:
m
- the model.adapter
- the adapter.
-
DistributedEnforcer
public DistributedEnforcer(Model m)
DistributedEnforcer initializes an enforcer with a model.- Parameters:
m
- the model.
-
DistributedEnforcer
public DistributedEnforcer(java.lang.String modelPath)
DistributedEnforcer initializes an enforcer with a model file.- Parameters:
modelPath
- the path of the model file.
-
DistributedEnforcer
public DistributedEnforcer(java.lang.String modelPath, java.lang.String policyFile, boolean enableLog)
DistributedEnforcer initializes an enforcer with a model file, a policy file and an enable log flag.- Parameters:
modelPath
- the path of the model file.policyFile
- the path of the policy file.enableLog
- whether to enable Casbin's log.
-
-
Method Detail
-
addPolicySelf
public java.util.List<java.util.List<java.lang.String>> addPolicySelf(java.util.function.BooleanSupplier shouldPersist, java.lang.String sec, java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
AddPolicySelf provides a method for dispatcher to add authorization rules to the current policy. The function returns the rules affected and error.- Parameters:
shouldPersist
- whether the changes should be persisted.sec
- the section, "p" or "g".ptype
- the policy type, "p", "p2", .. or "g", "g2", ..rules
- the rules.- Returns:
- succeeds or not.
-
removePolicySelf
public java.util.List<java.util.List<java.lang.String>> removePolicySelf(java.util.function.BooleanSupplier shouldPersist, java.lang.String sec, java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
RemovePolicySelf provides a method for dispatcher to remove policies from current policy. The function returns the rules affected and error.- Parameters:
shouldPersist
- whether the changes should be persisted.sec
- the section, "p" or "g".ptype
- the policy type, "p", "p2", .. or "g", "g2", ..rules
- the rules.- Returns:
- succeeds or not.
-
removeFilteredPolicySelf
public java.util.List<java.util.List<java.lang.String>> removeFilteredPolicySelf(java.util.function.BooleanSupplier shouldPersist, java.lang.String sec, java.lang.String ptype, int fieldIndex, java.lang.String... fieldValues)
RemoveFilteredPolicySelf provides a method for dispatcher to remove an authorization rule from the current policy, field filters can be specified. The function returns the rules affected and error.- Parameters:
shouldPersist
- whether the changes should be persisted.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.
-
clearPolicySelf
public void clearPolicySelf(java.util.function.BooleanSupplier shouldPersist)
ClearPolicySelf provides a method for dispatcher to clear all rules from the current policy.- Parameters:
shouldPersist
- whether the changes should be persisted.
-
updatePolicySelf
public boolean updatePolicySelf(java.util.function.BooleanSupplier shouldPersist, java.lang.String sec, java.lang.String ptype, java.util.List<java.lang.String> oldRule, java.util.List<java.lang.String> newRule)
UpdatePolicySelf provides a method for dispatcher to update an authorization rule from the current policy.- Parameters:
shouldPersist
- whether the changes should be persisted.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.
-
-