public class CoreEnforcer
extends java.lang.Object
| Constructor and Description |
|---|
CoreEnforcer() |
| Modifier and Type | Method and Description |
|---|---|
void |
buildRoleLinks()
buildRoleLinks manually rebuild the
role inheritance relations.
|
void |
clearPolicy()
clearPolicy clears all policy.
|
void |
enableAutoBuildRoleLinks(boolean autoBuildRoleLinks)
enableAutoBuildRoleLinks controls whether to save a policy rule
automatically to the adapter when it is added or removed.
|
void |
enableAutoSave(boolean autoSave)
enableAutoSave controls whether to save a policy rule automatically to
the adapter when it is added or removed.
|
void |
enableEnforce(boolean enable)
enableEnforce changes the enforcing state of Casbin, when Casbin is
disabled, all access will be allowed by the enforce() function.
|
void |
enableLog(boolean enable)
enableLog changes whether to print Casbin log to the standard output.
|
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).
|
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.
|
Adapter |
getAdapter()
getAdapter gets the current adapter.
|
Model |
getModel()
getModel gets the current model.
|
java.util.Map<java.lang.String,RoleManager> |
getRmMap()
getRmMap gets the current role manager map.
|
boolean |
isAutoNotifyDispatcher() |
boolean |
isAutoNotifyWatcher() |
boolean |
isFiltered()
isFiltered returns true if the loaded policy has been filtered.
|
void |
loadFilteredPolicy(java.lang.Object filter)
loadFilteredPolicy reloads a filtered policy from file/database.
|
void |
loadModel()
loadModel reloads the model from the model CONF file.
|
void |
loadPolicy()
loadPolicy reloads the policy from file/database.
|
static Model |
newModel()
newModel creates a model.
|
static Model |
newModel(java.lang.String text)
newModel creates a model.
|
static Model |
newModel(java.lang.String modelPath,
java.lang.String unused)
newModel creates a model.
|
void |
resetExpressionEvaluator()
Invalidate cache of compiled model matcher expression.
|
void |
savePolicy()
savePolicy saves the current policy (usually after changed with
Casbin API) back to file/database.
|
void |
setAdapter(Adapter adapter)
setAdapter sets the current adapter.
|
void |
setAutoNotifyDispatcher(boolean autoNotifyDispatcher) |
void |
setAutoNotifyWatcher(boolean autoNotifyWatcher) |
void |
setDispatcher(Dispatcher dispatcher)
setDispatcher sets the current dispatcher.
|
void |
setEffector(Effector eft)
setEffector sets the current effector.
|
void |
setModel(Model model)
setModel sets the current model.
|
void |
setRoleManager(RoleManager rm)
setRoleManager sets the current role manager for g.
|
void |
setRoleManager(java.lang.String ptype,
RoleManager rm)
setRoleManager sets role manager for ptype.
|
void |
setWatcher(Watcher watcher)
setWatcher sets the current watcher.
|
boolean |
validateEnforce(java.lang.Object... rvals) |
public static Model newModel()
public static Model newModel(java.lang.String text)
text - the model text.public static Model newModel(java.lang.String modelPath, java.lang.String unused)
modelPath - the path of the model file.unused - unused parameter, just for differentiating with
newModel(String text).public void loadModel()
public Model getModel()
public void setModel(Model model)
model - the model.public Adapter getAdapter()
public void setAdapter(Adapter adapter)
adapter - the adapter.public void setWatcher(Watcher watcher)
watcher - the watcher.public void setDispatcher(Dispatcher dispatcher)
dispatcher - jCasbin dispatcherpublic java.util.Map<java.lang.String,RoleManager> getRmMap()
public void setRoleManager(RoleManager rm)
rm - the role manager.public void setEffector(Effector eft)
eft - the effector.public void clearPolicy()
public void loadPolicy()
public void loadFilteredPolicy(java.lang.Object filter)
filter - the filter used to specify which type of policy should be loaded.public boolean isFiltered()
public void savePolicy()
public void setRoleManager(java.lang.String ptype,
RoleManager rm)
ptype - the policy type, can be "g", "g2", "g3", ..rm - the role manager.public void enableEnforce(boolean enable)
enable - whether to enable the enforcer.public void enableLog(boolean enable)
enable - whether to enable Casbin's log.public void enableAutoSave(boolean autoSave)
autoSave - whether to enable the AutoSave feature.public void enableAutoBuildRoleLinks(boolean autoBuildRoleLinks)
autoBuildRoleLinks - whether to automatically build the role links.public void buildRoleLinks()
public boolean enforce(java.lang.Object... rvals)
rvals - the request needs to be mediated, usually an array
of strings, can be class instances if ABAC is used.public boolean enforceWithMatcher(java.lang.String matcher,
java.lang.Object... rvals)
matcher - the custom matcher.rvals - the request needs to be mediated, usually an array
of strings, can be class instances if ABAC is used.public boolean validateEnforce(java.lang.Object... rvals)
public void resetExpressionEvaluator()
public boolean isAutoNotifyWatcher()
public void setAutoNotifyWatcher(boolean autoNotifyWatcher)
public boolean isAutoNotifyDispatcher()
public void setAutoNotifyDispatcher(boolean autoNotifyDispatcher)
Copyright © 2017–2021. All rights reserved.