Patch to add support for (unsigned) applets

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Patch to add support for (unsigned) applets

Peter A
All,

Here is a patch which allows xstream to run inside of unsigned applets with increased security restrictions.  Looks like this issue has come up a couple of times in the past.  The patch is fairly simple and only took a couple of hours to code up and test.  What the patch does is that it replaces all references to ClassLoader with a new XStreamClassLoader interface.  There is now no need to create a new instance of ClassLoader, which is what caused the security exception. 

All unit tests pass.  I don't believe that any additional unit tests are required since it's mostly a modification existing code instead of adding new classes.

To actually work inside of the applet the user does need to create a custom XStreamClassLoader, which uses reflections to load Class, and use PureJavaReflectionProvider.  Some obscure serialization issues still can't be handled inside of applets, but I have yet to encounter those in my application.  If requested I can post an example of how to do this too.

Potential issue:
* Take a look at CompositeClassLoader.  It passes all tests but I'm uneasy about how I implemented getClassLoader()

Thanks for the great work on xstream and let me know if you will (or will not) consider applying this patch.  Recently switched from XMLEncoder and this issue is holding up the next release of one of my libraries.

- Peter

--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.
Reply | Threaded
Open this post in threaded view
|

Re: Patch to add support for (unsigned) applets

Jörg Schaible-3
Hi Peter,

Peter A wrote:

> All,
>
> Here is a patch which allows xstream to run inside of unsigned applets
> with
> increased security restrictions.  Looks like this issue has come up a
> couple of times in the past.  The patch is fairly simple and only took a
> couple of hours to code up and test.

I'll have a look at it. However, can you please open a JIRA issue and attach
it there? And please, provide a patch that does not format part of the code
or restructures the import sections. Thanks.

> What the patch does is that it
> replaces all references to ClassLoader with a new XStreamClassLoader
> interface.  There is now no need to create a new instance of ClassLoader,
> which is what caused the security exception.
>
> All unit tests pass.  I don't believe that any additional unit tests are
> required since it's mostly a modification existing code instead of adding
> new classes.
>
> To actually work inside of the applet the user does need to create a
> custom XStreamClassLoader, which uses reflections to load Class, and use
> PureJavaReflectionProvider.  Some obscure serialization issues still can't
> be handled inside of applets, but I have yet to encounter those in my
> application.  If requested I can post an example of how to do this too.
>
> Potential issue:
> * Take a look at CompositeClassLoader.  It passes all tests but I'm uneasy
> about how I implemented getClassLoader()
>
> Thanks for the great work on xstream and let me know if you will (or will
> not) consider applying this patch.  Recently switched from XMLEncoder and
> this issue is holding up the next release of one of my libraries.

From what I've seen in the patch, your approach is very promising. The
current class loader design is one of the oldest parts of XStream and
unfortunately also part of the current API, so we cannot simply replace it,
but I have an idea for the next major version ... even if it means to create
some deprecations ;-)

Thanks,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Patch to add support for (unsigned) applets

Peter A

Hi Jörg,


I modified the patch and removed import simplifications that intellij did.

When is the next major version "scheduled" approximately?  Trying to figure out how to handle my serialization issues since Oracle broke backwards compatibility in 1.7 with XmlEncoder/XmlDecoder.

If you are going to totally break backwards compatibility you could probably do things a bit cleaner than I did it.  On the flip side, with additional work you could make that approach backwards compatible too, at the cost of code bloat and the need for more unit tests to handle edge cases.

- Peter



On Fri, Apr 12, 2013 at 8:25 AM, Jörg Schaible <[hidden email]> wrote:
Hi Peter,

Peter A wrote:

> All,
>
> Here is a patch which allows xstream to run inside of unsigned applets
> with
> increased security restrictions.  Looks like this issue has come up a
> couple of times in the past.  The patch is fairly simple and only took a
> couple of hours to code up and test.

I'll have a look at it. However, can you please open a JIRA issue and attach
it there? And please, provide a patch that does not format part of the code
or restructures the import sections. Thanks.

> What the patch does is that it
> replaces all references to ClassLoader with a new XStreamClassLoader
> interface.  There is now no need to create a new instance of ClassLoader,
> which is what caused the security exception.
>
> All unit tests pass.  I don't believe that any additional unit tests are
> required since it's mostly a modification existing code instead of adding
> new classes.
>
> To actually work inside of the applet the user does need to create a
> custom XStreamClassLoader, which uses reflections to load Class, and use
> PureJavaReflectionProvider.  Some obscure serialization issues still can't
> be handled inside of applets, but I have yet to encounter those in my
> application.  If requested I can post an example of how to do this too.
>
> Potential issue:
> * Take a look at CompositeClassLoader.  It passes all tests but I'm uneasy
> about how I implemented getClassLoader()
>
> Thanks for the great work on xstream and let me know if you will (or will
> not) consider applying this patch.  Recently switched from XMLEncoder and
> this issue is holding up the next release of one of my libraries.

From what I've seen in the patch, your approach is very promising. The
current class loader design is one of the oldest parts of XStream and
unfortunately also part of the current API, so we cannot simply replace it,
but I have an idea for the next major version ... even if it means to create
some deprecations ;-)

Thanks,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Patch to add support for (unsigned) applets

Jörg Schaible-3
In reply to this post by Jörg Schaible-3
Hi Peter,

Peter A wrote:

> Hi Jörg,
>
> Created the bug report:
>
> http://jira.codehaus.org/browse/XSTR-732
>
> I modified the patch and removed import simplifications that intellij did.

thanks a lot!

