PDA

View Full Version : java.security.AccessControlException: access denied


ld_pvl
06-25-2009, 07:15 AM
I'm writing a GUI Applet Application which is going to be run on a server. I have tested the program occasionally and it has been working fine. Lately, I needed to add another function which would allow the program to read some data from a CSV file which is stored in the same folder as my application jar file on the same server.

In my knowledge, applet applications are allowed to read files that are located on the same server. But in my case it does not work. Please help, thank you.

java.security.AccessControlException: access denied (java.io.FilePermission Default.csv read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
at java.io.FileInputStream.<init>(FileInputStream.java:100)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at java.io.FileReader.<init>(FileReader.java:41)
at fdrs.FX.DefaultValues.GetDefaultValuesArray(DefaultValues.java:16)
at fdrs.FX.DefaultValues.SpotValue(DefaultValues.java:57)
at fdrs.FX.Main.GenerateDefaultValuesforTables(Main.java:137)
at fdrs.FX.Main.<init>(Main.java:61)
at fdrs.MainApplet.init(MainApplet.java:11)
at sun.applet.AppletPanel.run(AppletPanel.java:424)
at java.lang.Thread.run(Thread.java:619)

Jimbooo
06-27-2009, 06:19 PM
I guess you'll have to show some of your code. We're kinda blind here.

ckeyrouz
07-02-2009, 06:39 PM
Applets are a bit tricky to trifle with unless you know what you are doing.
Applets contain lots of security issue and one of them is not allowing the Applet to access any file outside its context which means Applets are not allowed to access any file from the Operating System or any physical file on the hard drive.

But there is a solution for it.
under your jre/security folder there are 3 files:
java.policy
java.security
javaws.policy

check them and in the last file you can add some security rules but this is not very healthy since any change in the java policy might let other applets access system files.

The best solution is to generate a certificate key and sign the applet with it, just go to the following url and you will find what you need there:

http://www.captain.at/programming/java/

Hope it will be helpful and keep us posted with the result.
Thanks