Class FileBasedClusterNodeFirewall

java.lang.Object
org.apache.nifi.cluster.firewall.impl.FileBasedClusterNodeFirewall
All Implemented Interfaces:
ClusterNodeFirewall

public class FileBasedClusterNodeFirewall extends Object implements ClusterNodeFirewall
A file-based implementation of the ClusterFirewall interface. The class is configured with a file. If the file is empty, then everything is permissible. Otherwise, the file should contain hostnames or IPs formatted as dotted decimals with an optional CIDR suffix. Each entry must be separated by a newline. An example configuration is given below: # hash character is a comment delimiter 1.2.3.4 # exact IP some.host.name # a host name 4.5.6.7/8 # range of CIDR IPs 9.10.11.12/13 # a smaller range of CIDR IPs This class allows for synchronization with an optionally configured restore directory. If configured, then at startup, if the either the config file or the restore directory's copy is missing, then the configuration file will be copied to the appropriate location. If both restore directory contains a copy that is different in content to configuration file, then an exception is thrown at construction time.
  • Field Details

    • config

      private final File config
    • restoreDirectory

      private final File restoreDirectory
    • subnetInfos

      private final Collection<org.apache.commons.net.util.SubnetUtils.SubnetInfo> subnetInfos
    • logger

      private static final org.slf4j.Logger logger
  • Constructor Details

  • Method Details

    • isPermissible

      public boolean isPermissible(String hostOrIp)
      Description copied from interface: ClusterNodeFirewall
      Returns true if the given host or IP is permissible through the firewall; false otherwise. If an IP is given, then it must be formatted in dotted decimal notation.
      Specified by:
      isPermissible in interface ClusterNodeFirewall
      Parameters:
      hostOrIp - host
      Returns:
      true if permissible
    • syncWithRestoreDirectory

      private void syncWithRestoreDirectory() throws IOException
      Throws:
      IOException
    • parseConfig

      private void parseConfig(File config) throws IOException
      Throws:
      IOException