> When is the next major version "scheduled" approximately?  Trying to
> figure out how to handle my serialization issues since Oracle broke
> backwards compatibility in 1.7 with XmlEncoder/XmlDecoder.

Actually we will have to create a minor release first. The next major
release will be in autumn. However, before releasing 1.4.5 I will look into
XSTR-732 again, maybe I can find a compatible way for inclusion - I have
already the idea.
 
> If you are going to totally break backwards compatibility you could
> probably do things a bit cleaner than I did it.  On the flip side, with
> additional work you could make that approach backwards compatible too, at
> the cost of code bloat and the need for more unit tests to handle edge
> cases.

Actually XStream lacks at some places of a major clean-up, but time will
tell :-)

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re: Patch to add support for (unsigned) applets

Peter A
Any update on when this patch will get integrated?  Getting ready to do another release of my software and hope to get the Maven build working again.

- Peter


On Mon, Apr 15, 2013 at 4:18 AM, Jörg Schaible <[hidden email]> wrote:
Hi Peter,

Peter A wrote:

> Hi Jörg,
>
> Created the bug report:
>
> http://jira.codehaus.org/browse/XSTR-732
>
> I modified the patch and removed import simplifications that intellij did.

thanks a lot!

> When is the next major version "scheduled" approximately?  Trying to
> figure out how to handle my serialization issues since Oracle broke
> backwards compatibility in 1.7 with XmlEncoder/XmlDecoder.

Actually we will have to create a minor release first. The next major
release will be in autumn. However, before releasing 1.4.5 I will look into
XSTR-732 again, maybe I can find a compatible way for inclusion - I have
already the idea.

> If you are going to totally break backwards compatibility you could
> probably do things a bit cleaner than I did it.  On the flip side, with
> additional work you could make that approach backwards compatible too, at
> the cost of code bloat and the need for more unit tests to handle edge
> cases.

Actually XStream lacks at some places of a major clean-up, but time will
tell :-)

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Patch to add support for (unsigned) applets

Jörg Schaible-2
In reply to this post by Jörg Schaible-3
Hi Peter,

Peter A wrote:

> Any update on when this patch will get integrated?  Getting ready to do
> another release of my software and hope to get the Maven build working
> again.

as you can see, version 1.4.5 is still not released, I was simply occupied
with other tasks in real life. As already stated, I will look into it,
before 1.4.5. is ready, but I have no dead line for now.

Sorry,
Jörg



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Patch to add support for (unsigned) applets

Peter A
Hi Jörg,

I see that you posted a fix.  Skimming through the code it looks like it should work.  Just need to pass in a ClassLoaderReference with the ClassLoader set to null right?

There is also another bug that I need to report.  I *think* with the JavaBeanConverter (if not that class then another one does) it mangles the case of single character variables.  So 'R' becomes 'r' breaking compatibility with other converters.  When I test your patch I'll submit the formal bug report.

Thanks!
- Peter


On Tue, Jun 18, 2013 at 1:37 PM, Jörg Schaible <[hidden email]> wrote:
Hi Peter,

Peter A wrote:

> Any update on when this patch will get integrated?  Getting ready to do
> another release of my software and hope to get the Maven build working
> again.

as you can see, version 1.4.5 is still not released, I was simply occupied
with other tasks in real life. As already stated, I will look into it,
before 1.4.5. is ready, but I have no dead line for now.

Sorry,
Jörg



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Patch to add support for (unsigned) applets

Jörg Schaible-2
Hi Peter,

Peter A wrote:

> Hi Jörg,
>
> I see that you posted a fix.  Skimming through the code it looks like it
> should work.  Just need to pass in a ClassLoaderReference with the
> ClassLoader set to null right?

Actually I thought that you will pass a ClassLoader from a class that is
already loaded, e.g. "new XStream(new
ClassLoaderReference(getClass().getClassLoader()))". Setting the reference
to null will currently raise NPEs, but I will have a look if I can use then
the bootstrap class loader instead (see Javadoc for Class.loadClass(,,)).

> There is also another bug that I need to report.  I *think* with the
> JavaBeanConverter (if not that class then another one does) it mangles the
> case of single character variables.  So 'R' becomes 'r' breaking
> compatibility with other converters.  When I test your patch I'll submit
> the formal bug report.

Fine.

Note, that I have nothing done yet regarding the initialization errors for
the converters. I have the intent to do so, but you may open a separate JIRA
issue.

Regards,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Patch to add support for (unsigned) applets

Jörg Schaible-2
Hi Peter,

Jörg Schaible wrote:

[snip]

> Note, that I have nothing done yet regarding the initialization errors for
> the converters. I have the intent to do so, but you may open a separate
> JIRA issue.

Actually, it is XSTR-200 in general. My latest modification prevents that
any of the registered converters will fail at initialization. So, nothing
should stop you to initialize an XStream instance in an applet (or GAE ??).

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Patch to add support for (unsigned) applets

Peter A
In reply to this post by Jörg Schaible-2
Hi Jörg,

When I skimmed the code I thought it handled the null case, must have read the code in correctly.  Please ignore that comment.

My first attempt to use the new code failed and throws an exception.  See below for my code.  Did I do something wrong?

---------------- BEGIN -----------------------
ClassLoaderReference loader = new ClassLoaderReference(BoofMiscOps.class.getClassLoader());
XStream xstream = new XStream(new PureJavaReflectionProvider(),new DomDriver(),loader,null,new DefaultConverterLookup(), null);

