I'm using javassist and the ProxyFactory
class to create proxy classes. These are classes which represents the actual classes, but which are not "initialized" (the data they would hold is missing). So no matter which method you invoke on the class you get an Uninitialized
exception. The application where this code runs is started with java web start on clients. The application is signed during build.
I keep running into SecurityException
, but I'm not sure where to begin on this one. Is there a way to "sign" the proxy classes created with javassist?
The closest one I came across was Javaassists and Java Web Start: class sign doesn't match the others classes sign is the same package, but it doesn't use ProxyFactory.
T getProxy(Class<? extends Collection> c, Class[] interfaces) throws ProxyBuilderException {
ProxyFactory factory = new ProxyFactory();
factory.setSuperclass(c);
if (interfaces != null && interfaces.length > 0) {
factory.setInterfaces(interfaces);
}
handler = new MethodHandler() {
@Override
public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable {
throw new UninitializedException();
}
};
return (T) factory.create(new Class<?>[0], new Object[0], handler);
}
The application fails with the following exception.
Caused by: javassist.CannotCompileException: by java.lang.SecurityException: class "javassist.util.proxy.java_util_ArrayList_$$_jvsta7a_34"'s signer information does not match signer information of other classes in the same package
at javassist.util.proxy.DefineClassHelper.toClass2(DefineClassHelper.java:140)
at javassist.util.proxy.DefineClassHelper.toClass(DefineClassHelper.java:95)
at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:131)
at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:530)
... 28 more
Caused by: java.lang.SecurityException: class "javassist.util.proxy.java_util_ArrayList_$$_jvsta7a_34"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javassist.util.proxy.DefineClassHelper.toClass3(DefineClassHelper.java:152)
at javassist.util.proxy.DefineClassHelper.toClass2(DefineClassHelper.java:134)
... 31 more