aspose file tools*
The moose likes Applets and the fly likes AccessControlException is thrown when a signed applet is trying to read a file from local system Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "AccessControlException is thrown when a signed applet is trying to read a file from local system" Watch "AccessControlException is thrown when a signed applet is trying to read a file from local system" New topic
Author

AccessControlException is thrown when a signed applet is trying to read a file from local system

Rnk msra
Greenhorn

Joined: Apr 02, 2009
Posts: 5
Guys,

Please help me ..i am challenged...I am trying to read a .MIDI file,from an Applet(a signed one)
..I dont know where it is going wrong...

May be I might not be creating the policy file correctly or failing to access the URL...or point to policy file correctly...
Is there any way to skip creating policy files by using AccessController.doPrivileged()


here 's the stack trace..

java.security.AccessControlException: access denied (java.io.FilePermission C:\Documents and Settings\milind\GF1_P123 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.FileInputStream.<init>(Unknown Source)
at com.sun.media.sound.RmfFileReader.getMidiFileFormat(Unknown Source)
at javax.sound.midi.MidiSystem.getMidiFileFormat(Unknown Source)
at org.jfugue.Player.loadMidi(Player.java:402)
at AccessDLLApplet.processMidi(AccessDLLApplet.java:143)
at AccessDLLApplet$2.run(AccessDLLApplet.java:78)
at AccessDLLApplet$2.run(AccessDLLApplet.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at AccessDLLApplet.loadMidiString(AccessDLLApplet.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.invoke.JSInvoke.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
M K Rayapudi
Ranch Hand

Joined: Feb 19, 2007
Posts: 157
check this, it may help


R6i
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41888
    
  63
If the applet is signed, then you don't need to change any policy files - the applet will run without restrictions anyway. You may have to put the code into a privileged section, though; see http://faq.javaranch.com/java/HowCanAnAppletReadFilesOnTheLocalFileSystem for an example of that.


Ping & DNS - my free Android networking tools app
Rnk msra
Greenhorn

Joined: Apr 02, 2009
Posts: 5
I doubt , signing process that I am following is not correct .

Can you tell me the correct steps to sign an applet , I am also using Jfugue.jar capabilities in it.

Thanks in advance!

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41888
    
  63
If you're using 3rd party libraries, then those need to be signed as well. The concrete steps are described in one of the pages linked from the page I mentioned above.
Rnk msra
Greenhorn

Joined: Apr 02, 2009
Posts: 5
Hi Guys


Finally I got the solution ..!

I tried accessing my local resources through init() inside Applet , it worked . Any thread that you launch through init() will be able to access local resources. No need of using java.security.AccessController to get any extra privileges.

The most important thing is to keep all the relevant classes(third party jars etc) in a single jar and that should be signed properly.


Please correct me if am wrong.

Thanks for all your support.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41888
    
  63
Good to hear you got things working.
The most important thing is to keep all the relevant classes(third party jars etc) in a single jar and that should be signed properly.

There's no need to put all classes into a single jar file - it's perfectly possible to use multiple jar files, as long as all of them are signed.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AccessControlException is thrown when a signed applet is trying to read a file from local system