How can I use JAXB from an unsigned applet (without signing it)?

后端 未结 3 1075
生来不讨喜
生来不讨喜 2021-01-22 12:50

I would like to marshall Java objects into XML and vice-versa from within an Unsigned Applet and I can\'t change any of the security permission/policy files, or sign the applica

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-22 12:53

    I also tried to find a solution with JAXB without any success.

    I switched to Axis2 (1.5.4) with ADB binding, but it also tried accessing system properties which failed with security manager checks.

    In the end, I got a workable solution together by using AspectJ and using an aspect that rewrites System.getProperty() calls to return null when they fail. Since all the properties Axis2 needed were non-critical anyway this worked. I also needed to apply an aspect over org.apache.axiom.util.stax.dialect.StAXDialectDetector.getRootUrlForResource() to always return null since it tried to make a ClassLoader.getSystemClassLoader() call which also failed under a security manager. Again this seemed like a non-critical call. Got AspectJ to rewrite the Axis2 classes at build-time and it ran as an unsigned applet.

    It's a really messy solution, but at least it worked.

    I couldn't get the same AspectJ hack working with JAXB because JAXB requires direct access to the private fields of classes which doesn't fly under a security manager if JAXB is bundled with the applet (which we need to do if AspectJ is used to rewrite classes).

提交回复
热议问题