Skip to main content

Loaded classes and security?

2 replies [Last post]
mozste
Offline
Joined: 2008-07-11
Points: 0

Hi all,

I have a question about security and classloader:

While running a signed xlet I load some classes (from a downloaded jar file) using URLClassLoader. Once the classes are loaded, i can correctly find and instantiate them.

To be more precise, i use URLClassLoader.newInstance(URL[], this.getClass().getClassLoader()).

The problems arise every time i try to use a feature that requires either some specific permission or a signed application (like getting buda.root property). Some players raise a SecuriyException.

I don't get why this should happen, since:

1. the Xlet is correctly signed and has its perm file set (if i run the same code from the original loaded classes everything is ok)
2. the loaded jar file is signed with the same keystore of the original Xlet.

Maybe i'm missing some fundamental on security? Please someone shed some light!

Thanks!

Stefano

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
chihiro_saito
Offline
Joined: 2006-11-08
Points: 0

Hi Stefano,

ClassLoader is one of many elements that determine a security domain for a given class file in the java security model. Below is a doc that might help. This is not explicitly stating what "domain" consists of, but Java VM uniquely identifies a class by it's fully qualified classname (ex. "java.lang.String") and it's defining classloader, so using a different classloader for loading a class definitely puts that class into a different domain.

http://java.sun.com/j2se/1.4.2/docs/guide/security/spec/security-spec.do...

So, like you guessed, when you load a class with a new URLClassLoader, then that class is subject to a different security restriction from the original xlet classes by definition.

Java in general provides ways to attach permissions to a dynamically loaded classes (signed applet comes to mind) but I doubt there is a way for BD-J xlet to achieve this. The spec explicitly prohibits custom classloader extension for xlets, and xlets obviously cannot change how Java runtime in the BD player is configured.

If you need to run a downloaded jar in a trusted domain, perhaps one alternative is to add that jar in bdjo's ClassPathExtension and do a VFS update? I believe classes in the extension path, when properly signed, have the same privilege as the classes in the xlet jar.

Best,
Chihiro

mozste
Offline
Joined: 2008-07-11
Points: 0

Hi Chihiro,

your info and suggestions were very helpful.

I confirm classes in extension path have the same privileges as main jar (tested on different players).

Thanks a lot!

Stefano