We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › java security
Page Index Toggle Pages: 1
java security (Read 797 times)
java security
Jul 21st, 2005, 4:49pm
 
I've written an applet to view pictures as a slide show. I came across some java code that would allow me create a string array of all .jpg images in a dir rather than hard coding them:

void getPictures(){
 File dir = new File(filePath);  
 picture = dir.list();
 if (picture != null) {
   FilenameFilter filter = new FilenameFilter() {
     public boolean accept(File dir, String name) {
       return name.contains(".jpg");
     }
   };
   picture = dir.list(filter);
   println(picture);
 }
}

this also runs fine from processing.
However, when I run this from a browser I get the error:

java.security.AccessControlException: access denied (java.io.FilePermission <filePath> read)

which stops the applet reading the directory contents.

Is there an easy fix to this security problem? All the searches I've done elsewhere have baffled me with java speak way over my head!

Thanks

PS. How do I post 'code' blocks properly?
Re: java security
Reply #1 - Jul 22nd, 2005, 11:49am
 
Applets can't access the user's hard drive, unless signed.

It's to stop any applet you may find, from loading the contents of your hard drive, and sending them off to the author, for whatever nefarious purposes they may have.

It's all down to the Java "sandbox", that is a java applet can play safely, but only within the bounds of this sandbox. It can load files form it's own .jar file, or communicate with the server that your browser got the file from, but that's it.

If you sign the applet however, you can do more, like when you run it from within processing.
Re: java security
Reply #2 - Jul 25th, 2005, 8:17pm
 
PS. How do I post 'code' blocks properly?

[...] put code here [/...]
Type "code" in between the brackets

Page Index Toggle Pages: 1