
grant {
  permission java.io.FilePermission "${nano.config.tika}${/}-", "read";
  permission java.io.FilePermission "${java.home}${/}-", "read";

  permission java.io.FilePermission "${tika.logs.dir}", "read,write,delete";
  permission java.io.FilePermission "${tika.logs.dir}${/}-", "read,write,delete";
  permission java.io.FilePermission "${java.io.tmpdir}${/}-", "read,write,delete";

  permission java.lang.RuntimePermission "getenv.TIKA_CONFIG";
  permission java.lang.RuntimePermission "getClassLoader";
  permission java.lang.RuntimePermission "setContextClassLoader";
  permission java.lang.RuntimePermission "getStackWalkerWithClassReference";
  permission java.lang.RuntimePermission "getenv.*";

  // JMX is not used, but prints permission errors
  //permission javax.management.MBeanServerPermission "createMBeanServer";
  //permission javax.management.MBeanPermission "*", "queryNames";
  //permission javax.management.MBeanPermission "*", "registerMBean";
  //permission javax.management.MBeanTrustPermission "register";

  permission java.util.PropertyPermission "*", "read,write";
  // these are superfluous because of the general grant
  //permission java.util.PropertyPermission "org.apache.tika.service.error.warn", "read";
  //permission java.util.PropertyPermission "tika.custom-mimetypes", "read";
  //permission java.util.PropertyPermission "tika.config", "read";
  //permission java.util.PropertyPermission "org.apache.cxf.transport.http_jetty.continuations.disable", "read";

  // localhost networking
  permission java.net.SocketPermission "localhost:1024-", "accept,listen,connect,resolve";
  permission java.net.SocketPermission "127.0.0.1:1024-", "accept,listen,connect,resolve";
  permission java.net.SocketPermission "[::1]:1024-", "accept,listen,connect,resolve";

  // Unmapping is not supported, because not all required permissions are given to the Lucene JAR file
  permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
  permission java.lang.RuntimePermission "accessDeclaredMembers";
  permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
};
