public class Enforcer extends ManagementEnforcer
Constructor and Description |
---|
Enforcer()
Enforcer is the default constructor.
|
Enforcer(Model m)
Enforcer initializes an enforcer with a model.
|
Enforcer(Model m,
Adapter adapter)
Enforcer initializes an enforcer with a model and a database adapter.
|
Enforcer(Model m,
Adapter adapter,
boolean enableLog)
Enforcer initializes an enforcer with a model, a database adapter and an enable log flag.
|
Enforcer(java.lang.String modelPath)
Enforcer initializes an enforcer with a model file.
|
Enforcer(java.lang.String modelPath,
Adapter adapter)
Enforcer initializes an enforcer with a database adapter.
|
Enforcer(java.lang.String modelPath,
java.lang.String policyFile)
Enforcer initializes an enforcer with a model file and a policy file.
|
Enforcer(java.lang.String modelPath,
java.lang.String policyFile,
boolean enableLog)
Enforcer initializes an enforcer with a model file, a policy file and an enable log flag.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addPermissionForUser(java.lang.String user,
java.util.List<java.lang.String> permission)
addPermissionForUser adds a permission for a user or role.
|
boolean |
addPermissionForUser(java.lang.String user,
java.lang.String... permission)
addPermissionForUser adds a permission for a user or role.
|
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 batches
|
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
|
void |
buildIncrementalRoleLinks(Model.PolicyOperations op,
java.lang.String ptype,
java.util.List<java.util.List<java.lang.String>> rules)
buildIncrementalRoleLinks provides incremental build the role inheritance relations.
|
boolean |
deletePermission(java.util.List<java.lang.String> permission)
deletePermission deletes a permission.
|
boolean |
deletePermission(java.lang.String... permission)
deletePermission deletes a permission.
|
boolean |
deletePermissionForUser(java.lang.String user,
java.util.List<java.lang.String> permission)
deletePermissionForUser deletes a permission for a user or role.
|
boolean |
deletePermissionForUser(java.lang.String user,
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.
|
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.util.List<java.lang.String>> |
getImplicitPermissionsForUserInDomain(java.lang.String user,
java.lang.String domain)
getImplicitPermissionsForUserInDomain gets implicit permissions for a user or role in domain.
|
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.lang.String> |
getImplicitUsersForRole(java.lang.String name,
java.lang.String... domain)
getImplicitUsersForRole gets implicit users for a role.
|
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>> |
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.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 have 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 |
hasPermissionForUser(java.lang.String user,
java.util.List<java.lang.String> permission)
hasPermissionForUser determines whether a user has a permission.
|
boolean |
hasPermissionForUser(java.lang.String user,
java.lang.String... permission)
hasPermissionForUser determines whether a user has a permission.
|
boolean |
hasRoleForUser(java.lang.String name,
java.lang.String role)
hasRoleForUser determines whether a user has a role.
|
boolean |
updatePermissionForUser(java.lang.String user,
java.util.List<java.lang.String> oldPermission,
java.util.List<java.lang.String> newPermission)
updatePermissionForUser updates a permission for a user or role.
|
addFunction, addGroupingPolicies, addGroupingPolicies, addGroupingPolicy, addGroupingPolicy, addNamedGroupingPolicies, addNamedGroupingPolicies, addNamedGroupingPolicy, addNamedGroupingPolicy, addNamedPolicies, addNamedPolicy, addNamedPolicy, addPolicies, addPolicies, addPolicy, addPolicy, getAllActions, getAllNamedActions, getAllNamedObjects, getAllNamedRoles, getAllNamedSubjects, getAllObjects, getAllRoles, getAllSubjects, getFilteredGroupingPolicy, getFilteredNamedGroupingPolicy, getFilteredNamedPolicy, getFilteredPolicy, getGroupingPolicy, getNamedGroupingPolicy, getNamedPolicy, getPermittedActions, getPolicy, hasGroupingPolicy, hasGroupingPolicy, hasNamedGroupingPolicy, hasNamedGroupingPolicy, hasNamedPolicy, hasNamedPolicy, hasPolicy, hasPolicy, removeFilteredGroupingPolicy, removeFilteredNamedGroupingPolicy, removeFilteredNamedPolicy, removeFilteredPolicy, removeGroupingPolicies, removeGroupingPolicies, removeGroupingPolicy, removeGroupingPolicy, removeNamedGroupingPolicies, removeNamedGroupingPolicies, removeNamedGroupingPolicy, removeNamedGroupingPolicy, removeNamedPolicies, removeNamedPolicy, removeNamedPolicy, removePolicies, removePolicies, removePolicy, removePolicy, updateGroupingPolicy, updateNamedGroupingPolicy, updateNamedPolicy, updatePolicy
addNamedDomainLinkConditionFunc, addNamedDomainMatchingFunc, addNamedLinkConditionFunc, addNamedMatchingFunc, buildConditionalRoleLinks, buildRoleLinks, clearPolicy, enableAcceptJsonRequest, enableAutoBuildRoleLinks, enableAutoSave, enableEnforce, enableLog, enforce, enforceEx, enforceExWithMatcher, enforceWithMatcher, getAdapter, getAviatorEval, getModel, getNamedRoleManager, getRmMap, getRoleManager, isAutoNotifyDispatcher, isAutoNotifyWatcher, isFiltered, loadFilteredPolicy, loadModel, loadPolicy, mustUseDispatcher, newModel, newModel, newModel, resetExpressionEvaluator, savePolicy, setAdapter, setAutoNotifyDispatcher, setAutoNotifyWatcher, setAviatorEvaluator, setDispatcher, setEffector, setModel, setNamedDomainLinkConditionFuncParams, setNamedLinkConditionFuncParams, setNamedRoleManager, setRoleManager, setRoleManager, setWatcher, validateEnforce
public Enforcer()
public Enforcer(java.lang.String modelPath, java.lang.String policyFile)
modelPath
- the path of the model file.policyFile
- the path of the policy file.public Enforcer(java.lang.String modelPath, Adapter adapter)
modelPath
- the path of the model file.adapter
- the adapter.public Enforcer(Model m, Adapter adapter)
m
- the model.adapter
- the adapter.public Enforcer(Model m, Adapter adapter, boolean enableLog)
m
- the model.adapter
- the adapter.enableLog
- whether to enable Casbin's log.public Enforcer(Model m)
m
- the model.public Enforcer(java.lang.String modelPath)
modelPath
- the path of the model file.public Enforcer(java.lang.String modelPath, java.lang.String policyFile, boolean enableLog)
modelPath
- the path of the model file.policyFile
- the path of the policy file.enableLog
- whether to enable Casbin's log.public java.util.List<java.lang.String> getRolesForUser(java.lang.String name)
name
- the user.public java.util.List<java.lang.String> getUsersForRole(java.lang.String name)
name
- the role.public boolean hasRoleForUser(java.lang.String name, java.lang.String role)
name
- the user.role
- the role.public boolean addRoleForUser(java.lang.String user, java.lang.String role)
user
- the user.role
- the role.public boolean deleteRoleForUser(java.lang.String user, java.lang.String role)
user
- the user.role
- the role.public boolean deleteRolesForUser(java.lang.String user)
user
- the user.public boolean deleteUser(java.lang.String user)
user
- the user.public void deleteRole(java.lang.String role)
role
- the role.public boolean deletePermission(java.lang.String... permission)
permission
- the permission, usually be (obj, act). It is actually the rule without the subject.public boolean deletePermission(java.util.List<java.lang.String> permission)
permission
- the permission, usually be (obj, act). It is actually the rule without the subject.public boolean addPermissionForUser(java.lang.String user, java.lang.String... permission)
user
- the user.permission
- the permission, usually be (obj, act). It is actually the rule without the subject.public boolean updatePermissionForUser(java.lang.String user, java.util.List<java.lang.String> oldPermission, java.util.List<java.lang.String> newPermission)
user
- the user.oldPermission
- the old permission.newPermission
- the new permission.public boolean addPermissionForUser(java.lang.String user, java.util.List<java.lang.String> permission)
user
- the user.permission
- the permission, usually be (obj, act). It is actually the rule without the subject.public boolean deletePermissionForUser(java.lang.String user, java.lang.String... permission)
user
- the user.permission
- the permission, usually be (obj, act). It is actually the rule without the subject.public boolean deletePermissionForUser(java.lang.String user, java.util.List<java.lang.String> permission)
user
- the user.permission
- the permission, usually be (obj, act). It is actually the rule without the subject.public boolean deletePermissionsForUser(java.lang.String user)
user
- the user.public java.util.List<java.util.List<java.lang.String>> getPermissionsForUser(java.lang.String user, java.lang.String... domain)
user
- the user.domain
- domain.public boolean hasPermissionForUser(java.lang.String user, java.lang.String... permission)
user
- the user.permission
- the permission, usually be (obj, act). It is actually the rule without the subject.public boolean hasPermissionForUser(java.lang.String user, java.util.List<java.lang.String> permission)
user
- the user.permission
- the permission, usually be (obj, act). It is actually the rule without the subject.public java.util.List<java.lang.String> getUsersForRoleInDomain(java.lang.String name, java.lang.String domain)
name
- the role.domain
- the domain.public java.util.List<java.lang.String> getRolesForUserInDomain(java.lang.String name, java.lang.String domain)
name
- the user.domain
- the domain.public java.util.List<java.util.List<java.lang.String>> getPermissionsForUserInDomain(java.lang.String user, java.lang.String domain)
user
- the user.domain
- the domain.public boolean addRoleForUserInDomain(java.lang.String user, java.lang.String role, java.lang.String domain)
user
- the user.role
- the role.domain
- the domain.public boolean deleteRoleForUserInDomain(java.lang.String user, java.lang.String role, java.lang.String domain)
user
- the user.role
- the role.domain
- the domain.public java.util.List<java.lang.String> getImplicitRolesForUser(java.lang.String name, java.lang.String... domain)
getRolesForUser("alice") can only get: ["role:admin"]. But getImplicitRolesForUser("alice") will get: ["role:admin", "role:user"].
name
- the user.domain
- the user's domain.public java.util.List<java.lang.String> getImplicitUsersForRole(java.lang.String name, java.lang.String... domain)
name
- the role.domain
- the role's domain.public java.util.List<java.util.List<java.lang.String>> getImplicitPermissionsForUser(java.lang.String user, java.lang.String... domain)
getPermissionsForUser("alice") can only get: [["alice", "data2", "read"]]. But getImplicitPermissionsForUser("alice") will get: [["admin", "data1", "read"], ["alice", "data2", "read"]].
user
- the user.domain
- the user's domain.public java.util.List<java.util.List<java.lang.String>> getNamedImplicitPermissionsForUser(java.lang.String pType, java.lang.String user, java.lang.String... domain)
GetImplicitPermissionsForUser("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").
pType
- the name policy.user
- the user.domain
- the user's domain.public java.util.List<java.util.List<java.lang.String>> getImplicitPermissionsForUserInDomain(java.lang.String user, java.lang.String domain)
user
- the user.domain
- the domain.public java.util.List<java.lang.Boolean> batchEnforce(java.util.List<java.util.List<java.lang.String>> rules)
rules
- the rules.public java.util.List<java.lang.Boolean> batchEnforceWithMatcher(java.lang.String matcher, java.util.List<java.util.List<java.lang.String>> rules)
matcher
- the custom matcher.rules
- the rules.public void buildIncrementalRoleLinks(Model.PolicyOperations op, java.lang.String ptype, java.util.List<java.util.List<java.lang.String>> rules)
op
- Policy operations.ptype
- policy type.rules
- the rules.Copyright © 2017–2024. All rights reserved.