Class SyncedEnforcer
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
- Direct Known Subclasses:
DistributedEnforcer, SyncedCachedEnforcer
SyncedEnforcer = ManagementEnforcer + RBAC API.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicIntegerprivate static final ReadWriteLockprivate final ObjectFields inherited from class CoreEnforcer
acceptJsonRequest, adapter, autoBuildRoleLinks, autoNotifyDispatcher, autoNotifyWatcher, autoSave, condRmMap, dispatcher, fm, model, modelPath, rmMap, watcher -
Constructor Summary
ConstructorsConstructorDescription; SyncedEnforcer is the default constructor.SyncedEnforcer(String modelPath) SyncedEnforcer initializes an enforcer with a model file.SyncedEnforcer(String modelPath, String policyFile) SyncedEnforcer initializes an enforcer with a model file and a policy file.SyncedEnforcer(String modelPath, String policyFile, boolean enableLog) SyncedEnforcer initializes an enforcer with a model file, a policy file and an enable log flag.SyncedEnforcer(String modelPath, Adapter adapter) SyncedEnforcer initializes an enforcer with a database adapter.SyncedEnforcer initializes an enforcer with a model.SyncedEnforcer(Model m, Adapter adapter) SyncedEnforcer initializes an enforcer with a model and a database adapter. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddGroupingPolicies(String[][] rules) addGroupingPolicies adds role inheritance rules to the current policy.booleanaddGroupingPolicies(List<List<String>> rules) addGroupingPolicies adds role inheritance rules to the current policy.booleanaddGroupingPolicy(String... params) addGroupingPolicy adds a role inheritance rule to the current policy.booleanaddGroupingPolicy(List<String> params) addGroupingPolicy adds a role inheritance rule to the current policy.booleanaddNamedGroupingPolicies(String ptype, String[][] rules) addNamedGroupingPolicies adds named role inheritance rules to the current policy.booleanaddNamedGroupingPolicies(String ptype, List<List<String>> rules) addNamedGroupingPolicies adds named role inheritance rules to the current policy.booleanaddNamedGroupingPolicy(String ptype, String... params) addNamedGroupingPolicy adds a named role inheritance rule to the current policy.booleanaddNamedGroupingPolicy(String ptype, List<String> params) addNamedGroupingPolicy adds a named role inheritance rule to the current policy.booleanaddNamedPolicies(String ptype, List<List<String>> rules) addNamedPolicies adds authorization rules to the current named policy.booleanaddNamedPoliciesEx(String ptype, List<List<String>> rules) addNamedPoliciesEx adds authorization rules to the current named policy.booleanaddNamedPolicy(String ptype, String... params) AddNamedPolicy adds an authorization rule to the current named policy.booleanaddNamedPolicy(String ptype, List<String> params) AddNamedPolicy adds an authorization rule to the current named policy.booleanaddPermissionForUser(String user, String... permission) addPermissionForUser adds a permission for a user or role.booleanaddPermissionForUser(String user, List<String> permission) addPermissionForUser adds a permission for a user or role.booleanaddPolicies(String[][] rules) addPolicies adds authorization rules to the current policy.booleanaddPolicies(List<List<String>> rules) addPolicies adds authorization rules to the current policy.booleanaddPolicy adds an authorization rule to the current policy.booleanaddPolicy adds an authorization rule to the current policy.booleanaddRoleForUser(String user, String role) addRoleForUser adds a role for a user.booleanaddRoleForUserInDomain(String user, String role, String domain) addRoleForUserInDomain adds a role for a user inside a domain.batchEnforce(List<List<String>> rules) batchEnforce enforce in batchesbatchEnforceWithMatcher(String matcher, List<List<String>> rules) batchEnforceWithMatcher enforce with matcher in batchesvoidbuildRoleLinks manually rebuild the role inheritance relations.voidclearPolicy clears all policy.booleandeletePermission(String... permission) deletePermission deletes a permission.booleandeletePermission(List<String> permission) deletePermission deletes a permission.booleandeletePermissionForUser(String user, String... permission) deletePermissionForUser deletes a permission for a user or role.booleandeletePermissionForUser(String user, List<String> permission) deletePermissionForUser deletes a permission for a user or role.booleandeletePermissionsForUser deletes permissions for a user or role.voiddeleteRole(String role) deleteRole deletes a role.booleandeleteRoleForUser(String user, String role) deleteRoleForUser deletes a role for a user.booleandeleteRoleForUserInDomain(String user, String role, String domain) deleteRoleForUserInDomain deletes a role for a user inside a domain.booleandeleteRolesForUser(String user) deleteRolesForUser deletes all roles for a user.booleandeleteUser(String user) deleteUser deletes a user.booleanenforce decides whether a "subject" can access a "object" with the operation "action", input parameters are usually: (sub, obj, act).enforceEx decides whether a "subject" can access "object" with the operation "action", input parameters are usually: (sub, obj, act).enforceExWithMatcher(String matcher, Object... rvals) enforceExWithMatcher use a custom matcher to decide whether a "subject" can access a "object" with the operation "action", input parameters are usually: (matcher, sub, obj, act), use model matcher by default when matcher is "" or null.booleanenforceWithMatcher(String matcher, Object... rvals) enforceWithMatcher use a custom matcher to decide whether a "subject" can access a "object" with the operation "action", input parameters are usually: (matcher, sub, obj, act), use model matcher by default when matcher is "" or null.getAllActions gets the list of actions that show up in the current policy.getAllNamedActions(String ptype) GetAllNamedActions gets the list of actions that show up in the current named policy.getAllNamedObjects(String ptype) getAllNamedObjects gets the list of objects that show up in the current named policy.getAllNamedRoles(String ptype) getAllNamedRoles gets the list of roles that show up in the current named policy.getAllObjects gets the list of objects that show up in the current policy.getAllRoles gets the list of roles that show up in the current policy.getAllSubjects gets the list of subjects that show up in the current policy.getFilteredGroupingPolicy(int fieldIndex, String... fieldValues) getFilteredGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.getFilteredNamedGroupingPolicy(String ptype, int fieldIndex, String... fieldValues) getFilteredNamedGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.getFilteredNamedPolicy(String ptype, int fieldIndex, String... fieldValues) getFilteredNamedPolicy gets all the authorization rules in the named policy, field filters can be specified.getFilteredPolicy(int fieldIndex, String... fieldValues) getFilteredPolicy gets all the authorization rules in the policy, field filters can be specified.getGroupingPolicy gets all the role inheritance rules in the policy.getImplicitPermissionsForUser(String user, String... domain) getImplicitPermissionsForUser gets implicit permissions for a user or role.getImplicitRolesForUser(String name, String... domain) getImplicitRolesForUser gets implicit roles that a user has.getNamedGroupingPolicy(String ptype) getNamedGroupingPolicy gets all the role inheritance rules in the policy.getNamedImplicitPermissionsForUser(String pType, String user, String... domain) GetNamedImplicitPermissionsForUser gets implicit permissions for a user or role by named policy.getNamedPermissionsForUser(String pType, String user, String... domain) GetNamedPermissionsForUser gets permissions for a user or role by named policy.getNamedPolicy(String ptype) getNamedPolicy gets all the authorization rules in the named policy.getPermissionsForUser(String user, String... domain) getPermissionsForUser gets permissions for a user or role.getPermissionsForUserInDomain(String user, String domain) getPermissionsForUserInDomain gets permissions for a user or role inside a domain.getPolicy gets all the authorization rules in the policy.getRolesForUser(String name) getRolesForUser gets the roles that a user has.getRolesForUserInDomain(String name, String domain) getRolesForUserInDomain gets the roles that a user has inside a domain.getUsersForRole(String name) getUsersForRole gets the users that has a role.getUsersForRoleInDomain(String name, String domain) getUsersForRoleInDomain gets the users that a role has inside a domain.booleanhasGroupingPolicy(String... params) hasGroupingPolicy determines whether a role inheritance rule exists.booleanhasGroupingPolicy(List<String> params) hasGroupingPolicy determines whether a role inheritance rule exists.booleanhasNamedGroupingPolicy(String ptype, String... params) hasNamedGroupingPolicy determines whether a named role inheritance rule exists.booleanhasNamedGroupingPolicy(String ptype, List<String> params) hasNamedGroupingPolicy determines whether a named role inheritance rule exists.booleanhasNamedPolicy(String ptype, String... params) hasNamedPolicy determines whether a named authorization rule exists.booleanhasNamedPolicy(String ptype, List<String> params) hasNamedPolicy determines whether a named authorization rule exists.booleanhasPermissionForUser(String user, String... permission) hasPermissionForUser determines whether a user has a permission.booleanhasPermissionForUser(String user, List<String> permission) hasPermissionForUser determines whether a user has a permission.booleanhasPolicy determines whether an authorization rule exists.booleanhasPolicy determines whether an authorization rule exists.booleanhasRoleForUser(String name, String role) hasRoleForUser determines whether a user has a role.booleanvoidloadFilteredPolicy(Object filter) loadFilteredPolicy reloads a filtered policy from file/database.voidloadPolicy reloads the policy from file/database.booleanremoveFilteredGroupingPolicy(int fieldIndex, String... fieldValues) removeFilteredGroupingPolicy removes a role inheritance rule from the current policy, field filters can be specified.booleanremoveFilteredNamedGroupingPolicy(String ptype, int fieldIndex, String... fieldValues) removeFilteredNamedGroupingPolicy removes a role inheritance rule from the current named policy, field filters can be specified.booleanremoveFilteredNamedPolicy(String ptype, int fieldIndex, String... fieldValues) removeFilteredNamedPolicy removes an authorization rule from the current named policy, field filters can be specified.booleanremoveFilteredPolicy(int fieldIndex, String... fieldValues) removeFilteredPolicy removes an authorization rule from the current policy, field filters can be specified.booleanremoveGroupingPolicies(String[][] rules) removeGroupingPolicies removes role inheritance rules from the current policy.booleanremoveGroupingPolicies(List<List<String>> rules) removeGroupingPolicies removes role inheritance rules from the current policy.booleanremoveGroupingPolicy(String... params) removeGroupingPolicy removes a role inheritance rule from the current policy.booleanremoveGroupingPolicy(List<String> params) removeGroupingPolicy removes a role inheritance rule from the current policy.booleanremoveNamedGroupingPolicies(String ptype, String[][] rules) removeNamedGroupingPolicies removes role inheritance rules from the current named policy.booleanremoveNamedGroupingPolicies(String ptype, List<List<String>> rules) removeNamedGroupingPolicies removes role inheritance rules from the current named policy.booleanremoveNamedGroupingPolicy(String ptype, String... params) removeNamedGroupingPolicy removes a role inheritance rule from the current named policy.booleanremoveNamedGroupingPolicy(String ptype, List<String> params) removeNamedGroupingPolicy removes a role inheritance rule from the current named policy.booleanremoveNamedPolicies(String ptype, List<List<String>> rules) removeNamedPolicies removes authorization rules from the current named policy.booleanremoveNamedPolicy(String ptype, String... params) removeNamedPolicy removes an authorization rule from the current named policy.booleanremoveNamedPolicy(String ptype, List<String> params) removeNamedPolicy removes an authorization rule from the current named policy.booleanremovePolicies(String[][] rules) removePolicies removes authorization rules from the current policy.booleanremovePolicies(List<List<String>> rules) removePolicies removes authorization rules from the current policy.booleanremovePolicy(String... params) removePolicy removes an authorization rule from the current policy.booleanremovePolicy(List<String> params) removePolicy removes an authorization rule from the current policy.private voidrunSynchronized(Runnable action, Lock lock) private <T> TrunSynchronized(Supplier<T> action, Lock lock) voidsavePolicy saves the current policy (usually after changed with Casbin API) back to file/database.voidsetWatcher(Watcher watcher) setWatcher sets the current watcher.voidstartAutoLoadPolicy(long d) voidbooleanupdateGroupingPolicy(List<String> params1, List<String> params2) UpdateGroupingPolicy updates an authorization rule to the current named policy.booleanupdateNamedGroupingPolicy updates an authorization rule to the current named policy.booleanupdateNamedPolicy updates an authorization rule to the current named policy.booleanupdatePolicy(List<String> params1, List<String> params2) updatePolicy update an authorization rule to the current policy.Methods inherited from class Enforcer
getImplicitPermissionsForUserInDomain, getImplicitUsersForRole, updatePermissionForUserMethods inherited from class ManagementEnforcer
addFunction, getAllNamedSubjects, getPermittedActionsMethods inherited from class InternalEnforcer
addPolicies, addPolicy, buildIncrementalRoleLinks, getDomainIndex, removeFilteredPolicy, removePolicies, removePolicy, updatePolicyMethods inherited from class 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
-
Field Details
-
READ_WRITE_LOCK
-
stopAutoLoad
-
autoLoadRunning
-
-
Constructor Details
-
SyncedEnforcer
public SyncedEnforcer(); SyncedEnforcer is the default constructor. -
SyncedEnforcer
-
SyncedEnforcer
-
SyncedEnforcer
-
SyncedEnforcer
SyncedEnforcer initializes an enforcer with a model.- Parameters:
m- the model.
-
SyncedEnforcer
SyncedEnforcer initializes an enforcer with a model file.- Parameters:
modelPath- the path of the model file.
-
SyncedEnforcer
SyncedEnforcer 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 Details
-
isAutoLoadingRunning
public boolean isAutoLoadingRunning() -
startAutoLoadPolicy
public void startAutoLoadPolicy(long d) -
stopAutoLoadPolicy
public void stopAutoLoadPolicy() -
setWatcher
setWatcher sets the current watcher.- Overrides:
setWatcherin classCoreEnforcer- Parameters:
watcher- the watcher.
-
clearPolicy
public void clearPolicy()clearPolicy clears all policy.- Overrides:
clearPolicyin classCoreEnforcer
-
loadPolicy
public void loadPolicy()loadPolicy reloads the policy from file/database.- Overrides:
loadPolicyin classCoreEnforcer
-
loadFilteredPolicy
loadFilteredPolicy reloads a filtered policy from file/database.- Overrides:
loadFilteredPolicyin classCoreEnforcer- Parameters:
filter- the filter used to specify which type of policy should be loaded.
-
savePolicy
public void savePolicy()savePolicy saves the current policy (usually after changed with Casbin API) back to file/database.- Overrides:
savePolicyin classCoreEnforcer
-
buildRoleLinks
public void buildRoleLinks()buildRoleLinks manually rebuild the role inheritance relations.- Overrides:
buildRoleLinksin classCoreEnforcer
-
enforce
enforce decides whether a "subject" can access a "object" with the operation "action", input parameters are usually: (sub, obj, act).- Overrides:
enforcein classCoreEnforcer- Parameters:
rvals- the request needs to be mediated, usually an array of strings, can be class instances if ABAC is used.- Returns:
- whether to allow the request.
-
enforceWithMatcher
enforceWithMatcher use a custom matcher to decide whether a "subject" can access a "object" with the operation "action", input parameters are usually: (matcher, sub, obj, act), use model matcher by default when matcher is "" or null.- Overrides:
enforceWithMatcherin classCoreEnforcer- Parameters:
matcher- the custom matcher.rvals- the request needs to be mediated, usually an array of strings, can be class instances if ABAC is used.- Returns:
- whether to allow the request.
-
enforceEx
enforceEx decides whether a "subject" can access "object" with the operation "action", input parameters are usually: (sub, obj, act). the list explain, store matching rule.- Overrides:
enforceExin classCoreEnforcer- Parameters:
rvals- the request needs to be mediated, usually an array of strings, can be class instances if ABAC is used.- Returns:
- whether to allow the request.
-
enforceExWithMatcher
enforceExWithMatcher use a custom matcher to decide whether a "subject" can access a "object" with the operation "action", input parameters are usually: (matcher, sub, obj, act), use model matcher by default when matcher is "" or null. the list explain, store matching rule.- Overrides:
enforceExWithMatcherin classCoreEnforcer- Parameters:
matcher- the custom matcher.rvals- the request needs to be mediated, usually an array of strings, can be class instances if ABAC is used.- Returns:
- whether to allow the request.
-
batchEnforce
-
batchEnforceWithMatcher
-
getAllSubjects
getAllSubjects gets the list of subjects that show up in the current policy.- Overrides:
getAllSubjectsin classManagementEnforcer- Returns:
- all the subjects in "p" policy rules. It actually collects the 0-index elements of "p" policy rules. So make sure your subject is the 0-index element, like (sub, obj, act). Duplicates are removed.
-
getAllObjects
getAllObjects gets the list of objects that show up in the current policy.- Overrides:
getAllObjectsin classManagementEnforcer- Returns:
- all the objects in "p" policy rules. It actually collects the 1-index elements of "p" policy rules. So make sure your object is the 1-index element, like (sub, obj, act). Duplicates are removed.
-
getAllNamedObjects
getAllNamedObjects gets the list of objects that show up in the current named policy.- Overrides:
getAllNamedObjectsin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..- Returns:
- all the objects in policy rules of the ptype type. It actually collects the 1-index elements of the policy rules. So make sure your object is the 1-index element, like (sub, obj, act). Duplicates are removed.
-
getAllActions
getAllActions gets the list of actions that show up in the current policy.- Overrides:
getAllActionsin classManagementEnforcer- Returns:
- all the actions in "p" policy rules. It actually collects the 2-index elements of "p" policy rules. So make sure your action is the 2-index element, like (sub, obj, act). Duplicates are removed.
-
getAllNamedActions
GetAllNamedActions gets the list of actions that show up in the current named policy.- Overrides:
getAllNamedActionsin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..- Returns:
- all the actions in policy rules of the ptype type. It actually collects the 2-index elements of the policy rules. So make sure your action is the 2-index element, like (sub, obj, act). Duplicates are removed.
-
getAllRoles
getAllRoles gets the list of roles that show up in the current policy.- Overrides:
getAllRolesin classManagementEnforcer- Returns:
- all the roles in "g" policy rules. It actually collects the 1-index elements of "g" policy rules. So make sure your role is the 1-index element, like (sub, role). Duplicates are removed.
-
getAllNamedRoles
getAllNamedRoles gets the list of roles that show up in the current named policy.- Overrides:
getAllNamedRolesin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..- Returns:
- all the subjects in policy rules of the ptype type. It actually collects the 0-index elements of the policy rules. So make sure your subject is the 0-index element, like (sub, obj, act). Duplicates are removed.
-
getPolicy
getPolicy gets all the authorization rules in the policy.- Overrides:
getPolicyin classManagementEnforcer- Returns:
- all the "p" policy rules.
-
getFilteredPolicy
getFilteredPolicy gets all the authorization rules in the policy, field filters can be specified.- Overrides:
getFilteredPolicyin classManagementEnforcer- Parameters:
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:
- the filtered "p" policy rules.
-
getNamedPolicy
getNamedPolicy gets all the authorization rules in the named policy.- Overrides:
getNamedPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..- Returns:
- the "p" policy rules of the specified ptype.
-
getFilteredNamedPolicy
public List<List<String>> getFilteredNamedPolicy(String ptype, int fieldIndex, String... fieldValues) getFilteredNamedPolicy gets all the authorization rules in the named policy, field filters can be specified.- Overrides:
getFilteredNamedPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..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:
- the filtered "p" policy rules of the specified ptype.
-
getGroupingPolicy
getGroupingPolicy gets all the role inheritance rules in the policy.- Overrides:
getGroupingPolicyin classManagementEnforcer- Returns:
- all the "g" policy rules.
-
getRolesForUser
getRolesForUser gets the roles that a user has.- Overrides:
getRolesForUserin classEnforcer- Parameters:
name- the user.- Returns:
- the roles that the user has.
-
getFilteredGroupingPolicy
getFilteredGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.- Overrides:
getFilteredGroupingPolicyin classManagementEnforcer- Parameters:
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:
- the filtered "g" policy rules.
-
getNamedGroupingPolicy
getNamedGroupingPolicy gets all the role inheritance rules in the policy.- Overrides:
getNamedGroupingPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..- Returns:
- the "g" policy rules of the specified ptype.
-
getFilteredNamedGroupingPolicy
public List<List<String>> getFilteredNamedGroupingPolicy(String ptype, int fieldIndex, String... fieldValues) getFilteredNamedGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.- Overrides:
getFilteredNamedGroupingPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..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:
- the filtered "g" policy rules of the specified ptype.
-
hasPolicy
hasPolicy determines whether an authorization rule exists.- Overrides:
hasPolicyin classManagementEnforcer- Parameters:
params- the "p" policy rule, ptype "p" is implicitly used.- Returns:
- whether the rule exists.
-
hasPolicy
hasPolicy determines whether an authorization rule exists.- Overrides:
hasPolicyin classManagementEnforcer- Parameters:
params- the "p" policy rule, ptype "p" is implicitly used.- Returns:
- whether the rule exists.
-
hasNamedPolicy
hasNamedPolicy determines whether a named authorization rule exists.- Overrides:
hasNamedPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..params- the "p" policy rule.- Returns:
- whether the rule exists.
-
hasNamedPolicy
hasNamedPolicy determines whether a named authorization rule exists.- Overrides:
hasNamedPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..params- the "p" policy rule.- Returns:
- whether the rule exists.
-
addPolicy
addPolicy adds an authorization rule to the current policy. If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.- Overrides:
addPolicyin classManagementEnforcer- Parameters:
params- the "p" policy rule, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
addPolicies
addPolicies adds authorization rules to the current policy. If the rule already exists, the function returns false for the corresponding rule and the rule will not be added. Otherwise the function returns true for the corresponding rule by adding the new rule.- Overrides:
addPoliciesin classManagementEnforcer- Parameters:
rules- the "p" policy rules, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
updatePolicy
updatePolicy update an authorization rule to the current policy.- Overrides:
updatePolicyin classManagementEnforcer- Parameters:
params1- the old rule.params2- the new rule.- Returns:
- succeeds or not.
-
addPolicy
addPolicy adds an authorization rule to the current policy. If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.- Overrides:
addPolicyin classManagementEnforcer- Parameters:
params- the "p" policy rule, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
addPolicies
addPolicies adds authorization rules to the current policy. If the rule already exists, the function returns false for the corresponding rule and the rule will not be added. Otherwise the function returns true for the corresponding rule by adding the new rule.- Overrides:
addPoliciesin classManagementEnforcer- Parameters:
rules- the "p" policy rules, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
addNamedPolicy
AddNamedPolicy adds an authorization rule to the current named policy. If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.- Overrides:
addNamedPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..params- the "p" policy rule.- Returns:
- succeeds or not.
-
addNamedPolicies
addNamedPolicies adds authorization rules to the current named policy. If the rule already exists, the function returns false for the corresponding rule and the rule will not be added. Otherwise the function returns true for the corresponding by adding the new rule.- Overrides:
addNamedPoliciesin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..rules- the "p" policy rules.- Returns:
- succeeds or not.
-
addNamedPoliciesEx
addNamedPoliciesEx adds authorization rules to the current named policy. If the rule already exists, the rule will not be added. But unlike AddNamedPolicies, other non-existent rules are added instead of returning false directly- Overrides:
addNamedPoliciesExin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..rules- the "p" policy rules.- Returns:
- succeeds or not.
-
updateNamedPolicy
updateNamedPolicy updates an authorization rule to the current named policy.- Overrides:
updateNamedPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..params1- the old rule.params2- the new rule.- Returns:
- succeeds or not.
-
updateGroupingPolicy
UpdateGroupingPolicy updates an authorization rule to the current named policy.- Overrides:
updateGroupingPolicyin classManagementEnforcer- Parameters:
params1- the old rule.params2- the new rule.- Returns:
- succeeds or not.
-
updateNamedGroupingPolicy
updateNamedGroupingPolicy updates an authorization rule to the current named policy.- Overrides:
updateNamedGroupingPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..params1- the old rule.params2- the new rule.- Returns:
- succeeds or not.
-
addNamedPolicy
AddNamedPolicy adds an authorization rule to the current named policy. If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.- Overrides:
addNamedPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..params- the "p" policy rule.- Returns:
- succeeds or not.
-
removePolicy
removePolicy removes an authorization rule from the current policy.- Overrides:
removePolicyin classManagementEnforcer- Parameters:
params- the "p" policy rule, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
removePolicy
removePolicy removes an authorization rule from the current policy.- Overrides:
removePolicyin classManagementEnforcer- Parameters:
params- the "p" policy rule, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
removePolicies
removePolicies removes authorization rules from the current policy.- Overrides:
removePoliciesin classManagementEnforcer- Parameters:
rules- the "p" policy rules, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
removePolicies
removePolicies removes authorization rules from the current policy.- Overrides:
removePoliciesin classManagementEnforcer- Parameters:
rules- the "p" policy rules, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
removeFilteredPolicy
removeFilteredPolicy removes an authorization rule from the current policy, field filters can be specified.- Overrides:
removeFilteredPolicyin classManagementEnforcer- Parameters:
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.
-
removeNamedPolicy
removeNamedPolicy removes an authorization rule from the current named policy.- Overrides:
removeNamedPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..params- the "p" policy rule.- Returns:
- succeeds or not.
-
removeNamedPolicy
removeNamedPolicy removes an authorization rule from the current named policy.- Overrides:
removeNamedPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..params- the "p" policy rule.- Returns:
- succeeds or not.
-
removeNamedPolicies
removeNamedPolicies removes authorization rules from the current named policy.- Overrides:
removeNamedPoliciesin classManagementEnforcer- Parameters:
ptype- ptype the policy type, can be "p", "p2", "p3", ..rules- the "p" policy rules.- Returns:
- succeeds or not.
-
removeFilteredNamedPolicy
removeFilteredNamedPolicy removes an authorization rule from the current named policy, field filters can be specified.- Overrides:
removeFilteredNamedPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "p", "p2", "p3", ..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.
-
hasGroupingPolicy
hasGroupingPolicy determines whether a role inheritance rule exists.- Overrides:
hasGroupingPolicyin classManagementEnforcer- Parameters:
params- the "g" policy rule, ptype "g" is implicitly used.- Returns:
- whether the rule exists.
-
hasGroupingPolicy
hasGroupingPolicy determines whether a role inheritance rule exists.- Overrides:
hasGroupingPolicyin classManagementEnforcer- Parameters:
params- the "g" policy rule, ptype "g" is implicitly used.- Returns:
- whether the rule exists.
-
hasNamedGroupingPolicy
hasNamedGroupingPolicy determines whether a named role inheritance rule exists.- Overrides:
hasNamedGroupingPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..params- the "g" policy rule.- Returns:
- whether the rule exists.
-
hasNamedGroupingPolicy
hasNamedGroupingPolicy determines whether a named role inheritance rule exists.- Overrides:
hasNamedGroupingPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..params- the "g" policy rule.- Returns:
- whether the rule exists.
-
addGroupingPolicy
addGroupingPolicy adds a role inheritance rule to the current policy. If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.- Overrides:
addGroupingPolicyin classManagementEnforcer- Parameters:
params- the "g" policy rule, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
addGroupingPolicy
addGroupingPolicy adds a role inheritance rule to the current policy. If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.- Overrides:
addGroupingPolicyin classManagementEnforcer- Parameters:
params- the "g" policy rule, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
addGroupingPolicies
addGroupingPolicies adds role inheritance rules to the current policy. If the rule already exists, the function returns false for the corresponding policy rule and the rule will not be added. Otherwise the function returns true for the corresponding policy rule by adding the new rule.- Overrides:
addGroupingPoliciesin classManagementEnforcer- Parameters:
rules- the "g" policy rules, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
addGroupingPolicies
addGroupingPolicies adds role inheritance rules to the current policy. If the rule already exists, the function returns false for the corresponding policy rule and the rule will not be added. Otherwise the function returns true for the corresponding policy rule by adding the new rule.- Overrides:
addGroupingPoliciesin classManagementEnforcer- Parameters:
rules- the "g" policy rules, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
addNamedGroupingPolicy
addNamedGroupingPolicy adds a named role inheritance rule to the current policy. If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.- Overrides:
addNamedGroupingPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..params- the "g" policy rule.- Returns:
- succeeds or not.
-
addNamedGroupingPolicy
addNamedGroupingPolicy adds a named role inheritance rule to the current policy. If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.- Overrides:
addNamedGroupingPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..params- the "g" policy rule.- Returns:
- succeeds or not.
-
addNamedGroupingPolicies
addNamedGroupingPolicies adds named role inheritance rules to the current policy. If the rule already exists, the function returns false for the corresponding policy rule and the rule will not be added. Otherwise the function returns true for the corresponding policy rule by adding the new rule.- Overrides:
addNamedGroupingPoliciesin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..rules- the "g" policy rules.- Returns:
- succeeds or not.
-
addNamedGroupingPolicies
addNamedGroupingPolicies adds named role inheritance rules to the current policy. If the rule already exists, the function returns false for the corresponding policy rule and the rule will not be added. Otherwise the function returns true for the corresponding policy rule by adding the new rule.- Overrides:
addNamedGroupingPoliciesin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..rules- the "g" policy rules.- Returns:
- succeeds or not.
-
removeGroupingPolicy
removeGroupingPolicy removes a role inheritance rule from the current policy.- Overrides:
removeGroupingPolicyin classManagementEnforcer- Parameters:
params- the "g" policy rule, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
removeGroupingPolicy
removeGroupingPolicy removes a role inheritance rule from the current policy.- Overrides:
removeGroupingPolicyin classManagementEnforcer- Parameters:
params- the "g" policy rule, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
removeGroupingPolicies
removeGroupingPolicies removes role inheritance rules from the current policy.- Overrides:
removeGroupingPoliciesin classManagementEnforcer- Parameters:
rules- the "g" policy rules, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
removeGroupingPolicies
removeGroupingPolicies removes role inheritance rules from the current policy.- Overrides:
removeGroupingPoliciesin classManagementEnforcer- Parameters:
rules- the "g" policy rules, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
removeFilteredGroupingPolicy
removeFilteredGroupingPolicy removes a role inheritance rule from the current policy, field filters can be specified.- Overrides:
removeFilteredGroupingPolicyin classManagementEnforcer- Parameters:
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.
-
removeNamedGroupingPolicy
removeNamedGroupingPolicy removes a role inheritance rule from the current named policy.- Overrides:
removeNamedGroupingPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..params- the "g" policy rule.- Returns:
- succeeds or not.
-
removeNamedGroupingPolicy
removeNamedGroupingPolicy removes a role inheritance rule from the current named policy.- Overrides:
removeNamedGroupingPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..params- the "g" policy rule.- Returns:
- succeeds or not.
-
removeNamedGroupingPolicies
removeNamedGroupingPolicies removes role inheritance rules from the current named policy.- Overrides:
removeNamedGroupingPoliciesin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..rules- the "g" policy rules.- Returns:
- succeeds or not.
-
removeNamedGroupingPolicies
removeNamedGroupingPolicies removes role inheritance rules from the current named policy.- Overrides:
removeNamedGroupingPoliciesin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..rules- the "g" policy rules.- Returns:
- succeeds or not.
-
removeFilteredNamedGroupingPolicy
public boolean removeFilteredNamedGroupingPolicy(String ptype, int fieldIndex, String... fieldValues) removeFilteredNamedGroupingPolicy removes a role inheritance rule from the current named policy, field filters can be specified.- Overrides:
removeFilteredNamedGroupingPolicyin classManagementEnforcer- Parameters:
ptype- the policy type, can be "g", "g2", "g3", ..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.
-
getUsersForRole
getUsersForRole gets the users that has a role.- Overrides:
getUsersForRolein classEnforcer- Parameters:
name- the role.- Returns:
- the users that has the role.
-
hasRoleForUser
hasRoleForUser determines whether a user has a role.- Overrides:
hasRoleForUserin classEnforcer- Parameters:
name- the user.role- the role.- Returns:
- whether the user has the role.
-
addRoleForUser
addRoleForUser adds a role for a user. Returns false if the user already has the role (aka not affected).- Overrides:
addRoleForUserin classEnforcer- Parameters:
user- the user.role- the role.- Returns:
- succeeds or not.
-
deleteRoleForUser
deleteRoleForUser deletes a role for a user. Returns false if the user does not have the role (aka not affected).- Overrides:
deleteRoleForUserin classEnforcer- Parameters:
user- the user.role- the role.- Returns:
- succeeds or not.
-
deleteRolesForUser
deleteRolesForUser deletes all roles for a user. Returns false if the user does not have any roles (aka not affected).- Overrides:
deleteRolesForUserin classEnforcer- Parameters:
user- the user.- Returns:
- succeeds or not.
-
deleteUser
deleteUser deletes a user. Returns false if the user does not exist (aka not affected).- Overrides:
deleteUserin classEnforcer- Parameters:
user- the user.- Returns:
- succeeds or not.
-
deleteRole
deleteRole deletes a role.- Overrides:
deleteRolein classEnforcer- Parameters:
role- the role.
-
deletePermission
deletePermission deletes a permission. Returns false if the permission does not exist (aka not affected).- Overrides:
deletePermissionin classEnforcer- Parameters:
permission- the permission, usually be (obj, act). It is actually the rule without the subject.- Returns:
- succeeds or not.
-
deletePermission
deletePermission deletes a permission. Returns false if the permission does not exist (aka not affected).- Overrides:
deletePermissionin classEnforcer- Parameters:
permission- the permission, usually be (obj, act). It is actually the rule without the subject.- Returns:
- succeeds or not.
-
addPermissionForUser
addPermissionForUser adds a permission for a user or role. Returns false if the user or role already has the permission (aka not affected).- Overrides:
addPermissionForUserin classEnforcer- Parameters:
user- the user.permission- the permission, usually be (obj, act). It is actually the rule without the subject.- Returns:
- succeeds or not.
-
addPermissionForUser
addPermissionForUser adds a permission for a user or role. Returns false if the user or role already has the permission (aka not affected).- Overrides:
addPermissionForUserin classEnforcer- Parameters:
user- the user.permission- the permission, usually be (obj, act). It is actually the rule without the subject.- Returns:
- succeeds or not.
-
deletePermissionForUser
deletePermissionForUser deletes a permission for a user or role. Returns false if the user or role does not have the permission (aka not affected).- Overrides:
deletePermissionForUserin classEnforcer- Parameters:
user- the user.permission- the permission, usually be (obj, act). It is actually the rule without the subject.- Returns:
- succeeds or not.
-
deletePermissionForUser
deletePermissionForUser deletes a permission for a user or role. Returns false if the user or role does not have the permission (aka not affected).- Overrides:
deletePermissionForUserin classEnforcer- Parameters:
user- the user.permission- the permission, usually be (obj, act). It is actually the rule without the subject.- Returns:
- succeeds or not.
-
deletePermissionsForUser
deletePermissionsForUser deletes permissions for a user or role. Returns false if the user or role does not have any permissions (aka not affected).- Overrides:
deletePermissionsForUserin classEnforcer- Parameters:
user- the user.- Returns:
- succeeds or not.
-
getPermissionsForUser
getPermissionsForUser gets permissions for a user or role.- Overrides:
getPermissionsForUserin classEnforcer- Parameters:
user- the user.domain- the user's domain.- Returns:
- the permissions, a permission is usually like (obj, act). It is actually the rule without the subject.
-
getNamedPermissionsForUser
GetNamedPermissionsForUser gets permissions for a user or role by named policy.- Overrides:
getNamedPermissionsForUserin classEnforcer- Parameters:
pType- the name policy.user- the user.domain- domain.- Returns:
- the permissions.
-
hasPermissionForUser
hasPermissionForUser determines whether a user has a permission.- Overrides:
hasPermissionForUserin classEnforcer- Parameters:
user- the user.permission- the permission, usually be (obj, act). It is actually the rule without the subject.- Returns:
- whether the user has the permission.
-
hasPermissionForUser
hasPermissionForUser determines whether a user has a permission.- Overrides:
hasPermissionForUserin classEnforcer- Parameters:
user- the user.permission- the permission, usually be (obj, act). It is actually the rule without the subject.- Returns:
- whether the user has the permission.
-
getUsersForRoleInDomain
-
getRolesForUserInDomain
-
getPermissionsForUserInDomain
getPermissionsForUserInDomain gets permissions for a user or role inside a domain.- Overrides:
getPermissionsForUserInDomainin classEnforcer- Parameters:
user- the user.domain- the domain.- Returns:
- the permissions, a permission is usually like (obj, act). It is actually the rule without the subject.
-
addRoleForUserInDomain
addRoleForUserInDomain adds a role for a user inside a domain. Returns false if the user already has the role (aka not affected).- Overrides:
addRoleForUserInDomainin classEnforcer- Parameters:
user- the user.role- the role.domain- the domain.- Returns:
- succeeds or not.
-
deleteRoleForUserInDomain
deleteRoleForUserInDomain deletes a role for a user inside a domain. Returns false if the user does not have the role (aka not affected).- Overrides:
deleteRoleForUserInDomainin classEnforcer- Parameters:
user- the user.role- the role.domain- the domain.- Returns:
- succeeds or not.
-
getImplicitRolesForUser
getImplicitRolesForUser gets implicit roles that a user has. Compared to getRolesForUser(), this function retrieves indirect roles besides direct roles. For example: g, alice, role:admin g, role:admin, role:usergetRolesForUser("alice") can only get: ["role:admin"]. But getImplicitRolesForUser("alice") will get: ["role:admin", "role:user"].
- Overrides:
getImplicitRolesForUserin classEnforcer- Parameters:
name- the userdomain- the domain- Returns:
- implicit roles that a user has.
-
getImplicitPermissionsForUser
getImplicitPermissionsForUser gets implicit permissions for a user or role. Compared to getPermissionsForUser(), this function retrieves permissions for inherited roles. For example: p, admin, data1, read p, alice, data2, read g, alice, admingetPermissionsForUser("alice") can only get: [["alice", "data2", "read"]]. But getImplicitPermissionsForUser("alice") will get: [["admin", "data1", "read"], ["alice", "data2", "read"]].
- Overrides:
getImplicitPermissionsForUserin classEnforcer- Parameters:
user- the user.domain- the user's domain.- Returns:
- implicit permissions for a user or role.
-
getNamedImplicitPermissionsForUser
public List<List<String>> getNamedImplicitPermissionsForUser(String pType, String user, String... domain) GetNamedImplicitPermissionsForUser gets implicit permissions for a user or role by named policy. Compared to GetNamedPermissionsForUser(), this function retrieves permissions for inherited roles. For example: p, admin, data1, read p2, admin, create g, alice, adminGetImplicitPermissionsForUser("alice") can only get: [["admin", "data1", "read"]], whose policy is default policy "p" But you can specify the named policy "p2" to get: [["admin", "create"]] by GetNamedImplicitPermissionsForUser("p2","alice")
- Overrides:
getNamedImplicitPermissionsForUserin classEnforcer- Parameters:
pType- the name policy.user- the user.domain- the user's domain.- Returns:
- implicit permissions for a user or role by named policy.
-
runSynchronized
-
runSynchronized
-