By the time you get to a method in java the class has already been loaded so you couldn't do it that way.
What is wrong with the current verification that the VM already does?
I believe you can sign the jar.
If that isn't sufficient then you will need to use a custom class loader.
> How do not permit that a code not signed by a
> specified organization be executed by the JVM ?
Again impossible.
Although I suppose you could create your own VM.
> Custom ClassLoader ?
> I need some mechanism in the JVM.
If and only if you have an application running, then that application can do certain things, for instance use custom class loaders and security managers.
A class loader lets you verify the class. And you can do anything you want to do that.
The security manager lets you verify the methods that are called.
Note that you can't verify the security manager (chicken and the egg.)
Nor, without a custom VM, can you verify all applications, only your own.
Note finally if you are trying to create a turnkey system then you need to use another language besides java, at least for most of the security/access work. (Because this is the only thing I can guess you are attempting via this.)
My solution assumes an initial secure point. Thus I do not have a chicken and egg problem. But this is another problem.
Do you know an example of ClassLoader that verify the signature of a class file before loading that class?
I need to impede that a class not signed by my organization can be executed.
Tank you very much.
You can ask for information about an arbitrary class, eg. where it was loaded from, and what certificates it has.
If you assume a secure starting point, then you could potentially save the URL and certs of that object/class, and compare it against other classes whenever you want.
Object yourArbitraryObject = new String();
java.security.CodeSource codeSource = yourArbitraryObject.getClass().getProtectionDomain().getCodeSource();
URL classLoadedFrom = codeSource.getLocation();
java.security.cert.Certificate[] classCerts = codeSource.getCertificates();
regards,
Owen