xstream.registerConverter(new JavaBeanConverter(xstream.getMapper()));

        try {
            xstream.toXML(o,new FileOutputStream(fileName));
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
---------------- END -----------------------

com.thoughtworks.xstream.converters.ConversionException: No converter specified for class org.ejml.data.DenseMatrix64F
---- Debugging information ----
-------------------------------
    at com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:61)
    at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:48)
    at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
    at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
    at com.thoughtworks.xstream.XStream.marshal(XStream.java:990)
    at com.thoughtworks.xstream.XStream.marshal(XStream.java:979)
    at com.thoughtworks.xstream.XStream.toXML(XStream.java:967)
    at boofcv.misc.BoofMiscOps.saveXML(BoofMiscOps.java:49)
    at boofcv.misc.TestBoofMiscOps.saveXML_loadXML_file(TestBoofMiscOps.java:42)



On Thu, Jul 4, 2013 at 12:45 PM, Jörg Schaible <[hidden email]> wrote:
Hi Peter,

Peter A wrote:

> Hi Jörg,
>
> I see that you posted a fix.  Skimming through the code it looks like it
> should work.  Just need to pass in a ClassLoaderReference with the
> ClassLoader set to null right?

Actually I thought that you will pass a ClassLoader from a class that is
already loaded, e.g. "new XStream(new
ClassLoaderReference(getClass().getClassLoader()))". Setting the reference
to null will currently raise NPEs, but I will have a look if I can use then
the bootstrap class loader instead (see Javadoc for Class.loadClass(,,)).

> There is also another bug that I need to report.  I *think* with the
> JavaBeanConverter (if not that class then another one does) it mangles the
> case of single character variables.  So 'R' becomes 'r' breaking
> compatibility with other converters.  When I test your patch I'll submit
> the formal bug report.

Fine.

Note, that I have nothing done yet regarding the initialization errors for
the converters. I have the intent to do so, but you may open a separate JIRA
issue.

Regards,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Patch to add support for (unsigned) applets

Jörg Schaible-3
Peter A wrote:

> Hi Jörg,
>
> When I skimmed the code I thought it handled the null case, must have read
> the code in correctly.  Please ignore that comment.
>
> My first attempt to use the new code failed and throws an exception.  See
> below for my code.  Did I do something wrong?
>
> ---------------- BEGIN -----------------------
> ClassLoaderReference loader = new
> ClassLoaderReference(BoofMiscOps.class.getClassLoader());
> XStream xstream = new XStream(new PureJavaReflectionProvider(),new
> DomDriver(),loader,null,new DefaultConverterLookup(), null);
>
> xstream.registerConverter(new JavaBeanConverter(xstream.getMapper()));
>
>         try {
>             xstream.toXML(o,new FileOutputStream(fileName));
>         } catch (FileNotFoundException e) {
>             throw new RuntimeException(e);
>         }
> ---------------- END -----------------------


You did not provide a ConverterRegistry, so no converter was registered at
all. Since you use the defaults anyway, simply instantiate with:

XStream xstream = new XStream(new PureJavaReflectionProvider(),new
DomDriver(),loader);

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Patch to add support for (unsigned) applets

Peter A
A bit late, but I'm finally checking out the latest version of xstream for Applet compatibility.  So far no luck.  When I run the following code inside of appletviewer it crashes on the "new XStream()" line.  Code and exception below.  Am I doing something wrong or are there still issues that need to be worked around?  I'm using version 1.4.7 from Maven central repository.

Thanks!

--------------------- BEGIN -------------------------
    public static <T> T loadXML( Reader r ) {
        XStream xstream = new XStream(new PureJavaReflectionProvider(),new DomDriver(),new
            ClassLoaderReference(r.getClass().getClassLoader()));
        xstream.registerConverter(new JavaBeanConverter(xstream.getMapper()));
        return (T)xstream.fromXML(r);
    }
--------------------- END -------------------------

Exception in thread "Thread-1" com.thoughtworks.xstream.InitializationException: Could not instantiate mapper : com.thoughtworks.xstream.mapper.EnumMapper : access denied ("java.lang.RuntimePermission" "getClassLoader")
    at com.thoughtworks.xstream.XStream.buildMapperDynamically(XStream.java:622)
    at com.thoughtworks.xstream.XStream.buildMapper(XStream.java:596)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:568)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:496)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:489)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:428)
    at boofcv.io.UtilIO.loadXML(UtilIO.java:157)





On Mon, Jul 15, 2013 at 3:01 AM, Jörg Schaible <[hidden email]> wrote:
Peter A wrote:

> Hi Jörg,
>
> When I skimmed the code I thought it handled the null case, must have read
> the code in correctly.  Please ignore that comment.
>
> My first attempt to use the new code failed and throws an exception.  See
> below for my code.  Did I do something wrong?
>
> ---------------- BEGIN -----------------------
> ClassLoaderReference loader = new
> ClassLoaderReference(BoofMiscOps.class.getClassLoader());
> XStream xstream = new XStream(new PureJavaReflectionProvider(),new
> DomDriver(),loader,null,new DefaultConverterLookup(), null);
>
> xstream.registerConverter(new JavaBeanConverter(xstream.getMapper()));
>
>         try {
>             xstream.toXML(o,new FileOutputStream(fileName));
>         } catch (FileNotFoundException e) {
>             throw new RuntimeException(e);
>         }
> ---------------- END -----------------------


You did not provide a ConverterRegistry, so no converter was registered at
all. Since you use the defaults anyway, simply instantiate with:

XStream xstream = new XStream(new PureJavaReflectionProvider(),new
DomDriver(),loader);

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Patch to add support for (unsigned) applets

Jörg Schaible-2
Hi Peter,

Peter A wrote:

