Enforcer class

Inheritance

Constructors

Enforcer([String modelPath = '', String policyFile = ''])
Initializes an enforcer.
Enforcer.fromModelAndAdapter(Model model, [Adapter? adapter])
factory
Enforcer.fromModelPathAndAdapter(String modelPath, Adapter adapter)
factory
Enforcer.fromModelPathAndPolicyFile(String modelPath, String policyFile)
factory

Properties

adapter Adapter
getter/setter pairinherited
getter/setter pairinherited
autoNotifyDispatcher bool
getter/setter pairinherited
autoNotifyWatcher bool
getter/setter pairinherited
autoSave bool
getter/setter pairinherited
dispatcher Dispatcher?
getter/setter pairinherited
eft Effector
getter/setter pairinherited
fm FunctionMap
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
logger Logger
getter/setter pairinherited
model Model
getter/setter pairinherited
modelCount int
getter/setter pairinherited
modelPath String
getter/setter pairinherited
rm RoleManager
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
watcher Watcher?
getter/setter pairinherited

Methods

addFunction(String name, Function function) → void
addFunction adds a customized function. name the name of the new function. function the function.
inherited
addGroupingPolicy(List<String> params) bool
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.
inherited
addNamedGroupingPolicy(String ptype, List<String> params) bool
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.
inherited
addNamedPolicy(String ptype, List<String> params) bool
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.
inherited
addPermissionForUser(String user, List<String> permission) bool
addPermissionForUser adds a permission for a user or role. Returns false if the user or role already has the permission (aka not affected).
addPoliciesInternal(String sec, String ptype, List<List<String>> rules) bool
addPolicies adds multiple rules to the current policy.
inherited
addPolicy(List<String> params) bool
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.
inherited
addPolicyInternal(String sec, String ptype, List<String> rule) bool
addPolicy adds a rule to the current policy.
inherited
addPolicyList(List<String> params) bool
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.
inherited
addRoleForUser(String user, String role) bool
addRoleForUser adds a role for a user. Returns false if the user already has the role (aka not affected).
addRoleForUserInDomain(String user, String role, String domain) bool
addRoleForUserInDomain adds a role for a user inside a domain. Returns false if the user already has the role (aka not affected).
buildIncrementalRoleLinks provides incremental build the role inheritance relations. op Policy operations. ptype policy type. rules the rules.
inherited
Manually rebuild the role inheritance relations.
inherited
clearPolicy() → void
Clears all policy.
inherited
deletePermission(List<String> permission) bool
deletePermission deletes a permission. Returns false if the permission does not exist (aka not affected).
deletePermissionForUser(String user, List<String> permission) bool
deletePermissionForUser deletes a permission for a user or role. Returns false if the user or role does not have the permission (aka not affected).
deletePermissionsForUser(String user) bool
deletePermissionsForUser deletes permissions for a user or role. Returns false if the user or role does not have any permissions (aka not affected).
deleteRole(String role) → void
deleteRole deletes a role.
deleteRoleForUser(String user, String role) bool
deleteRoleForUser deletes a role for a user. Returns false if the user does not have the role (aka not affected).
deleteRoleForUserInDomain(String user, String role, String domain) bool
deleteRoleForUserInDomain deletes a role for a user inside a domain. Returns false if the user does not have the role (aka not affected).
deleteRolesForUser(String user) bool
deleteRolesForUser deletes all roles for a user. Returns false if the user does not have any roles (aka not affected).
deleteUser(String user) bool
deleteUser deletes a user. Returns false if the user does not exist (aka not affected).
Controls whether to save a policy rule automatically to the adapter when it is added or removed.
inherited
enableAutoSave(bool autoSave) → void
Controls whether to save a policy rule automatically to the adapter when it is added or removed.
inherited
enableEnforce(bool enable) → void
Changes the enforcing state of Casbin, when Casbin is disabled, all access will be allowed by the enforce() function.
inherited
enableLog(bool enable) → void
Changes whether to print Casbin log to the standard output.
inherited
enforce(List rvals) bool
Returns whether a "subject" can access a "object" with the operation "action", input parameters are usually: sub, obj, act.
inherited
getAdapter() Adapter
Returns the current adapter.
inherited
getAllActions() List<String>
getAllActions gets the list of actions that show up in the current policy.
inherited
getAllNamedActions(String ptype) List<String>
GetAllNamedActions gets the list of actions that show up in the current named policy.
inherited
getAllNamedObjects(String ptype) List<String>
getAllNamedObjects gets the list of objects that show up in the current named policy.
inherited
getAllNamedRoles(String ptype) List<String>
getAllNamedRoles gets the list of roles that show up in the current named policy.
inherited
getAllNamedSubjects(String ptype) List<String>
GetAllNamedSubjects gets the list of subjects that show up in the current named policy.
inherited
getAllObjects() List<String>
getAllObjects gets the list of objects that show up in the current policy.
inherited
getAllRoles() List<String>
getAllRoles gets the list of roles that show up in the current policy.
inherited
getAllSubjects() List<String>
getAllSubjects gets the list of subjects that show up in the current policy.
inherited
getDomainIndex(String ptype) int
inherited
getFilteredGroupingPolicy(int fieldIndex, dynamic fieldValues) List<List<String>>
getFilteredGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.
inherited
getFilteredNamedGroupingPolicy(String ptype, int fieldIndex, List<String> fieldValues) List<List<String>>
getFilteredNamedGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.
inherited
getFilteredNamedPolicy(String ptype, int fieldIndex, List<String> fieldValues) List<List<String>>
getFilteredNamedPolicy gets all the authorization rules in the named policy, field filters can be specified.
inherited
getFilteredPolicy(int fieldIndex, List<String> fieldValues) List<List<String>>
getFilteredPolicy gets all the authorization rules in the policy, field filters can be specified.
inherited
getGroupingPolicy() List<List<String>>
getGroupingPolicy gets all the role inheritance rules in the policy.
inherited
getModel() Model
Returns the current model.
inherited
getNamedGroupingPolicy(String ptype) List<List<String>>
getNamedGroupingPolicy gets all the role inheritance rules in the policy.
inherited
getNamedPolicy(String ptype) List<List<String>>
getNamedPolicy gets all the authorization rules in the named policy.
inherited
getPermissionsForUser(String user, List<String> domain) List<List<String>>
getPermissionsForUser gets permissions for a user or role.
getPermissionsForUserInDomain(String user, String domain) List<List<String>>
getPermissionsForUserInDomain gets permissions for a user or role inside a domain.
getPermittedActions(String sub, String obj) Set<String>
getPermittedActions returns all valid actions to specific object for current subject. At present, the execution efficiency of this method is not high. Please avoid calling this method frequently.
inherited
getPolicy() List<List<String>>
getPolicy gets all the authorization rules in the policy.
inherited
getRolesForUser(String name) List<String>
getRolesForUser gets the roles that a user has.
getRolesForUserInDomain(String name, String domain) List<String>
getRolesForUserInDomain gets the roles that a user has inside a domain.
getUsersForRole(String name) List<String>
getUsersForRole gets the users that has a role.
hasGroupingPolicy(List<String> params) bool
hasGroupingPolicy determines whether a role inheritance rule exists. params the "g" policy rule, ptype "g" is implicitly used. return whether the rule exists.
inherited
hasNamedGroupingPolicy(String ptype, List<String> params) bool
hasNamedGroupingPolicy determines whether a named role inheritance rule exists. ptype the policy type, can be "g", "g2", "g3", .. params the "g" policy rule. return whether the rule exists.
inherited
hasNamedPolicy(String ptype, List<String> params) bool
hasNamedPolicy determines whether a named authorization rule exists.
inherited
hasPermissionForUser(String user, List<String> permission) bool
hasPermissionForUser determines whether a user has a permission.
hasPolicy(List<String> params) bool
hasPolicy determines whether an authorization rule exists.
inherited
hasRoleForUser(String name, String role) bool
hasRoleForUser determines whether a user has a role.
isAutoNotifyDispatcher() bool
inherited
isAutoNotifyWatcher() bool
inherited
isFiltered() bool
Returns if the loaded policy has been filtered.
inherited
loadFilteredPolicy(dynamic filter) → void
Reloads a filtered policy from file/database.
inherited
loadModel() → void
Reloads the model from the model CONF file. Because the policy is attached to a model, so the policy is invalidated and needs to be reloaded by calling loadPolicy().
inherited
loadPolicy() → void
Reloads the policy from file/database.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeFilteredGroupingPolicy(int fieldIndex, List<String> fieldValues) bool
removeFilteredGroupingPolicy removes a role inheritance rule from the current policy, field filters can be specified. fieldIndex the policy rule's start index to be matched. fieldValues the field values to be matched, value "" means not to match this field. return succeeds or not.
inherited
removeFilteredNamedGroupingPolicy(String ptype, int fieldIndex, List<String> fieldValues) bool
removeFilteredNamedGroupingPolicy removes a role inheritance rule from the current named policy, field filters can be specified. 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. return succeeds or not.
inherited
removeFilteredNamedPolicy(String ptype, int fieldIndex, List<String> fieldValues) bool
removeFilteredNamedPolicy removes an authorization rule from the current named policy, field filters can be specified.
inherited
removeFilteredPolicy(int fieldIndex, List<String> fieldValues) bool
removeFilteredPolicy removes an authorization rule from the current policy, field filters can be specified.
inherited
removeFilteredPolicyInternal(String sec, String ptype, int fieldIndex, List<String> fieldValues) bool
removeFilteredPolicyInternal removes rules based on field filters from the current policy.
inherited
removeGroupingPolicy(List<String> params) bool
removeGroupingPolicy removes a role inheritance rule from the current policy.
inherited
removeNamedGroupingPolicy(String ptype, List<String> params) bool
removeNamedGroupingPolicy removes a role inheritance rule from the current named policy.
inherited
removeNamedPolicy(String ptype, List<String> params) bool
removeNamedPolicy removes an authorization rule from the current named policy.
inherited
removePoliciesInternal(String sec, String ptype, List<List<String>> rules) bool
removePoliciesInternal removes rules from the current policy.
inherited
removePolicy(List<String> params) bool
removePolicy removes an authorization rule from the current policy.
inherited
removePolicyInternal(String sec, String ptype, List<String> rule) bool
removePolicy removes a rule from the current policy.
inherited
savePolicy() → void
Saves the current policy (usually after changed with Casbin API) back to file/database.
inherited
setAdapter(Adapter adapter) → void
Sets the current adapter.
inherited
setAutoNotifyDispatcher(bool autoNotifyDispatcher) → void
inherited
setAutoNotifyWatcher(bool autoNotifyWatcher) → void
inherited
setDispatcher(Dispatcher dispatcher) → void
Sets the current dispatcher.
inherited
setEffector(Effector eft) → void
Sets the current effector.
inherited
setModel(Model model) → void
setModel sets the current model.
inherited
setRoleManager(RoleManager rm) → void
Sets the current role manager.
inherited
setWatcher(Watcher watcher) → void
Sets the current watcher.
inherited
toString() String
A string representation of this object.
inherited
updateNamedPolicy(String ptype, List<String> params1, List<String> params2) bool
updateNamedPolicy updates an authorization rule to the current named policy.
inherited
updatePermissionForUser(String user, List<String> oldPermission, List<String> newPermission) bool
updatePermissionForUser updates a permission for a user or role. Returns false if the user or role already has the permission (aka not affected).
updatePolicy(List<String> params1, List<String> params2) bool
updatePolicy update an authorization rule to the current policy. params1 the old rule. params2 the new rule. returns succeeds or not.
inherited
updatePolicyInternal(String sec, String ptype, List<String> oldRule, List<String> newRule) bool
updatePolicy updates an authorization rule from the current policy.
inherited
validateEnforce(List<String> rvals) bool
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited