Can't catch SecurityException?

Hello,

I have an photo book Applet that I use to search and download images, it mostly works but sometimes will fail with a SecurityException when it attempts to download certain images.

I've tried this in a try { } catch { } but it just ignores it and still throws the SecurityException.

I have not altered my security or permissions, and am running the applet on my computer rather than on a site.

I've read about 'SecurityManager' and some AllPermission setting but am not sure how that fits in or to implement it?

Any help would be fantastic,thanks!

[595 byte] By [not_terrya] at [2007-11-27 1:18:04]
# 1

Have you looked at the calling stacks for the SecurityException? Maybe it does not come from your own code therefore you cannot catch it.

As for AllPermission things, read http://java.sun.com/javase/6/docs/technotes/guides/plugin/developer_guide/security.html to find out how to sign an applet.

wangwja at 2007-7-11 23:53:49 > top of Java-index,Security,Signed Applets...
# 2
Hey,It doesn't - you are right... is there a quick way to just allow all permissions, no matter what, in Java? I looked at AllPermissions and SecurityManager but am not sure how that fits in...Thanks
not_terrya at 2007-7-11 23:53:49 > top of Java-index,Security,Signed Applets...
# 3

The easiest way is to sign the applet:

1. pack the class into a jar

2. use keytool to generate a keypair

3. sign the jar with the keypair

Every time you want to run a signed applet, the browser will ask you if you trust it. Since this applet is written by yourself, I suppose you can safely trust it and then it will have AllPermission.

wangwja at 2007-7-11 23:53:49 > top of Java-index,Security,Signed Applets...
# 4
Hey,Ok - cool -thanks I will give that a shot :-) Is there an easy way through Eclipse...as I kinda use it that way :-(Great stuff so far guys - many, many thanks!
not_terrya at 2007-7-11 23:53:49 > top of Java-index,Security,Signed Applets...
# 5
Sorry, don't know about Eclipse.You can follow the steps in http://java.sun.com/javase/6/docs/technotes/guides/plugin/developer_guide/rsa_signing.html. Note that you needn't get a real certificate, you can skip the 2,3,4 of keytool.
wangwja at 2007-7-11 23:53:49 > top of Java-index,Security,Signed Applets...