> A bit late, but I'm finally checking out the latest version of xstream for
> Applet compatibility.  So far no luck.  When I run the following code
> inside of appletviewer it crashes on the "new XStream()" line.  Code and
> exception below.  Am I doing something wrong or are there still issues
> that
> need to be worked around?

It seems so.

> I'm using version 1.4.7 from Maven central
> repository.
>
> Thanks!
>
> --------------------- BEGIN -------------------------
>     public static <T> T loadXML( Reader r ) {
>         XStream xstream = new XStream(new PureJavaReflectionProvider(),new
> DomDriver(),new
>             ClassLoaderReference(r.getClass().getClassLoader()));
>         xstream.registerConverter(new
> JavaBeanConverter(xstream.getMapper()));
>         return (T)xstream.fromXML(r);
>     }
> --------------------- END -------------------------
>
> Exception in thread "Thread-1"
> com.thoughtworks.xstream.InitializationException: Could not instantiate
> mapper : com.thoughtworks.xstream.mapper.EnumMapper : access denied
> ("java.lang.RuntimePermission" "getClassLoader")
>     at
> com.thoughtworks.xstream.XStream.buildMapperDynamically(XStream.java:622)
>     at com.thoughtworks.xstream.XStream.buildMapper(XStream.java:596)
>     at com.thoughtworks.xstream.XStream.<init>(XStream.java:568)
>     at com.thoughtworks.xstream.XStream.<init>(XStream.java:496)
>     at com.thoughtworks.xstream.XStream.<init>(XStream.java:489)
>     at com.thoughtworks.xstream.XStream.<init>(XStream.java:428)
>     at boofcv.io.UtilIO.loadXML(UtilIO.java:157)


Is this the complete stack trace? I am missing at least one additional
"caused by".

Cheers,
Jörg



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Patch to add support for (unsigned) applets

Peter A
Here's the full message.  Works just fine when run as an application:

/opt/jdk/jdk1.7.0_45/bin/appletviewer index.html
Exception in thread "Thread-1" java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "createClassLoader")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
    at java.security.AccessController.checkPermission(AccessController.java:559)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.SecurityManager.checkCreateClassLoader(SecurityManager.java:611)
    at java.lang.ClassLoader.checkCreateClassLoader(ClassLoader.java:275)
    at java.lang.ClassLoader.<init>(ClassLoader.java:336)
    at com.thoughtworks.xstream.core.util.CompositeClassLoader.<init>(CompositeClassLoader.java:73)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:411)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:364)
    at boofcv.io.UtilIO.loadXML(UtilIO.java:154)
    at boofcv.alg.geo.rectify.ShowRectifyCalibratedApp.changeInput(ShowRectifyCalibratedApp.java:154)
    at boofcv.gui.SelectAlgorithmAndInputPanel.performChangeInput(SelectAlgorithmAndInputPanel.java:326)
    at boofcv.gui.SelectAlgorithmAndInputPanel.access$200(SelectAlgorithmAndInputPanel.java:44)
    at boofcv.gui.SelectAlgorithmAndInputPanel$8.run(SelectAlgorithmAndInputPanel.java:300)

The code right now is slightly different from the way it was before:

    public static <T> T loadXML( Reader r ) {
        XStream xstream = new XStream(new PureJavaReflectionProvider());
        xstream.registerConverter(new JavaBeanConverter(xstream.getMapper()));
        return (T)xstream.fromXML(r);
    }

Another issue I have now is that the PureJavaReflectionProvider() has issues with capitalization.  The variable is capitalized in the class but I have to modify the xml by hand to make it lower case or it won't parse.

I also have more time now and should be able to reply faster.  Sorry for the previous delays.

- Peter



On Mon, May 26, 2014 at 3:52 PM, Jörg Schaible <[hidden email]> wrote:
Hi Peter,

Peter A wrote:

> A bit late, but I'm finally checking out the latest version of xstream for
> Applet compatibility.  So far no luck.  When I run the following code
> inside of appletviewer it crashes on the "new XStream()" line.  Code and
> exception below.  Am I doing something wrong or are there still issues
> that
> need to be worked around?

It seems so.

> I'm using version 1.4.7 from Maven central
> repository.
>
> Thanks!
>
> --------------------- BEGIN -------------------------
>     public static <T> T loadXML( Reader r ) {
>         XStream xstream = new XStream(new PureJavaReflectionProvider(),new
> DomDriver(),new
>             ClassLoaderReference(r.getClass().getClassLoader()));
>         xstream.registerConverter(new
> JavaBeanConverter(xstream.getMapper()));
>         return (T)xstream.fromXML(r);
>     }
> --------------------- END -------------------------
>
> Exception in thread "Thread-1"
> com.thoughtworks.xstream.InitializationException: Could not instantiate
> mapper : com.thoughtworks.xstream.mapper.EnumMapper : access denied
> ("java.lang.RuntimePermission" "getClassLoader")
>     at
> com.thoughtworks.xstream.XStream.buildMapperDynamically(XStream.java:622)
>     at com.thoughtworks.xstream.XStream.buildMapper(XStream.java:596)
>     at com.thoughtworks.xstream.XStream.<init>(XStream.java:568)
>     at com.thoughtworks.xstream.XStream.<init>(XStream.java:496)
>     at com.thoughtworks.xstream.XStream.<init>(XStream.java:489)
>     at com.thoughtworks.xstream.XStream.<init>(XStream.java:428)
>     at boofcv.io.UtilIO.loadXML(UtilIO.java:157)


Is this the complete stack trace? I am missing at least one additional
"caused by".

