Problem granting read FilePermission to an applet
I'm having problems trying to give read FilePermission to an applet under jre version 1.4.2_08 on a Win98 system. I had previously been using jre version 1.3.1 and had no problems using the applet to read files. I had setup the .java.policy file using policytool. When I installed jre 1.4.2_08 the applet no longer works. It gets access denied FilePermission ... read errors:
java.security.AccessControlException: access denied (java.io.FilePermission E:\Miscellaneous\SailJazz read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.File.exists(Unknown Source)
at java.lang.Thread.run(Unknown Source)
For testing I have two browsers: NS 7.02 and IE 6.0. I have left NS using jre 1.3.1 plugin for its applets. It continues to work fine. When I configure IE to use jre 1.3.1 it works. When I change IE to use 1.4.2 it gets the access denied. FilePermission ... read error.
The CodeBase is set to a folder above where the jar file resides: file:/E:/Miscellaneous/-
I have several jar files within subfolders that use that same CodeBase hence the ending -
The target is set to the folder above the subfolders that the applet is to read: E:/Miscellaneous/SailJazz
I have other targets with an ending / that also don't work.
Have there been changes to the policy file contents or usage between 1.3.1 and 1.4.2?
How does one find the problem? My prior experiences trouble shooting has been the shotgun approach: keep trying all possible combinations until it works. Surely there is a better way. Any ideas?
Please read the question!
thanks for the response.
My applet works fine using the jre version 1.3.1. It is a local application that does NOT involve a host. The applet read files from my harddrive.
When I installed jre version 1.4.2 I get the FilePermission read error.
My question(again) is: What's changed with jre version 1.4.2 that an applet that works with 1.3.1 does NOT work with 1.4.2??? How do I get my applet to work with 1.4.2???
Description of application
I didn't explain the application as I don't think its relevant to the problem.
I don't see how using a Panel or any other GUI can affect Security. Could you please explain the relationship?
Remember the Applet works with 1.3. What has changed and what do I need to change to get it work with 1.4?
But since you want to change my design, I'll explain it a bit.
An example might be the Java Tutorial which can be downloaded in a zip file and unzipped to files on your harddrive. I rewrite the search page to use my applet and am able to search all the pages of the tutorial for ...
Keep the logics, change GUI strategy
I have no intent on changing your logical design, what I suggested was that you
could change it into an application, that is, make it a Panel extension instead
of an Applet extension, Applet is a Panel descendant with web capabilities,
if you dont utilize any of those, and you just want to download pages from
web, you could just as well make it into a Panel and supply it with a main
method where you wrap the Panel (previously known as Applet) in a Frame.
I don't know the specifics of the security upgrades that has been done
after the java version you use became an oldie....
But, since you have explained your task now, I think maybe the little
application I have attatched here can be useful. You should at least check it
out. It is an app that performs multiple simultaneous downloads of web site content.
The SiteConn class contained here can easily be modified to perform
bytestream download for zip file retrieval.
Change design? Or correct the policy?
Thanks again for the response.
I'm not sure why I should reinstall Java 1.3. I have jre 1.3 installed and am able to use it with both the NS and with IE browsers. I would like to move on to jre 1.4 but am unable to give FilePermission.
The documentation leads me to believe that it is possible to give an applet permission to read all the files in a directory (and in subdirectories???) So I have designed an application that requires that capability. And it works with jre 1.3.
The Tutorial gives an example:
Type the following in the text box to the right of the list labeled Target Name to specify all files in the C:\TestData\ directory:
However, I am not able to get that to work with either 1.3 or 1.4?
The general question is: How do you debug incorrect policy statements?
It's a problem similiar to the problem with incorrect classpath. Nothing works until you get it correct. Beginers often have to change and change and change it until they understand how it works and can corretly code it. I still have had problems and have written some tools to help me diagnose the problem.
Has anyone found such a technique with the policy files?