How do I grant a site's applet an AllPermission privilege?

Posted by nahsra on Stack Overflow See other posts from Stack Overflow or by nahsra
Published on 2010-05-13T15:34:39Z Indexed on 2010/05/13 19:24 UTC
Read the original article Hit count: 415

Filed under:
|
|
|
|

I'd like to specify certain applets to run with java.security.AllPermission on my computer (for debugging and security testing). However, I don't want to enable all applets that I run to have this permission. So, editing my user Java policy file (which I have ensured is the correct policy file through testing), I try to put this value:

grant codeBase "http://host_where_applet_lives/-" {
 permission java.security.AllPermission;
};

This value fails when the applet tries to do something powerful (create a new Thread, in my case). However, when I put the following value:

grant {
 permission java.security.AllPermission;
};

The applet is able to perform the powerful operation. The only difference is the lack of a codeBase attribute.

An answer to a similar question asked here [1] seemed to suggest (but never show or prove) that AccessController.doPrivileged() calls may be required. To me, this sounds wrong as I don't need that call when I grant the permissions to all applets (the second example I showed). Even if this is a solution, littering the applets I run with AccessController.doPrivileged() calls is not easy or necessarily possible. To top it off, my tests show that this just doesn't work anyway. But I'm happy to hear more ideas around it.

[1] http://stackoverflow.com/questions/1751412/cant-get-allpermission-configured-for-intranet-applet-can-anyone-help

© Stack Overflow or respective owner

Related posts about applet

Related posts about java