Cheers,
Jörg



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Re: Patch to add support for (unsigned) applets

Jörg Schaible-2
Hi Peter,

Peter A wrote:

> Here's the full message.  Works just fine when run as an application:
>
> /opt/jdk/jdk1.7.0_45/bin/appletviewer index.html
> Exception in thread "Thread-1" java.security.AccessControlException:
> access denied ("java.lang.RuntimePermission" "createClassLoader")


You will never have this permission in an unsigned applet.


>     at
>
java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
>     at
> java.security.AccessController.checkPermission(AccessController.java:559)
>     at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
>     at
> java.lang.SecurityManager.checkCreateClassLoader(SecurityManager.java:611)
>     at java.lang.ClassLoader.checkCreateClassLoader(ClassLoader.java:275)
>     at java.lang.ClassLoader.<init>(ClassLoader.java:336)
>     at
>
com.thoughtworks.xstream.core.util.CompositeClassLoader.<init>(CompositeClassLoader.java:73)
>     at com.thoughtworks.xstream.XStream.<init>(XStream.java:411)
>     at com.thoughtworks.xstream.XStream.<init>(XStream.java:364)


You have to provide the classloader in a ClassLoaderReference also as
XStream contructor parameter.


>     at boofcv.io.UtilIO.loadXML(UtilIO.java:154)
>     at
>
boofcv.alg.geo.rectify.ShowRectifyCalibratedApp.changeInput(ShowRectifyCalibratedApp.java:154)
>     at
>
boofcv.gui.SelectAlgorithmAndInputPanel.performChangeInput(SelectAlgorithmAndInputPanel.java:326)
>     at
>
boofcv.gui.SelectAlgorithmAndInputPanel.access$200(SelectAlgorithmAndInputPanel.java:44)
>     at
>
boofcv.gui.SelectAlgorithmAndInputPanel$8.run(SelectAlgorithmAndInputPanel.java:300)

>
> The code right now is slightly different from the way it was before:
>
>     public static <T> T loadXML( Reader r ) {
>         XStream xstream = new XStream(new PureJavaReflectionProvider());
>         xstream.registerConverter(new
> JavaBeanConverter(xstream.getMapper()));
>         return (T)xstream.fromXML(r);
>     }
>
> Another issue I have now is that the PureJavaReflectionProvider() has
> issues with capitalization.


Sorry, no. The PureJavaReflectonProvider has no such issues.


> The variable is capitalized in the class but
> I have to modify the xml by hand to make it lower case or it won't parse.


Since you have registered to use a JavaBeanConverter for any class with a
public default constructor.

