I'm writing a security manager that I want to grant all permission to
classes loaded by my loader or JRE classes, otherwise no permissions.
My problem is that in checkPermission() , the calls to get class
loaders (of thread / class context) cause checkPermission() calls
themselves and I get an infinite loop.
I see the secmanager methods currentClassLoader() &
currentLoadedClass() that are related to what I'm trying to do, but
they are deprecated and it is recommended to use checkPermission to
somehow acclomplish the same type of check.
I must be missing something here -- any ideas on how to override
checkPermission() and use methods in there that trigger calls to
checkPermission themselves? And/or a better strategy to accomplish
my main goal?
TIA John
Thomas Hawtin - 23 Mar 2006 02:39 GMT
> I'm writing a security manager that I want to grant all permission to
> classes loaded by my loader or JRE classes, otherwise no permissions.
>
> My problem is that in checkPermission() , the calls to get class
> loaders (of thread / class context) cause checkPermission() calls
> themselves and I get an infinite loop.
Not really my area, but: I think you want to be looking at
java.security.SecureClassLoader. Particularly getPermissions. Also
java.net.URLClassLoader. Add permissions to classes (indirectly) and let
AccessController do its stuff.
Extending SecurityManager is usually about restricting permissions (see
sun.applet.AppletSecurity).
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/