Posted By:
Anonymous
Posted On:
Monday, May 7, 2001 12:45 AM
I followed the Sun's tutorial on granting write access to an applet. I tried it out but it doesn't work. Here's what I did: I used the policytool.exe program to create a new policy file in the directory C:Test. Here's the content of the file created: grant codeBase "http://java.sun.com/docs/books/tutorial/security1.2/tour1/example-1dot2/" { permission java.io.FilePermission "writetest", "write"; }; After that I added this line to the security properties file, java.security, in the directory C:jdk1.3jrelibsecurity, as well as the java.security file in the directory C:Program FilesJavaSoftJRE1.3.0_02libsecurity: policy.url.3=file:/C:/Test/mypolicy
More>>
I followed the Sun's tutorial on granting write access to an applet. I tried it out but it doesn't work. Here's what I did:
I used the policytool.exe program to create a new policy file in the directory C:Test. Here's the content
of the file created:
grant codeBase "http://java.sun.com/docs/books/tutorial/security1.2/tour1/example-1dot2/" {
permission java.io.FilePermission "writetest", "write";
};
After that I added this line to the security properties file, java.security, in the directory C:jdk1.3jrelibsecurity,
as well as the java.security file in the directory C:Program FilesJavaSoftJRE1.3.0_02libsecurity:
policy.url.3=file:/C:/Test/mypolicy
This is supposed to grant write access to an applet in the URL http://java.sun.com/docs/books/tutorial/security1.2/tour1/example-1dot2/WriteFile.html. The applet will write to a file named
"writetest" in the current directory.
However, it doesn't work. The applet throws a security exception both in Netscape and Internet Explorer.
My questions are:
(1) Why doesn't it work?
(2) There are two identical security properties files in the C:jdk1.3jrelibsecurity and C:Program
FilesJavaSoftJRE1.3.0_02libsecurity directories. Which is the one that is actually used?
(3) How do I specify in the policy file in order to let an applet read and write any file in my system?
<<Less