=================== %< =============
XStream xstream = new XStream(new PureJavaReflectionProvider());
xstream.registerConverter(new JavaBeanConverter(xstream.getMapper()));
ConverterLookup lookup = xstream.getConverterLookup();
assertTrue(lookup.lookupConverterForType(ArrayList.class) instanceof
=================== %< =============

The priority of the internally registered converters is listed here:
http://xstream.codehaus.org/converters.html

The JavaBeanConverter is not using the PureJavaReflectionConverter at all,
it follows the JavaBean naming conventions:

=================== %< =============
class Bean {
  String __NaMe$$;
  String getName() { return __NaMe$$; }
  void setName(String s) { __NaMe$$ = s; }
}
=================== %< =============

Since the bean attribute's name is "name", "name" will be used for the XML
elements in a Bean instance. Register the converter with a lower prio.

 
> I also have more time now and should be able to reply faster.  Sorry for
> the previous delays.


Your feedback is welcome,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Re: Patch to add support for (unsigned) applets

Peter A
Ok here is what worked successfully inside an applet:

---------------------- BEGIN ----------------------------
XStream xstream = new XStream(new PureJavaReflectionProvider(),new XppDriver(),
                new ClassLoaderReference(UtilIO.class.getClassLoader()));
        xstream.registerConverter(new JavaBeanConverter(xstream.getMapper()));
----------------------- END -----------------------------

Where UtilIO is just a random class in my code.  At one point I made the mistake of passing in Reader.class which caused weird class not found exceptions to be thrown.

I would recommend adding that somewhere to the tutorial since the default doesn't work in Applets.  Thanks again for the help!

- Peter



On Tue, Jun 3, 2014 at 6:12 PM, Jörg Schaible <[hidden email]> wrote:
Hi Peter,

Peter A wrote:

> Here's the full message.  Works just fine when run as an application:
>
> /opt/jdk/jdk1.7.0_45/bin/appletviewer index.html
> Exception in thread "Thread-1" java.security.AccessControlException:
> access denied ("java.lang.RuntimePermission" "createClassLoader")


You will never have this permission in an unsigned applet.


>     at
>
java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
>     at
> java.security.AccessController.checkPermission(AccessController.java:559)
>     at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
>     at
> java.lang.SecurityManager.checkCreateClassLoader(SecurityManager.java:611)
>     at java.lang.ClassLoader.checkCreateClassLoader(ClassLoader.java:275)
>     at java.lang.ClassLoader.<init>(ClassLoader.java:336)
>     at
>
com.thoughtworks.xstream.core.util.CompositeClassLoader.<init>(CompositeClassLoader.java:73)
>     at com.thoughtworks.xstream.XStream.<init>(XStream.java:411)
>     at com.thoughtworks.xstream.XStream.<init>(XStream.java:364)


You have to provide the classloader in a ClassLoaderReference also as
XStream contructor parameter.


>     at boofcv.io.UtilIO.loadXML(UtilIO.java:154)
>     at
>
boofcv.alg.geo.rectify.ShowRectifyCalibratedApp.changeInput(ShowRectifyCalibratedApp.java:154)
>     at
>
boofcv.gui.SelectAlgorithmAndInputPanel.performChangeInput(SelectAlgorithmAndInputPanel.java:326)
>     at
>
boofcv.gui.SelectAlgorithmAndInputPanel.access$200(SelectAlgorithmAndInputPanel.java:44)
>     at
>
boofcv.gui.SelectAlgorithmAndInputPanel$8.run(SelectAlgorithmAndInputPanel.java:300)
>
> The code right now is slightly different from the way it was before:
>
>     public static <T> T loadXML( Reader r ) {
>         XStream xstream = new XStream(new PureJavaReflectionProvider());
>         xstream.registerConverter(new
> JavaBeanConverter(xstream.getMapper()));
>         return (T)xstream.fromXML(r);
>     }
>
> Another issue I have now is that the PureJavaReflectionProvider() has
> issues with capitalization.


Sorry, no. The PureJavaReflectonProvider has no such issues.


> The variable is capitalized in the class but
> I have to modify the xml by hand to make it lower case or it won't parse.


Since you have registered to use a JavaBeanConverter for any class with a
public default constructor.

=================== %< =============
XStream xstream = new XStream(new PureJavaReflectionProvider());
xstream.registerConverter(new JavaBeanConverter(xstream.getMapper()));
ConverterLookup lookup = xstream.getConverterLookup();
assertTrue(lookup.lookupConverterForType(ArrayList.class) instanceof
=================== %< =============

The priority of the internally registered converters is listed here:
http://xstream.codehaus.org/converters.html

The JavaBeanConverter is not using the PureJavaReflectionConverter at all,
it follows the JavaBean naming conventions:

=================== %< =============
class Bean {
  String __NaMe$$;
  String getName() { return __NaMe$$; }
  void setName(String s) { __NaMe$$ = s; }
}
=================== %< =============

Since the bean attribute's name is "name", "name" will be used for the XML
elements in a Bean instance. Register the converter with a lower prio.


> I also have more time now and should be able to reply faster.  Sorry for
> the previous delays.


Your feedback is welcome,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Re: Re: Patch to add support for (unsigned) applets

Jörg Schaible-4
In reply to this post by Jörg Schaible-2
Peter A wrote:

> Ok here is what worked successfully inside an applet:
>
> ---------------------- BEGIN ----------------------------
> XStream xstream = new XStream(new PureJavaReflectionProvider(),new
> XppDriver(),
>                 new ClassLoaderReference(UtilIO.class.getClassLoader()));
>         xstream.registerConverter(new
> JavaBeanConverter(xstream.getMapper()));
> ----------------------- END -----------------------------
>
> Where UtilIO is just a random class in my code.  At one point I made the
> mistake of passing in Reader.class which caused weird class not found
> exceptions to be thrown.
>
> I would recommend adding that somewhere to the tutorial since the default
> doesn't work in Applets.  Thanks again for the help!

Actually the context classloader should do:

  Thread.currentThread().getContextClassloader();

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Re: Re: Patch to add support for (unsigned) applets

Peter A
I spoke too soon.  The code in the previous message works in applications and applets as long as it doesn't encounter a class variable that's composed of a single letter name.  If it does contain a class variable with a single letter then it will work as an application but throw the following exception inside an applet.  This seems a bit quirky.  I vaguely remember needing to modify JavaBeanConverter when i submitted that patch/hack a while ago.

- Peter

Exception in thread "Thread-1" com.thoughtworks.xstream.converters.ConversionException: access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks") : access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
---- Debugging information ----
message             : access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
cause-exception     : java.security.AccessControlException
cause-message       : access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
class               : georegression.struct.se.Se3_F64
required-type       : georegression.struct.se.Se3_F64
converter-type      : com.thoughtworks.xstream.converters.javabean.JavaBeanConverter
path                : /boofcv.struct.calib.StereoParameters/rightToLeft/r
line number         : 31
class[1]            : boofcv.struct.calib.StereoParameters
version             : not available
-------------------------------
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
    at com.thoughtworks.xstream.converters.javabean.JavaBeanConverter.unmarshal(JavaBeanConverter.java:134)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1185)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1169)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1040)
    at boofcv.io.UtilIO.loadXML(UtilIO.java:152)
    at boofcv.alg.geo.rectify.ShowRectifyCalibratedApp.changeInput(ShowRectifyCalibratedApp.java:154)
    at boofcv.gui.SelectAlgorithmAndInputPanel.performChangeInput(SelectAlgorithmAndInputPanel.java:326)
    at boofcv.gui.SelectAlgorithmAndInputPanel.access$200(SelectAlgorithmAndInputPanel.java:44)
    at boofcv.gui.SelectAlgorithmAndInputPanel$8.run(SelectAlgorithmAndInputPanel.java:300)
Caused by: java.security.AccessControlException: access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
    at java.security.AccessController.checkPermission(AccessController.java:560)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:128)
    at com.thoughtworks.xstream.converters.reflection.FieldDictionary.buildMap(FieldDictionary.java:148)
    at com.thoughtworks.xstream.converters.reflection.FieldDictionary.fieldOrNull(FieldDictionary.java:113)
    at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.getFieldOrNull(PureJavaReflectionProvider.java:193)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.canAccess(AbstractReflectionConverter.java:61)
    at com.thoughtworks.xstream.converters.reflection.ReflectionConverter.canConvert(ReflectionConverter.java:41)
    at com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:56)
    at com.thoughtworks.xstream.XStream$1.lookupConverterForType(XStream.java:498)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:56)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
    at com.thoughtworks.xstream.converters.javabean.JavaBeanConverter.unmarshal(JavaBeanConverter.java:134)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
    ... 18 more


