Class RegexRulesPasswordProvider

  • All Implemented Interfaces:
    org.apache.tika.parser.PasswordProvider

    public class RegexRulesPasswordProvider
    extends Object
    implements org.apache.tika.parser.PasswordProvider
    Password provider for Extracting request handler which finds correct password based on file name matching against a list of regular expressions. The list of passwords is supplied in an optional Map. If an explicit password is set, it will be used.
    • Constructor Detail

      • RegexRulesPasswordProvider

        public RegexRulesPasswordProvider()
    • Method Detail

      • getPassword

        public String getPassword​(org.apache.tika.metadata.Metadata meta)
        Specified by:
        getPassword in interface org.apache.tika.parser.PasswordProvider
      • parseRulesFile

        public static LinkedHashMap<Pattern,​String> parseRulesFile​(InputStream is)
        Parses rule file from stream and returns a Map of all rules found
        Parameters:
        is - input stream for the file
      • parse

        public void parse​(InputStream is)
        Initialize rules through file input stream. This is a convenience for first calling setPasswordMap(parseRulesFile(is)).
        Parameters:
        is - the input stream with rules file, one line per rule on format regex=password
      • getExplicitPassword

        public String getExplicitPassword()
        Gets the explicit password, if set
        Returns:
        the password, or null if not set
      • setExplicitPassword

        public void setExplicitPassword​(String explicitPassword)
        Sets an explicit password which will be used instead of password map
        Parameters:
        explicitPassword - the password to use
      • resetExplicitPassword

        public void resetExplicitPassword()
        Resets explicit password, so that map will be used for lookups