JDK-6895411 : Regression: Applets are not honoring the remote policy URL
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u18
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-10-26
  • Updated: 2010-09-08
  • Resolved: 2010-06-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6u21 b02Fixed
Related Reports
Relates :  
Description
Applets are ignoring the permissions specified inside the remote polciy URL. 

Steps to reproduce:
1) Install JRE 6u18-b04
2) Set following permissions inside the .java.policy file inside the <user_home>
grant {
  permission java.lang.RuntimePermission "usePolicy";
};
3) Set "policy.url.2" inside <jre_home>/lib/security/java.security as follows
policy.url.2=http://nicole1.sfbay.sun.com:8080/plugin_tests/usePolicy/sqe.policy

Permissions inside the remote policy file are :
grant {
  permission java.security.AllPermission;
};


4) Try loading the following signed applet:
http://sqeweb.sfbay.sun.com/deployment2/jitu/plug-bug/security/file/exec/AppletFullJavaVersion.html
It should get loaded without any security pop-up. If security pop-up is there then bug is reproduced

5) Try loading the following unsigned applet. It should not throw any security exception
http://sqeweb.sfbay.sun.com/deployment2/jitu/plug-bug/security/file/exec/AppletFullJavaVerUnsigned.html
If security exception is thrown then bug is reproduced

Comments
EVALUATION The issue is that we are calling into createTempFile recursively as following: Initializing the temporary file code initializes the security policy code. Initializing the security policy code in this case loads a remote URL. Loading a remote URL with deployment URL handler installed initializes the temporary file code. Wherever we choose to start in the circle, we will still have the circular initi alization problem. The fix is to initializing the security policy before installing the deployment URL handler. The trick is calling java.security.Policy.getPolicy() will initiali zes the security system.
18-03-2010

EVALUATION This is caused by createTempFile() is called recursively, will try to avoid that when trace is disabled, target to 6u20.
05-11-2009

EVALUATION I reproduce it in my machine, but not as consistent SQE, here are what the conditions to reproduce this bug: 1. Clean up cache (you don't need to delete cache dir, just delete cache using Java control panel button). 2. Disable tracing in Java control panel too. 3. Run your testcase, you will see the security popup. The reason is that it failed to pass the policy file sqe.policy, it throw a NullPointerException. Now run the same applet again, it works this time. Here are the exceptions: policy: reading http://nicole1.sfbay.sun.com:8080/plugin_tests/usePolicy/sqe.policy policy: error parsing http://nicole1.sfbay.sun.com:8080/plugin_tests/usePolicy/sqe.policy policy: java.lang.NullPointerException java.lang.NullPointerException at java.io.File.generateFile(Unknown Source) at java.io.File.createTempFile(Unknown Source) at java.io.File.createTempFile(Unknown Source) at com.sun.deploy.cache.DeployCacheRequest$1.run(DeployCacheHandler.java:435) at java.security.AccessController.doPrivileged(Native Method) at com.sun.deploy.cache.DeployCacheRequest.<init>(DeployCacheHandler.java:431) at com.sun.deploy.cache.DeployCacheHandler.put(DeployCacheHandler.java:285) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at java.net.URL.openStream(Unknown Source) at sun.security.util.PolicyUtil.getInputStream(Unknown Source) at sun.security.provider.PolicyFile.init(Unknown Source) at sun.security.provider.PolicyFile.access$400(Unknown Source) at sun.security.provider.PolicyFile$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.security.provider.PolicyFile.initPolicyFile(Unknown Source) at sun.security.provider.PolicyFile.initPolicyFile(Unknown Source) at sun.security.provider.PolicyFile.init(Unknown Source) at sun.security.provider.PolicyFile.<init>(Unknown Source) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at java.security.Policy.getPolicyNoCheck(Unknown Source) at java.security.Policy.getPolicy(Unknown Source) at sun.security.jca.Providers$1.run(Unknown Source) at sun.security.jca.Providers$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.security.jca.Providers.getProviderList(Unknown Source) at java.security.SecureRandom.getPrngAlgorithm(Unknown Source) at java.security.SecureRandom.getDefaultPRNG(Unknown Source) at java.security.SecureRandom.<init>(Unknown Source) at java.io.File$LazyInitialization.<clinit>(Unknown Source) at java.io.File.createTempFile(Unknown Source) at java.io.File.createTempFile(Unknown Source) at com.sun.deploy.cache.DeployCacheRequest$1.run(DeployCacheHandler.java:435) at java.security.AccessController.doPrivileged(Native Method) at com.sun.deploy.cache.DeployCacheRequest.<init>(DeployCacheHandler.java:431) at com.sun.deploy.cache.DeployCacheHandler.put(DeployCacheHandler.java:285) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at sun.plugin.PluginURLJarFileCallBack.downloadJAR(Unknown Source) at sun.plugin.PluginURLJarFileCallBack.access$000(Unknown Source) at sun.plugin.PluginURLJarFileCallBack$2.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.plugin.PluginURLJarFileCallBack.retrieve(Unknown Source) at sun.net.www.protocol.jar.URLJarFile.retrieve(Unknown Source) at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source) at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source) at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source) at sun.plugin.net.protocol.jar.CachedJarURLConnection.connect(Unknown Source) at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFileInternal(Unknown Source) at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFile(Unknown Source) at sun.misc.URLClassPath$JarLoader.getJarFile(Unknown Source) at sun.misc.URLClassPath$JarLoader.access$600(Unknown Source) at sun.misc.URLClassPath$JarLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.misc.URLClassPath$JarLoader.ensureOpen(Unknown Source) at sun.misc.URLClassPath$JarLoader.<init>(Unknown Source) at sun.misc.URLClassPath$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.misc.URLClassPath.getLoader(Unknown Source) at sun.misc.URLClassPath.getLoader(Unknown Source) at sun.misc.URLClassPath.getResource(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) policy: reading file://C:/Documents%20and%20Settings/jitu/Application%20Data/Sun/Java/Deployment/security/java.policy
02-11-2009