On Wed, Jun 4, 2014 at 12:08 PM, Jörg Schaible <[hidden email]> wrote:
Peter A wrote:

> Ok here is what worked successfully inside an applet:
>
> ---------------------- BEGIN ----------------------------
> XStream xstream = new XStream(new PureJavaReflectionProvider(),new
> XppDriver(),
>                 new ClassLoaderReference(UtilIO.class.getClassLoader()));
>         xstream.registerConverter(new
> JavaBeanConverter(xstream.getMapper()));
> ----------------------- END -----------------------------
>
> Where UtilIO is just a random class in my code.  At one point I made the
> mistake of passing in Reader.class which caused weird class not found
> exceptions to be thrown.
>
> I would recommend adding that somewhere to the tutorial since the default
> doesn't work in Applets.  Thanks again for the help!

Actually the context classloader should do:

  Thread.currentThread().getContextClassloader();

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Re: Re: Re: Patch to add support for (unsigned) applets

Jörg Schaible-2
Hi Peter,

Peter A wrote:

> I spoke too soon.  The code in the previous message works in applications
> and applets as long as it doesn't encounter a class variable that's
> composed of a single letter name.  If it does contain a class variable
> with a single letter then it will work as an application but throw the
> following
> exception inside an applet.  This seems a bit quirky.  I vaguely remember
> needing to modify JavaBeanConverter when i submitted that patch/hack a
> while ago.

This has nothing to do with the JavaBeanConverter or with the name. You can
see from the stack trace, that georegression.struct.se.Se3_F64 was handled
by the ReflectionConverter ... which will *never* work in an untrusted
applet. It simply seems that georegression.struct.se.Se3_F64 is not a
JavaBean (resp. has no public default constructor).

- Jörg

>
> - Peter
>
> Exception in thread "Thread-1"
> com.thoughtworks.xstream.converters.ConversionException: access denied
> ("java.lang.reflect.ReflectPermission" "suppressAccessChecks") : access
> denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
> ---- Debugging information ----
> message             : access denied ("java.lang.reflect.ReflectPermission"
> "suppressAccessChecks")
> cause-exception     : java.security.AccessControlException
> cause-message       : access denied ("java.lang.reflect.ReflectPermission"
> "suppressAccessChecks")
> class               : georegression.struct.se.Se3_F64
> required-type       : georegression.struct.se.Se3_F64
> converter-type      :
> com.thoughtworks.xstream.converters.javabean.JavaBeanConverter
> path                : /boofcv.struct.calib.StereoParameters/rightToLeft/r
> line number         : 31
> class[1]            : boofcv.struct.calib.StereoParameters
> version             : not available
> -------------------------------
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
>     at
>
com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
>     at
>
com.thoughtworks.xstream.converters.javabean.JavaBeanConverter.unmarshal(JavaBeanConverter.java:134)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>     at
>
com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
>     at
>
com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
>     at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1185)
>     at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1169)
>     at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1040)
>     at boofcv.io.UtilIO.loadXML(UtilIO.java:152)
>     at
>
boofcv.alg.geo.rectify.ShowRectifyCalibratedApp.changeInput(ShowRectifyCalibratedApp.java:154)
>     at
>
boofcv.gui.SelectAlgorithmAndInputPanel.performChangeInput(SelectAlgorithmAndInputPanel.java:326)
>     at
>
boofcv.gui.SelectAlgorithmAndInputPanel.access$200(SelectAlgorithmAndInputPanel.java:44)
>     at
>
boofcv.gui.SelectAlgorithmAndInputPanel$8.run(SelectAlgorithmAndInputPanel.java:300)
> Caused by: java.security.AccessControlException: access denied
> ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
>     at
>
java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
>     at
> java.security.AccessController.checkPermission(AccessController.java:560)
>     at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
>     at
>
java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:128)
>     at
>
com.thoughtworks.xstream.converters.reflection.FieldDictionary.buildMap(FieldDictionary.java:148)
>     at
>
com.thoughtworks.xstream.converters.reflection.FieldDictionary.fieldOrNull(FieldDictionary.java:113)
>     at
>
com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.getFieldOrNull(PureJavaReflectionProvider.java:193)
>     at
>
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.canAccess(AbstractReflectionConverter.java:61)
>     at
>
com.thoughtworks.xstream.converters.reflection.ReflectionConverter.canConvert(ReflectionConverter.java:41)
>     at
>
com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:56)
>     at
>
com.thoughtworks.xstream.XStream$1.lookupConverterForType(XStream.java:498)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:56)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
>     at
>
com.thoughtworks.xstream.converters.javabean.JavaBeanConverter.unmarshal(JavaBeanConverter.java:134)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)

>     ... 18 more
>
>
> On Wed, Jun 4, 2014 at 12:08 PM, Jörg Schaible
> <[hidden email]
>> wrote:
>
>> Peter A wrote:
>>
>> > Ok here is what worked successfully inside an applet:
>> >
>> > ---------------------- BEGIN ----------------------------
>> > XStream xstream = new XStream(new PureJavaReflectionProvider(),new
>> > XppDriver(),
>> >                 new
>> >                 ClassLoaderReference(UtilIO.class.getClassLoader()));
>> >         xstream.registerConverter(new
>> > JavaBeanConverter(xstream.getMapper()));
>> > ----------------------- END -----------------------------
>> >
>> > Where UtilIO is just a random class in my code.  At one point I made
>> > the mistake of passing in Reader.class which caused weird class not
>> > found exceptions to be thrown.
>> >
>> > I would recommend adding that somewhere to the tutorial since the
>> > default
>> > doesn't work in Applets.  Thanks again for the help!
>>
>> Actually the context classloader should do:
>>
>>   Thread.currentThread().getContextClassloader();
>>
>> Cheers,
>> Jörg
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: Re: Re: Re: Patch to add support for (unsigned) applets

