Package org.casbin.jcasbin.main
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
public class SyncedEnforcer extends Enforcer
SyncedEnforcer = ManagementEnforcer + RBAC API.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicInteger
autoLoadRunning
private static java.util.concurrent.locks.ReadWriteLock
READ_WRITE_LOCK
private java.lang.Object
stopAutoLoad
-
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 SyncedEnforcer()
; SyncedEnforcer is the default constructor.SyncedEnforcer(java.lang.String modelPath)
SyncedEnforcer initializes an enforcer with a model file.SyncedEnforcer(java.lang.String modelPath, java.lang.String policyFile)
SyncedEnforcer initializes an enforcer with a model file and a policy file.SyncedEnforcer(java.lang.String modelPath, java.lang.String policyFile, boolean enableLog)
SyncedEnforcer initializes an enforcer with a model file, a policy file and an enable log flag.SyncedEnforcer(java.lang.String modelPath, Adapter adapter)
SyncedEnforcer initializes an enforcer with a database adapter.SyncedEnforcer(Model m)
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addGroupingPolicies(java.lang.String[][] rules)
addGroupingPolicies adds role inheritance rules to the current policy.boolean
addGroupingPolicies(java.util.List<java.util.List<java.lang.String>> rules)
addGroupingPolicies adds role inheritance rules to the current policy.boolean
addGroupingPolicy(java.lang.String... params)
addGroupingPolicy adds a role inheritance rule to the current policy.boolean
addGroupingPolicy(java.util.List<java.lang.String> params)
addGroupingPolicy adds a role inheritance rule to the current policy.boolean
addNamedGroupingPolicies(java.lang.String ptype, java.lang.String[][] rules)
addNamedGroupingPolicies adds named role inheritance rules to the current policy.boolean
addNamedGroupingPolicies(java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
addNamedGroupingPolicies adds named role inheritance rules to the current policy.boolean
addNamedGroupingPolicy(java.lang.String ptype, java.lang.String... params)
addNamedGroupingPolicy adds a named role inheritance rule to the current policy.boolean
addNamedGroupingPolicy(java.lang.String ptype, java.util.List<java.lang.String> params)
addNamedGroupingPolicy adds a named role inheritance rule to the current policy.boolean
addNamedPolicies(java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
addNamedPolicies adds authorization rules to the current named policy.boolean
addNamedPoliciesEx(java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
addNamedPoliciesEx adds authorization rules to the current named policy.boolean
addNamedPolicy(java.lang.String ptype, java.lang.String... params)
AddNamedPolicy adds an authorization rule to the current named policy.boolean
addNamedPolicy(java.lang.String ptype, java.util.List<java.lang.String> params)
AddNamedPolicy adds an authorization rule to the current named policy.boolean
addPermissionForUser(java.lang.String user, java.lang.String... permission)
addPermissionForUser adds a permission for a user or role.boolean
addPermissionForUser(java.lang.String user, java.util.List<java.lang.String> permission)
addPermissionForUser adds a permission for a user or role.boolean
addPolicies(java.lang.String[][] rules)
addPolicies adds authorization rules to the current policy.boolean
addPolicies(java.util.List<java.util.List<java.lang.String>> rules)
addPolicies adds authorization rules to the current policy.boolean
addPolicy(java.lang.String... params)
addPolicy adds an authorization rule to the current policy.boolean
addPolicy(java.util.List<java.lang.String> params)
addPolicy adds an authorization rule to the current policy.boolean
addRoleForUser(java.lang.String user, java.lang.String role)
addRoleForUser adds a role for a user.boolean
addRoleForUserInDomain(java.lang.String user, java.lang.String role, java.lang.String domain)
addRoleForUserInDomain adds a role for a user inside a domain.java.util.List<java.lang.Boolean>
batchEnforce(java.util.List<java.util.List<java.lang.String>> rules)
batchEnforce enforce in batchesjava.util.List<java.lang.Boolean>
batchEnforceWithMatcher(java.lang.String matcher, java.util.List<java.util.List<java.lang.String>> rules)
batchEnforceWithMatcher enforce with matcher in batchesvoid
buildRoleLinks()
buildRoleLinks manually rebuild the role inheritance relations.void
clearPolicy()
clearPolicy clears all policy.boolean
deletePermission(java.lang.String... permission)
deletePermission deletes a permission.boolean
deletePermission(java.util.List<java.lang.String> permission)
deletePermission deletes a permission.boolean
deletePermissionForUser(java.lang.String user, java.lang.String... permission)
deletePermissionForUser deletes a permission for a user or role.boolean
deletePermissionForUser(java.lang.String user, java.util.List<java.lang.String> permission)
deletePermissionForUser deletes a permission for a user or role.boolean
deletePermissionsForUser(java.lang.String user)
deletePermissionsForUser deletes permissions for a user or role.void
deleteRole(java.lang.String role)
deleteRole deletes a role.boolean
deleteRoleForUser(java.lang.String user, java.lang.String role)
deleteRoleForUser deletes a role for a user.boolean
deleteRoleForUserInDomain(java.lang.String user, java.lang.String role, java.lang.String domain)
deleteRoleForUserInDomain deletes a role for a user inside a domain.boolean
deleteRolesForUser(java.lang.String user)
deleteRolesForUser deletes all roles for a user.boolean
deleteUser(java.lang.String user)
deleteUser deletes a user.boolean
enforce(java.lang.Object... rvals)
enforce decides whether a "subject" can access a "object" with the operation "action", input parameters are usually: (sub, obj, act).EnforceResult
enforceEx(java.lang.Object... rvals)
enforceEx decides whether a "subject" can access "object" with the operation "action", input parameters are usually: (sub, obj, act).EnforceResult
enforceExWithMatcher(java.lang.String matcher, java.lang.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.boolean
enforceWithMatcher(java.lang.String matcher, java.lang.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.java.util.List<java.lang.String>
getAllActions()
getAllActions gets the list of actions that show up in the current policy.java.util.List<java.lang.String>
getAllNamedActions(java.lang.String ptype)
GetAllNamedActions gets the list of actions that show up in the current named policy.java.util.List<java.lang.String>
getAllNamedObjects(java.lang.String ptype)
getAllNamedObjects gets the list of objects that show up in the current named policy.java.util.List<java.lang.String>
getAllNamedRoles(java.lang.String ptype)
getAllNamedRoles gets the list of roles that show up in the current named policy.java.util.List<java.lang.String>
getAllObjects()
getAllObjects gets the list of objects that show up in the current policy.java.util.List<java.lang.String>
getAllRoles()
getAllRoles gets the list of roles that show up in the current policy.java.util.List<java.lang.String>
getAllSubjects()
getAllSubjects gets the list of subjects that show up in the current policy.java.util.List<java.util.List<java.lang.String>>
getFilteredGroupingPolicy(int fieldIndex, java.lang.String... fieldValues)
getFilteredGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.java.util.List<java.util.List<java.lang.String>>
getFilteredNamedGroupingPolicy(java.lang.String ptype, int fieldIndex, java.lang.String... fieldValues)
getFilteredNamedGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.java.util.List<java.util.List<java.lang.String>>
getFilteredNamedPolicy(java.lang.String ptype, int fieldIndex, java.lang.String... fieldValues)
getFilteredNamedPolicy gets all the authorization rules in the named policy, field filters can be specified.java.util.List<java.util.List<java.lang.String>>
getFilteredPolicy(int fieldIndex, java.lang.String... fieldValues)
getFilteredPolicy gets all the authorization rules in the policy, field filters can be specified.java.util.List<java.util.List<java.lang.String>>
getGroupingPolicy()
getGroupingPolicy gets all the role inheritance rules in the policy.java.util.List<java.util.List<java.lang.String>>
getImplicitPermissionsForUser(java.lang.String user, java.lang.String... domain)
getImplicitPermissionsForUser gets implicit permissions for a user or role.java.util.List<java.lang.String>
getImplicitRolesForUser(java.lang.String name, java.lang.String... domain)
getImplicitRolesForUser gets implicit roles that a user has.java.util.List<java.util.List<java.lang.String>>
getNamedGroupingPolicy(java.lang.String ptype)
getNamedGroupingPolicy gets all the role inheritance rules in the policy.java.util.List<java.util.List<java.lang.String>>
getNamedImplicitPermissionsForUser(java.lang.String pType, java.lang.String user, java.lang.String... domain)
GetNamedImplicitPermissionsForUser gets implicit permissions for a user or role by named policy.java.util.List<java.util.List<java.lang.String>>
getNamedPermissionsForUser(java.lang.String pType, java.lang.String user, java.lang.String... domain)
GetNamedPermissionsForUser gets permissions for a user or role by named policy.java.util.List<java.util.List<java.lang.String>>
getNamedPolicy(java.lang.String ptype)
getNamedPolicy gets all the authorization rules in the named policy.java.util.List<java.util.List<java.lang.String>>
getPermissionsForUser(java.lang.String user, java.lang.String... domain)
getPermissionsForUser gets permissions for a user or role.java.util.List<java.util.List<java.lang.String>>
getPermissionsForUserInDomain(java.lang.String user, java.lang.String domain)
getPermissionsForUserInDomain gets permissions for a user or role inside a domain.java.util.List<java.util.List<java.lang.String>>
getPolicy()
getPolicy gets all the authorization rules in the policy.java.util.List<java.lang.String>
getRolesForUser(java.lang.String name)
getRolesForUser gets the roles that a user has.java.util.List<java.lang.String>
getRolesForUserInDomain(java.lang.String name, java.lang.String domain)
getRolesForUserInDomain gets the roles that a user has inside a domain.java.util.List<java.lang.String>
getUsersForRole(java.lang.String name)
getUsersForRole gets the users that has a role.java.util.List<java.lang.String>
getUsersForRoleInDomain(java.lang.String name, java.lang.String domain)
getUsersForRoleInDomain gets the users that a role has inside a domain.boolean
hasGroupingPolicy(java.lang.String... params)
hasGroupingPolicy determines whether a role inheritance rule exists.boolean
hasGroupingPolicy(java.util.List<java.lang.String> params)
hasGroupingPolicy determines whether a role inheritance rule exists.boolean
hasNamedGroupingPolicy(java.lang.String ptype, java.lang.String... params)
hasNamedGroupingPolicy determines whether a named role inheritance rule exists.boolean
hasNamedGroupingPolicy(java.lang.String ptype, java.util.List<java.lang.String> params)
hasNamedGroupingPolicy determines whether a named role inheritance rule exists.boolean
hasNamedPolicy(java.lang.String ptype, java.lang.String... params)
hasNamedPolicy determines whether a named authorization rule exists.boolean
hasNamedPolicy(java.lang.String ptype, java.util.List<java.lang.String> params)
hasNamedPolicy determines whether a named authorization rule exists.boolean
hasPermissionForUser(java.lang.String user, java.lang.String... permission)
hasPermissionForUser determines whether a user has a permission.boolean
hasPermissionForUser(java.lang.String user, java.util.List<java.lang.String> permission)
hasPermissionForUser determines whether a user has a permission.boolean
hasPolicy(java.lang.String... params)
hasPolicy determines whether an authorization rule exists.boolean
hasPolicy(java.util.List<java.lang.String> params)
hasPolicy determines whether an authorization rule exists.boolean
hasRoleForUser(java.lang.String name, java.lang.String role)
hasRoleForUser determines whether a user has a role.boolean
isAutoLoadingRunning()
void
loadFilteredPolicy(java.lang.Object filter)
loadFilteredPolicy reloads a filtered policy from file/database.void
loadPolicy()
loadPolicy reloads the policy from file/database.boolean
removeFilteredGroupingPolicy(int fieldIndex, java.lang.String... fieldValues)
removeFilteredGroupingPolicy removes a role inheritance rule from the current policy, field filters can be specified.boolean
removeFilteredNamedGroupingPolicy(java.lang.String ptype, int fieldIndex, java.lang.String... fieldValues)
removeFilteredNamedGroupingPolicy removes a role inheritance rule from the current named policy, field filters can be specified.boolean
removeFilteredNamedPolicy(java.lang.String ptype, int fieldIndex, java.lang.String... fieldValues)
removeFilteredNamedPolicy removes an authorization rule from the current named policy, field filters can be specified.boolean
removeFilteredPolicy(int fieldIndex, java.lang.String... fieldValues)
removeFilteredPolicy removes an authorization rule from the current policy, field filters can be specified.boolean
removeGroupingPolicies(java.lang.String[][] rules)
removeGroupingPolicies removes role inheritance rules from the current policy.boolean
removeGroupingPolicies(java.util.List<java.util.List<java.lang.String>> rules)
removeGroupingPolicies removes role inheritance rules from the current policy.boolean
removeGroupingPolicy(java.lang.String... params)
removeGroupingPolicy removes a role inheritance rule from the current policy.boolean
removeGroupingPolicy(java.util.List<java.lang.String> params)
removeGroupingPolicy removes a role inheritance rule from the current policy.boolean
removeNamedGroupingPolicies(java.lang.String ptype, java.lang.String[][] rules)
removeNamedGroupingPolicies removes role inheritance rules from the current named policy.boolean
removeNamedGroupingPolicies(java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
removeNamedGroupingPolicies removes role inheritance rules from the current named policy.boolean
removeNamedGroupingPolicy(java.lang.String ptype, java.lang.String... params)
removeNamedGroupingPolicy removes a role inheritance rule from the current named policy.boolean
removeNamedGroupingPolicy(java.lang.String ptype, java.util.List<java.lang.String> params)
removeNamedGroupingPolicy removes a role inheritance rule from the current named policy.boolean
removeNamedPolicies(java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
removeNamedPolicies removes authorization rules from the current named policy.boolean
removeNamedPolicy(java.lang.String ptype, java.lang.String... params)
removeNamedPolicy removes an authorization rule from the current named policy.boolean
removeNamedPolicy(java.lang.String ptype, java.util.List<java.lang.String> params)
removeNamedPolicy removes an authorization rule from the current named policy.boolean
removePolicies(java.lang.String[][] rules)
removePolicies removes authorization rules from the current policy.boolean
removePolicies(java.util.List<java.util.List<java.lang.String>> rules)
removePolicies removes authorization rules from the current policy.boolean
removePolicy(java.lang.String... params)
removePolicy removes an authorization rule from the current policy.boolean
removePolicy(java.util.List<java.lang.String> params)
removePolicy removes an authorization rule from the current policy.private void
runSynchronized(java.lang.Runnable action, java.util.concurrent.locks.Lock lock)
private <T> T
runSynchronized(java.util.function.Supplier<T> action, java.util.concurrent.locks.Lock lock)
void
savePolicy()
savePolicy saves the current policy (usually after changed with Casbin API) back to file/database.void
setWatcher(Watcher watcher)
setWatcher sets the current watcher.void
startAutoLoadPolicy(long d)
void
stopAutoLoadPolicy()
boolean
updateGroupingPolicy(java.util.List<java.lang.String> params1, java.util.List<java.lang.String> params2)
UpdateGroupingPolicy updates an authorization rule to the current named policy.boolean
updateNamedGroupingPolicy(java.lang.String ptype, java.util.List<java.lang.String> params1, java.util.List<java.lang.String> params2)
updateNamedGroupingPolicy updates an authorization rule to the current named policy.boolean
updateNamedPolicy(java.lang.String ptype, java.util.List<java.lang.String> params1, java.util.List<java.lang.String> params2)
updateNamedPolicy updates an authorization rule to the current named policy.boolean
updatePolicy(java.util.List<java.lang.String> params1, java.util.List<java.lang.String> params2)
updatePolicy update an authorization rule to the current policy.-
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
-
SyncedEnforcer
public SyncedEnforcer()
; SyncedEnforcer is the default constructor.
-
SyncedEnforcer
public SyncedEnforcer(java.lang.String modelPath, java.lang.String policyFile)
SyncedEnforcer 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.
-
SyncedEnforcer
public SyncedEnforcer(java.lang.String modelPath, Adapter adapter)
SyncedEnforcer initializes an enforcer with a database adapter.- Parameters:
modelPath
- the path of the model file.adapter
- the adapter.
-
SyncedEnforcer
public SyncedEnforcer(Model m, Adapter adapter)
SyncedEnforcer initializes an enforcer with a model and a database adapter.- Parameters:
m
- the model.adapter
- the adapter.
-
SyncedEnforcer
public SyncedEnforcer(Model m)
SyncedEnforcer initializes an enforcer with a model.- Parameters:
m
- the model.
-
SyncedEnforcer
public SyncedEnforcer(java.lang.String modelPath)
SyncedEnforcer initializes an enforcer with a model file.- Parameters:
modelPath
- the path of the model file.
-
SyncedEnforcer
public SyncedEnforcer(java.lang.String modelPath, java.lang.String policyFile, boolean enableLog)
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 Detail
-
isAutoLoadingRunning
public boolean isAutoLoadingRunning()
-
startAutoLoadPolicy
public void startAutoLoadPolicy(long d)
-
stopAutoLoadPolicy
public void stopAutoLoadPolicy()
-
setWatcher
public void setWatcher(Watcher watcher)
setWatcher sets the current watcher.- Overrides:
setWatcher
in classCoreEnforcer
- Parameters:
watcher
- the watcher.
-
clearPolicy
public void clearPolicy()
clearPolicy clears all policy.- Overrides:
clearPolicy
in classCoreEnforcer
-
loadPolicy
public void loadPolicy()
loadPolicy reloads the policy from file/database.- Overrides:
loadPolicy
in classCoreEnforcer
-
loadFilteredPolicy
public void loadFilteredPolicy(java.lang.Object filter)
loadFilteredPolicy reloads a filtered policy from file/database.- Overrides:
loadFilteredPolicy
in 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:
savePolicy
in classCoreEnforcer
-
buildRoleLinks
public void buildRoleLinks()
buildRoleLinks manually rebuild the role inheritance relations.- Overrides:
buildRoleLinks
in classCoreEnforcer
-
enforce
public boolean enforce(java.lang.Object... rvals)
enforce decides whether a "subject" can access a "object" with the operation "action", input parameters are usually: (sub, obj, act).- Overrides:
enforce
in 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
public boolean enforceWithMatcher(java.lang.String matcher, java.lang.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.- Overrides:
enforceWithMatcher
in 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
public EnforceResult enforceEx(java.lang.Object... rvals)
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:
enforceEx
in 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
public EnforceResult enforceExWithMatcher(java.lang.String matcher, java.lang.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. the list explain, store matching rule.- Overrides:
enforceExWithMatcher
in 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
public java.util.List<java.lang.Boolean> batchEnforce(java.util.List<java.util.List<java.lang.String>> rules)
batchEnforce enforce in batches- Overrides:
batchEnforce
in classEnforcer
- Parameters:
rules
- the rules.- Returns:
- the results
-
batchEnforceWithMatcher
public java.util.List<java.lang.Boolean> batchEnforceWithMatcher(java.lang.String matcher, java.util.List<java.util.List<java.lang.String>> rules)
batchEnforceWithMatcher enforce with matcher in batches- Overrides:
batchEnforceWithMatcher
in classEnforcer
- Parameters:
matcher
- the custom matcher.rules
- the rules.- Returns:
- the results
-
getAllSubjects
public java.util.List<java.lang.String> getAllSubjects()
getAllSubjects gets the list of subjects that show up in the current policy.- Overrides:
getAllSubjects
in 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
public java.util.List<java.lang.String> getAllObjects()
getAllObjects gets the list of objects that show up in the current policy.- Overrides:
getAllObjects
in 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
public java.util.List<java.lang.String> getAllNamedObjects(java.lang.String ptype)
getAllNamedObjects gets the list of objects that show up in the current named policy.- Overrides:
getAllNamedObjects
in 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
public java.util.List<java.lang.String> getAllActions()
getAllActions gets the list of actions that show up in the current policy.- Overrides:
getAllActions
in 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
public java.util.List<java.lang.String> getAllNamedActions(java.lang.String ptype)
GetAllNamedActions gets the list of actions that show up in the current named policy.- Overrides:
getAllNamedActions
in 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
public java.util.List<java.lang.String> getAllRoles()
getAllRoles gets the list of roles that show up in the current policy.- Overrides:
getAllRoles
in 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
public java.util.List<java.lang.String> getAllNamedRoles(java.lang.String ptype)
getAllNamedRoles gets the list of roles that show up in the current named policy.- Overrides:
getAllNamedRoles
in 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
public java.util.List<java.util.List<java.lang.String>> getPolicy()
getPolicy gets all the authorization rules in the policy.- Overrides:
getPolicy
in classManagementEnforcer
- Returns:
- all the "p" policy rules.
-
getFilteredPolicy
public java.util.List<java.util.List<java.lang.String>> getFilteredPolicy(int fieldIndex, java.lang.String... fieldValues)
getFilteredPolicy gets all the authorization rules in the policy, field filters can be specified.- Overrides:
getFilteredPolicy
in 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
public java.util.List<java.util.List<java.lang.String>> getNamedPolicy(java.lang.String ptype)
getNamedPolicy gets all the authorization rules in the named policy.- Overrides:
getNamedPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "p", "p2", "p3", ..- Returns:
- the "p" policy rules of the specified ptype.
-
getFilteredNamedPolicy
public java.util.List<java.util.List<java.lang.String>> getFilteredNamedPolicy(java.lang.String ptype, int fieldIndex, java.lang.String... fieldValues)
getFilteredNamedPolicy gets all the authorization rules in the named policy, field filters can be specified.- Overrides:
getFilteredNamedPolicy
in 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
public java.util.List<java.util.List<java.lang.String>> getGroupingPolicy()
getGroupingPolicy gets all the role inheritance rules in the policy.- Overrides:
getGroupingPolicy
in classManagementEnforcer
- Returns:
- all the "g" policy rules.
-
getRolesForUser
public java.util.List<java.lang.String> getRolesForUser(java.lang.String name)
getRolesForUser gets the roles that a user has.- Overrides:
getRolesForUser
in classEnforcer
- Parameters:
name
- the user.- Returns:
- the roles that the user has.
-
getFilteredGroupingPolicy
public java.util.List<java.util.List<java.lang.String>> getFilteredGroupingPolicy(int fieldIndex, java.lang.String... fieldValues)
getFilteredGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.- Overrides:
getFilteredGroupingPolicy
in 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
public java.util.List<java.util.List<java.lang.String>> getNamedGroupingPolicy(java.lang.String ptype)
getNamedGroupingPolicy gets all the role inheritance rules in the policy.- Overrides:
getNamedGroupingPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "g", "g2", "g3", ..- Returns:
- the "g" policy rules of the specified ptype.
-
getFilteredNamedGroupingPolicy
public java.util.List<java.util.List<java.lang.String>> getFilteredNamedGroupingPolicy(java.lang.String ptype, int fieldIndex, java.lang.String... fieldValues)
getFilteredNamedGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.- Overrides:
getFilteredNamedGroupingPolicy
in 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
public boolean hasPolicy(java.util.List<java.lang.String> params)
hasPolicy determines whether an authorization rule exists.- Overrides:
hasPolicy
in classManagementEnforcer
- Parameters:
params
- the "p" policy rule, ptype "p" is implicitly used.- Returns:
- whether the rule exists.
-
hasPolicy
public boolean hasPolicy(java.lang.String... params)
hasPolicy determines whether an authorization rule exists.- Overrides:
hasPolicy
in classManagementEnforcer
- Parameters:
params
- the "p" policy rule, ptype "p" is implicitly used.- Returns:
- whether the rule exists.
-
hasNamedPolicy
public boolean hasNamedPolicy(java.lang.String ptype, java.util.List<java.lang.String> params)
hasNamedPolicy determines whether a named authorization rule exists.- Overrides:
hasNamedPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "p", "p2", "p3", ..params
- the "p" policy rule.- Returns:
- whether the rule exists.
-
hasNamedPolicy
public boolean hasNamedPolicy(java.lang.String ptype, java.lang.String... params)
hasNamedPolicy determines whether a named authorization rule exists.- Overrides:
hasNamedPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "p", "p2", "p3", ..params
- the "p" policy rule.- Returns:
- whether the rule exists.
-
addPolicy
public boolean addPolicy(java.util.List<java.lang.String> params)
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:
addPolicy
in classManagementEnforcer
- Parameters:
params
- the "p" policy rule, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
addPolicies
public boolean addPolicies(java.util.List<java.util.List<java.lang.String>> rules)
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:
addPolicies
in classManagementEnforcer
- Parameters:
rules
- the "p" policy rules, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
updatePolicy
public boolean updatePolicy(java.util.List<java.lang.String> params1, java.util.List<java.lang.String> params2)
updatePolicy update an authorization rule to the current policy.- Overrides:
updatePolicy
in classManagementEnforcer
- Parameters:
params1
- the old rule.params2
- the new rule.- Returns:
- succeeds or not.
-
addPolicy
public boolean addPolicy(java.lang.String... params)
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:
addPolicy
in classManagementEnforcer
- Parameters:
params
- the "p" policy rule, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
addPolicies
public boolean addPolicies(java.lang.String[][] rules)
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:
addPolicies
in classManagementEnforcer
- Parameters:
rules
- the "p" policy rules, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
addNamedPolicy
public boolean addNamedPolicy(java.lang.String ptype, java.util.List<java.lang.String> params)
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:
addNamedPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "p", "p2", "p3", ..params
- the "p" policy rule.- Returns:
- succeeds or not.
-
addNamedPolicies
public boolean addNamedPolicies(java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
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:
addNamedPolicies
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "p", "p2", "p3", ..rules
- the "p" policy rules.- Returns:
- succeeds or not.
-
addNamedPoliciesEx
public boolean addNamedPoliciesEx(java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
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:
addNamedPoliciesEx
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "p", "p2", "p3", ..rules
- the "p" policy rules.- Returns:
- succeeds or not.
-
updateNamedPolicy
public boolean updateNamedPolicy(java.lang.String ptype, java.util.List<java.lang.String> params1, java.util.List<java.lang.String> params2)
updateNamedPolicy updates an authorization rule to the current named policy.- Overrides:
updateNamedPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "p", "p2", "p3", ..params1
- the old rule.params2
- the new rule.- Returns:
- succeeds or not.
-
updateGroupingPolicy
public boolean updateGroupingPolicy(java.util.List<java.lang.String> params1, java.util.List<java.lang.String> params2)
UpdateGroupingPolicy updates an authorization rule to the current named policy.- Overrides:
updateGroupingPolicy
in classManagementEnforcer
- Parameters:
params1
- the old rule.params2
- the new rule.- Returns:
- succeeds or not.
-
updateNamedGroupingPolicy
public boolean updateNamedGroupingPolicy(java.lang.String ptype, java.util.List<java.lang.String> params1, java.util.List<java.lang.String> params2)
updateNamedGroupingPolicy updates an authorization rule to the current named policy.- Overrides:
updateNamedGroupingPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "g", "g2", "g3", ..params1
- the old rule.params2
- the new rule.- Returns:
- succeeds or not.
-
addNamedPolicy
public boolean addNamedPolicy(java.lang.String ptype, java.lang.String... params)
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:
addNamedPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "p", "p2", "p3", ..params
- the "p" policy rule.- Returns:
- succeeds or not.
-
removePolicy
public boolean removePolicy(java.util.List<java.lang.String> params)
removePolicy removes an authorization rule from the current policy.- Overrides:
removePolicy
in classManagementEnforcer
- Parameters:
params
- the "p" policy rule, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
removePolicy
public boolean removePolicy(java.lang.String... params)
removePolicy removes an authorization rule from the current policy.- Overrides:
removePolicy
in classManagementEnforcer
- Parameters:
params
- the "p" policy rule, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
removePolicies
public boolean removePolicies(java.util.List<java.util.List<java.lang.String>> rules)
removePolicies removes authorization rules from the current policy.- Overrides:
removePolicies
in classManagementEnforcer
- Parameters:
rules
- the "p" policy rules, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
removePolicies
public boolean removePolicies(java.lang.String[][] rules)
removePolicies removes authorization rules from the current policy.- Overrides:
removePolicies
in classManagementEnforcer
- Parameters:
rules
- the "p" policy rules, ptype "p" is implicitly used.- Returns:
- succeeds or not.
-
removeFilteredPolicy
public boolean removeFilteredPolicy(int fieldIndex, java.lang.String... fieldValues)
removeFilteredPolicy removes an authorization rule from the current policy, field filters can be specified.- Overrides:
removeFilteredPolicy
in 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
public boolean removeNamedPolicy(java.lang.String ptype, java.util.List<java.lang.String> params)
removeNamedPolicy removes an authorization rule from the current named policy.- Overrides:
removeNamedPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "p", "p2", "p3", ..params
- the "p" policy rule.- Returns:
- succeeds or not.
-
removeNamedPolicy
public boolean removeNamedPolicy(java.lang.String ptype, java.lang.String... params)
removeNamedPolicy removes an authorization rule from the current named policy.- Overrides:
removeNamedPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "p", "p2", "p3", ..params
- the "p" policy rule.- Returns:
- succeeds or not.
-
removeNamedPolicies
public boolean removeNamedPolicies(java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
removeNamedPolicies removes authorization rules from the current named policy.- Overrides:
removeNamedPolicies
in classManagementEnforcer
- Parameters:
ptype
- ptype the policy type, can be "p", "p2", "p3", ..rules
- the "p" policy rules.- Returns:
- succeeds or not.
-
removeFilteredNamedPolicy
public boolean removeFilteredNamedPolicy(java.lang.String ptype, int fieldIndex, java.lang.String... fieldValues)
removeFilteredNamedPolicy removes an authorization rule from the current named policy, field filters can be specified.- Overrides:
removeFilteredNamedPolicy
in 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
public boolean hasGroupingPolicy(java.util.List<java.lang.String> params)
hasGroupingPolicy determines whether a role inheritance rule exists.- Overrides:
hasGroupingPolicy
in classManagementEnforcer
- Parameters:
params
- the "g" policy rule, ptype "g" is implicitly used.- Returns:
- whether the rule exists.
-
hasGroupingPolicy
public boolean hasGroupingPolicy(java.lang.String... params)
hasGroupingPolicy determines whether a role inheritance rule exists.- Overrides:
hasGroupingPolicy
in classManagementEnforcer
- Parameters:
params
- the "g" policy rule, ptype "g" is implicitly used.- Returns:
- whether the rule exists.
-
hasNamedGroupingPolicy
public boolean hasNamedGroupingPolicy(java.lang.String ptype, java.util.List<java.lang.String> params)
hasNamedGroupingPolicy determines whether a named role inheritance rule exists.- Overrides:
hasNamedGroupingPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "g", "g2", "g3", ..params
- the "g" policy rule.- Returns:
- whether the rule exists.
-
hasNamedGroupingPolicy
public boolean hasNamedGroupingPolicy(java.lang.String ptype, java.lang.String... params)
hasNamedGroupingPolicy determines whether a named role inheritance rule exists.- Overrides:
hasNamedGroupingPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "g", "g2", "g3", ..params
- the "g" policy rule.- Returns:
- whether the rule exists.
-
addGroupingPolicy
public boolean addGroupingPolicy(java.util.List<java.lang.String> params)
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:
addGroupingPolicy
in classManagementEnforcer
- Parameters:
params
- the "g" policy rule, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
addGroupingPolicy
public boolean addGroupingPolicy(java.lang.String... params)
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:
addGroupingPolicy
in classManagementEnforcer
- Parameters:
params
- the "g" policy rule, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
addGroupingPolicies
public boolean addGroupingPolicies(java.util.List<java.util.List<java.lang.String>> rules)
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:
addGroupingPolicies
in classManagementEnforcer
- Parameters:
rules
- the "g" policy rules, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
addGroupingPolicies
public boolean addGroupingPolicies(java.lang.String[][] rules)
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:
addGroupingPolicies
in classManagementEnforcer
- Parameters:
rules
- the "g" policy rules, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
addNamedGroupingPolicy
public boolean addNamedGroupingPolicy(java.lang.String ptype, java.util.List<java.lang.String> params)
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:
addNamedGroupingPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "g", "g2", "g3", ..params
- the "g" policy rule.- Returns:
- succeeds or not.
-
addNamedGroupingPolicy
public boolean addNamedGroupingPolicy(java.lang.String ptype, java.lang.String... params)
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:
addNamedGroupingPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "g", "g2", "g3", ..params
- the "g" policy rule.- Returns:
- succeeds or not.
-
addNamedGroupingPolicies
public boolean addNamedGroupingPolicies(java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
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:
addNamedGroupingPolicies
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "g", "g2", "g3", ..rules
- the "g" policy rules.- Returns:
- succeeds or not.
-
addNamedGroupingPolicies
public boolean addNamedGroupingPolicies(java.lang.String ptype, java.lang.String[][] rules)
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:
addNamedGroupingPolicies
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "g", "g2", "g3", ..rules
- the "g" policy rules.- Returns:
- succeeds or not.
-
removeGroupingPolicy
public boolean removeGroupingPolicy(java.util.List<java.lang.String> params)
removeGroupingPolicy removes a role inheritance rule from the current policy.- Overrides:
removeGroupingPolicy
in classManagementEnforcer
- Parameters:
params
- the "g" policy rule, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
removeGroupingPolicy
public boolean removeGroupingPolicy(java.lang.String... params)
removeGroupingPolicy removes a role inheritance rule from the current policy.- Overrides:
removeGroupingPolicy
in classManagementEnforcer
- Parameters:
params
- the "g" policy rule, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
removeGroupingPolicies
public boolean removeGroupingPolicies(java.util.List<java.util.List<java.lang.String>> rules)
removeGroupingPolicies removes role inheritance rules from the current policy.- Overrides:
removeGroupingPolicies
in classManagementEnforcer
- Parameters:
rules
- the "g" policy rules, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
removeGroupingPolicies
public boolean removeGroupingPolicies(java.lang.String[][] rules)
removeGroupingPolicies removes role inheritance rules from the current policy.- Overrides:
removeGroupingPolicies
in classManagementEnforcer
- Parameters:
rules
- the "g" policy rules, ptype "g" is implicitly used.- Returns:
- succeeds or not.
-
removeFilteredGroupingPolicy
public boolean removeFilteredGroupingPolicy(int fieldIndex, java.lang.String... fieldValues)
removeFilteredGroupingPolicy removes a role inheritance rule from the current policy, field filters can be specified.- Overrides:
removeFilteredGroupingPolicy
in 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
public boolean removeNamedGroupingPolicy(java.lang.String ptype, java.util.List<java.lang.String> params)
removeNamedGroupingPolicy removes a role inheritance rule from the current named policy.- Overrides:
removeNamedGroupingPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "g", "g2", "g3", ..params
- the "g" policy rule.- Returns:
- succeeds or not.
-
removeNamedGroupingPolicy
public boolean removeNamedGroupingPolicy(java.lang.String ptype, java.lang.String... params)
removeNamedGroupingPolicy removes a role inheritance rule from the current named policy.- Overrides:
removeNamedGroupingPolicy
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "g", "g2", "g3", ..params
- the "g" policy rule.- Returns:
- succeeds or not.
-
removeNamedGroupingPolicies
public boolean removeNamedGroupingPolicies(java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
removeNamedGroupingPolicies removes role inheritance rules from the current named policy.- Overrides:
removeNamedGroupingPolicies
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "g", "g2", "g3", ..rules
- the "g" policy rules.- Returns:
- succeeds or not.
-
removeNamedGroupingPolicies
public boolean removeNamedGroupingPolicies(java.lang.String ptype, java.lang.String[][] rules)
removeNamedGroupingPolicies removes role inheritance rules from the current named policy.- Overrides:
removeNamedGroupingPolicies
in classManagementEnforcer
- Parameters:
ptype
- the policy type, can be "g", "g2", "g3", ..rules
- the "g" policy rules.- Returns:
- succeeds or not.
-
removeFilteredNamedGroupingPolicy
public boolean removeFilteredNamedGroupingPolicy(java.lang.String ptype, int fieldIndex, java.lang.String... fieldValues)
removeFilteredNamedGroupingPolicy removes a role inheritance rule from the current named policy, field filters can be specified.- Overrides:
removeFilteredNamedGroupingPolicy
in 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
public java.util.List<java.lang.String> getUsersForRole(java.lang.String name)
getUsersForRole gets the users that has a role.- Overrides:
getUsersForRole
in classEnforcer
- Parameters:
name
- the role.- Returns:
- the users that has the role.
-
hasRoleForUser
public boolean hasRoleForUser(java.lang.String name, java.lang.String role)
hasRoleForUser determines whether a user has a role.- Overrides:
hasRoleForUser
in classEnforcer
- Parameters:
name
- the user.role
- the role.- Returns:
- whether the user has the role.
-
addRoleForUser
public boolean addRoleForUser(java.lang.String user, java.lang.String role)
addRoleForUser adds a role for a user. Returns false if the user already has the role (aka not affected).- Overrides:
addRoleForUser
in classEnforcer
- Parameters:
user
- the user.role
- the role.- Returns:
- succeeds or not.
-
deleteRoleForUser
public boolean deleteRoleForUser(java.lang.String user, java.lang.String role)
deleteRoleForUser deletes a role for a user. Returns false if the user does not have the role (aka not affected).- Overrides:
deleteRoleForUser
in classEnforcer
- Parameters:
user
- the user.role
- the role.- Returns:
- succeeds or not.
-
deleteRolesForUser
public boolean deleteRolesForUser(java.lang.String user)
deleteRolesForUser deletes all roles for a user. Returns false if the user does not have any roles (aka not affected).- Overrides:
deleteRolesForUser
in classEnforcer
- Parameters:
user
- the user.- Returns:
- succeeds or not.
-
deleteUser
public boolean deleteUser(java.lang.String user)
deleteUser deletes a user. Returns false if the user does not exist (aka not affected).- Overrides:
deleteUser
in classEnforcer
- Parameters:
user
- the user.- Returns:
- succeeds or not.
-
deleteRole
public void deleteRole(java.lang.String role)
deleteRole deletes a role.- Overrides:
deleteRole
in classEnforcer
- Parameters:
role
- the role.
-
deletePermission
public boolean deletePermission(java.lang.String... permission)
deletePermission deletes a permission. Returns false if the permission does not exist (aka not affected).- Overrides:
deletePermission
in classEnforcer
- Parameters:
permission
- the permission, usually be (obj, act). It is actually the rule without the subject.- Returns:
- succeeds or not.
-
deletePermission
public boolean deletePermission(java.util.List<java.lang.String> permission)
deletePermission deletes a permission. Returns false if the permission does not exist (aka not affected).- Overrides:
deletePermission
in classEnforcer
- Parameters:
permission
- the permission, usually be (obj, act). It is actually the rule without the subject.- Returns:
- succeeds or not.
-
addPermissionForUser
public boolean addPermissionForUser(java.lang.String user, java.lang.String... permission)
addPermissionForUser adds a permission for a user or role. Returns false if the user or role already has the permission (aka not affected).- Overrides:
addPermissionForUser
in 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
public boolean addPermissionForUser(java.lang.String user, java.util.List<java.lang.String> permission)
addPermissionForUser adds a permission for a user or role. Returns false if the user or role already has the permission (aka not affected).- Overrides:
addPermissionForUser
in 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
public boolean deletePermissionForUser(java.lang.String user, java.lang.String... permission)
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:
deletePermissionForUser
in 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
public boolean deletePermissionForUser(java.lang.String user, java.util.List<java.lang.String> permission)
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:
deletePermissionForUser
in 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
public boolean deletePermissionsForUser(java.lang.String user)
deletePermissionsForUser deletes permissions for a user or role. Returns false if the user or role does not have any permissions (aka not affected).- Overrides:
deletePermissionsForUser
in classEnforcer
- Parameters:
user
- the user.- Returns:
- succeeds or not.
-
getPermissionsForUser
public java.util.List<java.util.List<java.lang.String>> getPermissionsForUser(java.lang.String user, java.lang.String... domain)
getPermissionsForUser gets permissions for a user or role.- Overrides:
getPermissionsForUser
in 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
public java.util.List<java.util.List<java.lang.String>> getNamedPermissionsForUser(java.lang.String pType, java.lang.String user, java.lang.String... domain)
GetNamedPermissionsForUser gets permissions for a user or role by named policy.- Overrides:
getNamedPermissionsForUser
in classEnforcer
- Parameters:
pType
- the name policy.user
- the user.domain
- domain.- Returns:
- the permissions.
-
hasPermissionForUser
public boolean hasPermissionForUser(java.lang.String user, java.lang.String... permission)
hasPermissionForUser determines whether a user has a permission.- Overrides:
hasPermissionForUser
in 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
public boolean hasPermissionForUser(java.lang.String user, java.util.List<java.lang.String> permission)
hasPermissionForUser determines whether a user has a permission.- Overrides:
hasPermissionForUser
in 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
public java.util.List<java.lang.String> getUsersForRoleInDomain(java.lang.String name, java.lang.String domain)
getUsersForRoleInDomain gets the users that a role has inside a domain.- Overrides:
getUsersForRoleInDomain
in classEnforcer
- Parameters:
name
- the role.domain
- the domain.- Returns:
- the users that the role has in the domain.
-
getRolesForUserInDomain
public java.util.List<java.lang.String> getRolesForUserInDomain(java.lang.String name, java.lang.String domain)
getRolesForUserInDomain gets the roles that a user has inside a domain.- Overrides:
getRolesForUserInDomain
in classEnforcer
- Parameters:
name
- the user.domain
- the domain.- Returns:
- the roles that the user has in the domain.
-
getPermissionsForUserInDomain
public java.util.List<java.util.List<java.lang.String>> getPermissionsForUserInDomain(java.lang.String user, java.lang.String domain)
getPermissionsForUserInDomain gets permissions for a user or role inside a domain.- Overrides:
getPermissionsForUserInDomain
in 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
public boolean addRoleForUserInDomain(java.lang.String user, java.lang.String role, java.lang.String domain)
addRoleForUserInDomain adds a role for a user inside a domain. Returns false if the user already has the role (aka not affected).- Overrides:
addRoleForUserInDomain
in classEnforcer
- Parameters:
user
- the user.role
- the role.domain
- the domain.- Returns:
- succeeds or not.
-
deleteRoleForUserInDomain
public boolean deleteRoleForUserInDomain(java.lang.String user, java.lang.String role, java.lang.String domain)
deleteRoleForUserInDomain deletes a role for a user inside a domain. Returns false if the user does not have the role (aka not affected).- Overrides:
deleteRoleForUserInDomain
in classEnforcer
- Parameters:
user
- the user.role
- the role.domain
- the domain.- Returns:
- succeeds or not.
-
getImplicitRolesForUser
public java.util.List<java.lang.String> getImplicitRolesForUser(java.lang.String name, java.lang.String... domain)
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:
getImplicitRolesForUser
in classEnforcer
- Parameters:
name
- the userdomain
- the domain- Returns:
- implicit roles that a user has.
-
getImplicitPermissionsForUser
public java.util.List<java.util.List<java.lang.String>> getImplicitPermissionsForUser(java.lang.String user, java.lang.String... domain)
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:
getImplicitPermissionsForUser
in classEnforcer
- Parameters:
user
- the user.domain
- the user's domain.- Returns:
- implicit permissions for a user or role.
-
getNamedImplicitPermissionsForUser
public java.util.List<java.util.List<java.lang.String>> getNamedImplicitPermissionsForUser(java.lang.String pType, java.lang.String user, java.lang.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:
getNamedImplicitPermissionsForUser
in 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
private <T> T runSynchronized(java.util.function.Supplier<T> action, java.util.concurrent.locks.Lock lock)
-
runSynchronized
private void runSynchronized(java.lang.Runnable action, java.util.concurrent.locks.Lock lock)
-
-