Class AdapterMock

  • All Implemented Interfaces:
    Adapter

    public class AdapterMock
    extends java.lang.Object
    implements Adapter
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String errorValue  
      private java.lang.String filePath  
    • Constructor Summary

      Constructors 
      Constructor Description
      AdapterMock​(java.lang.String filePath)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      java.lang.Exception getMockErr()  
      void loadPolicy​(Model model)
      loadPolicy loads all policy rules from the storage.
      private void loadPolicyFile​(Model model, Helper.loadPolicyLineHandler<java.lang.String,​Model> handler)  
      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.
      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.
      void savePolicy​(Model model)
      savePolicy saves all policy rules to the storage.
      void setMockErr​(java.lang.String errorToSet)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • filePath

        private java.lang.String filePath
      • errorValue

        private java.lang.String errorValue
    • Constructor Detail

      • AdapterMock

        public AdapterMock​(java.lang.String filePath)
    • Method Detail

      • setMockErr

        public void setMockErr​(java.lang.String errorToSet)
      • getMockErr

        public java.lang.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​(java.lang.String sec,
                              java.lang.String ptype,
                              java.util.List<java.lang.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​(java.lang.String sec,
                                 java.lang.String ptype,
                                 java.util.List<java.lang.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​(java.lang.String sec,
                                         java.lang.String ptype,
                                         int fieldIndex,
                                         java.lang.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.