Peter A
While creating a minimal project to replicate the problem I found the error.  Se3_F64 was a proper bean, but a class it referenced was not.  Once that was fixed everything works.  Should have created the minimal case first...  Thanks.

- Peter


On Wed, Jun 4, 2014 at 3:59 PM, Jörg Schaible <[hidden email]> wrote:
Hi Peter,

Peter A wrote:

> I spoke too soon.  The code in the previous message works in applications
> and applets as long as it doesn't encounter a class variable that's
> composed of a single letter name.  If it does contain a class variable
> with a single letter then it will work as an application but throw the
> following
> exception inside an applet.  This seems a bit quirky.  I vaguely remember
> needing to modify JavaBeanConverter when i submitted that patch/hack a
> while ago.

This has nothing to do with the JavaBeanConverter or with the name. You can
see from the stack trace, that georegression.struct.se.Se3_F64 was handled
by the ReflectionConverter ... which will *never* work in an untrusted
applet. It simply seems that georegression.struct.se.Se3_F64 is not a
JavaBean (resp. has no public default constructor).

- Jörg

>
> - Peter
>
> Exception in thread "Thread-1"
> com.thoughtworks.xstream.converters.ConversionException: access denied
> ("java.lang.reflect.ReflectPermission" "suppressAccessChecks") : access
> denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
> ---- Debugging information ----
> message             : access denied ("java.lang.reflect.ReflectPermission"
> "suppressAccessChecks")
> cause-exception     : java.security.AccessControlException
> cause-message       : access denied ("java.lang.reflect.ReflectPermission"
> "suppressAccessChecks")
> class               : georegression.struct.se.Se3_F64
> required-type       : georegression.struct.se.Se3_F64
> converter-type      :
> com.thoughtworks.xstream.converters.javabean.JavaBeanConverter
> path                : /boofcv.struct.calib.StereoParameters/rightToLeft/r
> line number         : 31
> class[1]            : boofcv.struct.calib.StereoParameters
> version             : not available
> -------------------------------
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
>     at
>
com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
>     at
>
com.thoughtworks.xstream.converters.javabean.JavaBeanConverter.unmarshal(JavaBeanConverter.java:134)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>     at
>
com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
>     at
>
com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
>     at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1185)
>     at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1169)
>     at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1040)
>     at boofcv.io.UtilIO.loadXML(UtilIO.java:152)
>     at
>
boofcv.alg.geo.rectify.ShowRectifyCalibratedApp.changeInput(ShowRectifyCalibratedApp.java:154)
>     at
>
boofcv.gui.SelectAlgorithmAndInputPanel.performChangeInput(SelectAlgorithmAndInputPanel.java:326)
>     at
>
boofcv.gui.SelectAlgorithmAndInputPanel.access$200(SelectAlgorithmAndInputPanel.java:44)
>     at
>
boofcv.gui.SelectAlgorithmAndInputPanel$8.run(SelectAlgorithmAndInputPanel.java:300)
> Caused by: java.security.AccessControlException: access denied
> ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
>     at
>
java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
>     at
> java.security.AccessController.checkPermission(AccessController.java:560)
>     at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
>     at
>
java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:128)
>     at
>
com.thoughtworks.xstream.converters.reflection.FieldDictionary.buildMap(FieldDictionary.java:148)
>     at
>
com.thoughtworks.xstream.converters.reflection.FieldDictionary.fieldOrNull(FieldDictionary.java:113)
>     at
>
com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.getFieldOrNull(PureJavaReflectionProvider.java:193)
>     at
>
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.canAccess(AbstractReflectionConverter.java:61)
>     at
>
com.thoughtworks.xstream.converters.reflection.ReflectionConverter.canConvert(ReflectionConverter.java:41)
>     at
>
com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:56)
>     at
>
com.thoughtworks.xstream.XStream$1.lookupConverterForType(XStream.java:498)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:56)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
>     at
>
com.thoughtworks.xstream.converters.javabean.JavaBeanConverter.unmarshal(JavaBeanConverter.java:134)
>     at
>
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
>     ... 18 more
>
>
> On Wed, Jun 4, 2014 at 12:08 PM, Jörg Schaible
> <[hidden email]
>> wrote:
>
>> Peter A wrote:
>>
>> > Ok here is what worked successfully inside an applet:
>> >
>> > ---------------------- BEGIN ----------------------------
>> > XStream xstream = new XStream(new PureJavaReflectionProvider(),new
>> > XppDriver(),
>> >                 new
>> >                 ClassLoaderReference(UtilIO.class.getClassLoader()));
>> >         xstream.registerConverter(new
>> > JavaBeanConverter(xstream.getMapper()));
>> > ----------------------- END -----------------------------
>> >
>> > Where UtilIO is just a random class in my code.  At one point I made
>> > the mistake of passing in Reader.class which caused weird class not
>> > found exceptions to be thrown.
>> >
>> > I would recommend adding that somewhere to the tutorial since the
>> > default
>> > doesn't work in Applets.  Thanks again for the help!
>>
>> Actually the context classloader should do:
>>
>>   Thread.currentThread().getContextClassloader();
>>
>> Cheers,
>> Jörg
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.