Class FileAdapter
- java.lang.Object
-
- org.casbin.jcasbin.persist.file_adapter.FileAdapter
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.ByteArrayInputStreambyteArrayInputStreamprivate java.lang.StringfilePathprivate booleanreadOnly
-
Constructor Summary
Constructors Constructor Description FileAdapter(java.io.InputStream inputStream)FileAdapter is the constructor for FileAdapter.FileAdapter(java.lang.String filePath)FileAdapter is the constructor for FileAdapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPolicy(java.lang.String sec, java.lang.String ptype, java.util.List<java.lang.String> rule)addPolicy adds a policy rule to the storage.private java.util.List<java.lang.String>getModelPolicy(Model model, java.lang.String ptype)voidloadPolicy(Model model)loadPolicy loads all policy rules from the storage.private voidloadPolicyData(Model model, Helper.loadPolicyLineHandler<java.lang.String,Model> handler, java.io.InputStream inputStream)voidremoveFilteredPolicy(java.lang.String sec, java.lang.String ptype, int fieldIndex, java.lang.String... fieldValues)removeFilteredPolicy removes policy rules that match the filter from the storage.voidremovePolicy(java.lang.String sec, java.lang.String ptype, java.util.List<java.lang.String> rule)removePolicy removes a policy rule from the storage.voidsavePolicy(Model model)savePolicy saves all policy rules to the storage.private voidsavePolicyFile(java.lang.String text)
-
-
-
Constructor Detail
-
FileAdapter
public FileAdapter(java.lang.String filePath)
FileAdapter is the constructor for FileAdapter.- Parameters:
filePath- the path of the policy file.
-
FileAdapter
public FileAdapter(java.io.InputStream inputStream)
FileAdapter is the constructor for FileAdapter.- Parameters:
inputStream- the policy file.inputStream
-
-
Method Detail
-
loadPolicy
public void loadPolicy(Model model)
loadPolicy loads all policy rules from the storage.- Specified by:
loadPolicyin interfaceAdapter- Parameters:
model- the model.
-
savePolicy
public void savePolicy(Model model)
savePolicy saves all policy rules to the storage.- Specified by:
savePolicyin interfaceAdapter- Parameters:
model- the model.
-
getModelPolicy
private java.util.List<java.lang.String> getModelPolicy(Model model, java.lang.String ptype)
-
loadPolicyData
private void loadPolicyData(Model model, Helper.loadPolicyLineHandler<java.lang.String,Model> handler, java.io.InputStream inputStream)
-
savePolicyFile
private void savePolicyFile(java.lang.String text)
-
addPolicy
public void addPolicy(java.lang.String sec, java.lang.String ptype, java.util.List<java.lang.String> rule)addPolicy adds a policy rule to the storage.
-
removePolicy
public void removePolicy(java.lang.String sec, java.lang.String ptype, java.util.List<java.lang.String> rule)removePolicy removes a policy rule from the storage.- Specified by:
removePolicyin interfaceAdapter- Parameters:
sec- the section, "p" or "g".ptype- the policy type, "p", "p2", .. or "g", "g2", ..rule- the rule, like (sub, obj, act).
-
removeFilteredPolicy
public void removeFilteredPolicy(java.lang.String sec, java.lang.String ptype, int fieldIndex, java.lang.String... fieldValues)removeFilteredPolicy removes policy rules that match the filter from the storage.- Specified by:
removeFilteredPolicyin interfaceAdapter- Parameters:
sec- the section, "p" or "g".ptype- the policy type, "p", "p2", .. or "g", "g2", ..fieldIndex- the policy rule's start index to be matched.fieldValues- the field values to be matched, value "" means not to match this field.
-
-