Hi,
Evaluating a (pretty old) security tutorial from Sun, I encounter a
very strange problem.
In the example, an applet trying to write a file on local disk is
loaded from the website of Sun, at first without any security policy:
appletviewer http://java.sun.com/docs/books/tutorial/security1.2/tour1/example-1dot2/WriteFil
e.html
As expected, an AccessControlException is thrown
Second, a policyfile called "mypolicy" is created to grant the code
from the Sun-url file-write permission:
grant codeBase "http://java.sun.com/docs/books/tutorial/security1.2/tour1/example-1dot2/"
{
permission java.io.FilePermission "writetest", "write";
};
Now I run the applet specifying this policyfile on the commandline:
appletviewer -J-Djava.security.policy=mypolicy
http://java.sun.com/docs/books/tutorial/security1.2/tour1/example-1dot2/WriteFil
e.html
This works OK, the the applet writes a file to the disk.
But now, I insert the following line in the java.security file:
policy.url.1=file:${java.home}/lib/security/java.policy
policy.url.2=file:${user.home}/.java.policy
#new line added by me...
policy.url.3=file:c:/temp/mypolicy
The policyfile is located in c:/temp. The tutorial suggests that I
should now be able to run the applet WITHOUT specifying the policyfile
on the commandline. But when I try this, an AccessControlException is
thrown again, as if the AppletViewer were not able to locate the the
java.security file.
I use JSK version 1.4.1_03, the java.security file is located at
c:/j2sdk1.4.1_03/jre/lib/security.
So does the appletviewer look in that location for the java./security
file ? Or do i miss someting else ???
Greetz, Klaas
KC Wong - 05 Mar 2004 08:57 GMT
> I use JSK version 1.4.1_03, the java.security file is located at
> c:/j2sdk1.4.1_03/jre/lib/security.
> So does the appletviewer look in that location for the java./security
> file ? Or do i miss someting else ???
When installing JDK, a JRE is always installed under JAVA_HOME/jre. It will
also ask if you'd like to install a "public" JRE. This "public" JRE will be
by default in C:/Program Files/...
It's most likely you were using the "public" JRE.
HTH,
KC