Class WhiteBlackList

    • Field Detail

      • whitelist

        protected Set<String> whitelist
        Whitelisted items (whole-string match)
      • blacklist

        protected Set<String> blacklist
        Blacklisted items (whole-string match)
      • whitelistPrefixes

        protected List<String> whitelistPrefixes
        Whitelisted items (prefix match)
      • blacklistPrefixes

        protected List<String> blacklistPrefixes
        Blacklisted items (prefix match)
      • whitelistGlobs

        protected Set<String> whitelistGlobs
        Whitelist glob strings. (Serialized to JSON, for logging purposes.)
      • blacklistGlobs

        protected Set<String> blacklistGlobs
        Blacklist glob strings. (Serialized to JSON, for logging purposes.)
      • whitelistPatterns

        protected transient List<Pattern> whitelistPatterns
        Whitelist regexp patterns. (Not serialized to JSON.)
      • blacklistPatterns

        protected transient List<Pattern> blacklistPatterns
        Blacklist regexp patterns. (Not serialized to JSON.)
    • Constructor Detail

      • WhiteBlackList

        public WhiteBlackList()
        Constructor for deserialization.
    • Method Detail

      • addToWhitelist

        public abstract void addToWhitelist​(String str)
        Parameters:
        str - The string to whitelist.
      • addToBlacklist

        public abstract void addToBlacklist​(String str)
        Parameters:
        str - The string to blacklist.
      • isWhitelistedAndNotBlacklisted

        public abstract boolean isWhitelistedAndNotBlacklisted​(String str)
        Parameters:
        str - The string to test.
        Returns:
        true if the string is whitelisted and not blacklisted.
      • isWhitelisted

        public abstract boolean isWhitelisted​(String str)
        Parameters:
        str - The string to test.
        Returns:
        true if the string is whitelisted.
      • whitelistHasPrefix

        public abstract boolean whitelistHasPrefix​(String str)
        Parameters:
        str - The string to test.
        Returns:
        true if the string is a prefix of a whitelisted string.
      • isBlacklisted

        public abstract boolean isBlacklisted​(String str)
        Parameters:
        str - The string to test.
        Returns:
        true if the string is blacklisted.
      • normalizePath

        public static String normalizePath​(String path)
        Remove initial and final '/' characters, if any.
        Parameters:
        path - The path to normalize.
        Returns:
        The normalized path.
      • normalizePackageOrClassName

        public static String normalizePackageOrClassName​(String packageOrClassName)
        Remove initial and final '.' characters, if any.
        Parameters:
        packageOrClassName - The package or class name.
        Returns:
        The normalized package or class name.
      • pathToPackageName

        public static String pathToPackageName​(String path)
        Convert a path to a package name.
        Parameters:
        path - The path.
        Returns:
        The package name.
      • packageNameToPath

        public static String packageNameToPath​(String packageName)
        Convert a package name to a path.
        Parameters:
        packageName - The package name.
        Returns:
        The path.
      • classNameToClassfilePath

        public static String classNameToClassfilePath​(String className)
        Convert a class name to a classfile path.
        Parameters:
        className - The class name.
        Returns:
        The classfile path (including a ".class" suffix).
      • globToPattern

        public static Pattern globToPattern​(String glob)
        Convert a spec with a '*' glob character into a regular expression. Replaces "." with "\." and "*" with ".*", then compiles a regular expression.
        Parameters:
        glob - The glob string.
        Returns:
        The Pattern created from the glob string.
      • whitelistIsEmpty

        public boolean whitelistIsEmpty()
        Returns:
        true if there were no whitelist criteria added.
      • isSpecificallyWhitelistedAndNotBlacklisted

        public boolean isSpecificallyWhitelistedAndNotBlacklisted​(String str)
        Parameters:
        str - The string to test.
        Returns:
        true if the requested string is specifically whitelisted and not blacklisted, i.e. will not return true if the whitelist is empty, or if the string is blacklisted.
      • isSpecificallyWhitelisted

        public boolean isSpecificallyWhitelisted​(String str)
        Parameters:
        str - The string to test.
        Returns:
        true if the requested string is specifically whitelisted, i.e. will not return true if the whitelist is empty.
      • sortPrefixes

        public void sortPrefixes()
        Need to sort prefixes to ensure correct whitelist/blacklist evaluation (see Issue #167).