Class IPFilterImpl

  • All Implemented Interfaces:
    IPFilter

    public class IPFilterImpl
    extends java.lang.Object
    implements IPFilter
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected IpFilter filter  
    • Constructor Summary

      Constructors 
      Constructor Description
      IPFilterImpl()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addRange​(IPRange range)
      Adds a range.
      void ban​(java.lang.String IPAddress, java.lang.String text)
      Explicitly bans an address
      void block​(java.lang.String IPAddress)
      Explicitly blocks an address
      IPRange createAndAddRange​(java.lang.String description, java.lang.String start_ip, java.lang.String end_ip, boolean this_session_only)
      Creates, validates and adds a range
      IPRange createRange​(int address_type, boolean this_session_only)
      creates a new range but *doesn't* add it to the list.
      IPBanned[] getBannedIPs()
      Gets the current list of b addresses
      IPBlocked[] getBlockedIPs()
      Gets the current list of blocked addresses
      java.io.File getFile()
      Gets the file name used for persistent ranges
      boolean getInRangeAddressesAreAllowed()
      The filter either allows defined ranges to be allowed or denied access
      long getLastUpdateTime()
      Gets the last time the filter set was updated or marked as up to date
      int getNumberOfBannedIPs()
      returns length of banned ip list
      int getNumberOfBlockedIPs()
      returns length of blocked ip list
      int getNumberOfRanges()
      returns length of ranges list
      IPRange[] getRanges()
      Gets the current set of defined IP ranges
      boolean isEnabled()
      Test if ipfilter is enabled or not
      boolean isInRange​(java.lang.String IPAddress)
      Checks an address to see if its in an allowed range
      void reload()
      Reloads the ip filter from the config file (obtainable using "getFile")
      void removeRange​(IPRange range)
      Remove a range
      void save()
      saves current setting to file given by getFile
      void setEnabled​(boolean enabled)
      change the enabled status
      void setInRangeAddressesAreAllowed​(boolean b)
      Set the behaviour of the filter to either allow or deny access for defined ranges
      void unban​(java.lang.String IPAddress)
      Removes a ban on an address
      • Methods inherited from class java.lang.Object

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

      • IPFilterImpl

        public IPFilterImpl()
    • Method Detail

      • getFile

        public java.io.File getFile()
        Description copied from interface: IPFilter
        Gets the file name used for persistent ranges
        Specified by:
        getFile in interface IPFilter
        Returns:
      • getRanges

        public IPRange[] getRanges()
        Description copied from interface: IPFilter
        Gets the current set of defined IP ranges
        Specified by:
        getRanges in interface IPFilter
        Returns:
      • getNumberOfRanges

        public int getNumberOfRanges()
        Description copied from interface: IPFilter
        returns length of ranges list
        Specified by:
        getNumberOfRanges in interface IPFilter
        Returns:
      • getNumberOfBlockedIPs

        public int getNumberOfBlockedIPs()
        Description copied from interface: IPFilter
        returns length of blocked ip list
        Specified by:
        getNumberOfBlockedIPs in interface IPFilter
        Returns:
      • getNumberOfBannedIPs

        public int getNumberOfBannedIPs()
        Description copied from interface: IPFilter
        returns length of banned ip list
        Specified by:
        getNumberOfBannedIPs in interface IPFilter
        Returns:
      • isInRange

        public boolean isInRange​(java.lang.String IPAddress)
        Description copied from interface: IPFilter
        Checks an address to see if its in an allowed range
        Specified by:
        isInRange in interface IPFilter
        Returns:
      • createRange

        public IPRange createRange​(int address_type,
                                   boolean this_session_only)
        Description copied from interface: IPFilter
        creates a new range but *doesn't* add it to the list. Use the add method to add it
        Specified by:
        createRange in interface IPFilter
        Parameters:
        address_type - - 1= ipv4, 2=ipv6
        this_session_only - // not persisted if "this_session_only" is true
        Returns:
      • addRange

        public void addRange​(IPRange range)
        Description copied from interface: IPFilter
        Adds a range. Only ranges created with "create" above can be added
        Specified by:
        addRange in interface IPFilter
      • createAndAddRange

        public IPRange createAndAddRange​(java.lang.String description,
                                         java.lang.String start_ip,
                                         java.lang.String end_ip,
                                         boolean this_session_only)
        Description copied from interface: IPFilter
        Creates, validates and adds a range
        Specified by:
        createAndAddRange in interface IPFilter
        this_session_only - not persisted if true
        Returns:
        new range or null if invalid
      • getBlockedIPs

        public IPBlocked[] getBlockedIPs()
        Description copied from interface: IPFilter
        Gets the current list of blocked addresses
        Specified by:
        getBlockedIPs in interface IPFilter
        Returns:
      • block

        public void block​(java.lang.String IPAddress)
        Description copied from interface: IPFilter
        Explicitly blocks an address
        Specified by:
        block in interface IPFilter
      • getBannedIPs

        public IPBanned[] getBannedIPs()
        Description copied from interface: IPFilter
        Gets the current list of b addresses
        Specified by:
        getBannedIPs in interface IPFilter
        Returns:
      • ban

        public void ban​(java.lang.String IPAddress,
                        java.lang.String text)
        Description copied from interface: IPFilter
        Explicitly bans an address
        Specified by:
        ban in interface IPFilter
      • unban

        public void unban​(java.lang.String IPAddress)
        Description copied from interface: IPFilter
        Removes a ban on an address
        Specified by:
        unban in interface IPFilter
      • isEnabled

        public boolean isEnabled()
        Description copied from interface: IPFilter
        Test if ipfilter is enabled or not
        Specified by:
        isEnabled in interface IPFilter
        Returns:
      • setEnabled

        public void setEnabled​(boolean enabled)
        Description copied from interface: IPFilter
        change the enabled status
        Specified by:
        setEnabled in interface IPFilter
      • getInRangeAddressesAreAllowed

        public boolean getInRangeAddressesAreAllowed()
        Description copied from interface: IPFilter
        The filter either allows defined ranges to be allowed or denied access
        Specified by:
        getInRangeAddressesAreAllowed in interface IPFilter
        Returns:
      • setInRangeAddressesAreAllowed

        public void setInRangeAddressesAreAllowed​(boolean b)
        Description copied from interface: IPFilter
        Set the behaviour of the filter to either allow or deny access for defined ranges
        Specified by:
        setInRangeAddressesAreAllowed in interface IPFilter
      • getLastUpdateTime

        public long getLastUpdateTime()
        Description copied from interface: IPFilter
        Gets the last time the filter set was updated or marked as up to date
        Specified by:
        getLastUpdateTime in interface IPFilter
        Returns: