This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rnk msra
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check this, it may help
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rnk msra
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic