Class AdapterMock

java.lang.Object
org.casbin.jcasbin.persist.file_adapter.AdapterMock
All Implemented Interfaces:
Adapter

public class AdapterMock extends Object implements Adapter
  • Field Details

    • filePath

      private String filePath
    • errorValue

      private String errorValue
  • Constructor Details

    • AdapterMock

      public AdapterMock(String filePath)
  • Method Details

    • setMockErr

      public void setMockErr(String errorToSet)
    • getMockErr

      public Exception getMockErr()
    • loadPolicy

      public void loadPolicy(Model model)
      Description copied from interface: Adapter
      loadPolicy loads all policy rules from the storage.
      Specified by:
      loadPolicy in interface Adapter
      Parameters:
      model - the model.
    • savePolicy

      public void savePolicy(Model model)
      Description copied from interface: Adapter
      savePolicy saves all policy rules to the storage.
      Specified by:
      savePolicy in interface Adapter
      Parameters:
      model - the model.
    • addPolicy

      public void addPolicy(String sec, String ptype, List<String> rule)
      Description copied from interface: Adapter
      addPolicy adds a policy rule to the storage. This is part of the Auto-Save feature.
      Specified by:
      addPolicy in interface Adapter
      Parameters:
      sec - the section, "p" or "g".
      ptype - the policy type, "p", "p2", .. or "g", "g2", ..
      rule - the rule, like (sub, obj, act).
    • removePolicy

      public void removePolicy(String sec, String ptype, List<String> rule)
      Description copied from interface: Adapter
      removePolicy removes a policy rule from the storage. This is part of the Auto-Save feature.
      Specified by:
      removePolicy in interface Adapter
      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(String sec, String ptype, int fieldIndex, String... fieldValues)
      Description copied from interface: Adapter
      removeFilteredPolicy removes policy rules that match the filter from the storage. This is part of the Auto-Save feature.
      Specified by:
      removeFilteredPolicy in interface Adapter
      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.
    • loadPolicyFile

      private void loadPolicyFile(Model model, Helper.loadPolicyLineHandler<String,Model> handler) throws IOException
      Throws:
      IOException