xstream

Security framework of XStream not initialized, XStream is probably vulnerable

浪尽此生 提交于 2019-11-30 17:16:50
Security framework of XStream not initialized, XStream is probably vulnerable I keep getting this console error in red while using XStream (1.4.10) I tried the following: XStream.setupDefaultSecurity(xs); and xs.addPermission(AnyTypePermission.ANY); xs.addPermission(NoTypePermission.NONE); none of which got rid of it. I do not need any fancy security settings, I just want to silence that warning. Maybe also prepare the code for 1.5.x When dealing with security issues, I wouldn't take it lightly. Firstly one would understand the severity of the issue, here a good write up . Then find out how

how to create an InputStream from a Document or Node

我与影子孤独终老i 提交于 2019-11-30 17:01:14
How can I create an InputStream object from a XML Document or Node object to be used in xstream? I need to replace the ??? with some meaningful code. Thanks. Document doc = getDocument(); InputStream is = ???; MyObject obj = (MyObject) xstream.fromXML(is); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Source xmlSource = new DOMSource(doc); Result outputTarget = new StreamResult(outputStream); TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget); InputStream is = new ByteArrayInputStream(outputStream.toByteArray()); If you are using Java

Java XStream - Ignore tag that doesn't exist in XML

橙三吉。 提交于 2019-11-30 12:55:41
问题 I currently use a piece of XML like the following <Person> <Name>Frank Smith</Name> <Id>100023412</Id> <DOB>12/05/1954</DOB> <LasLogin>01/09/2010</LasLogin> <FavOS>Windows</FavOS> // Wild card that may occasionally appear </Person> What I am stuck with, is when using XStream I need to be able to ignore certain tags that appear (in the case above 'FavOS') These tags may not be known or change in the future. Is there a way to Ignore all tags that do not match what is currently implemented?

Can't add XStream file dependency to Android Studio project

好久不见. 提交于 2019-11-30 04:24:35
问题 I have downloaded and added xstream-1.4.8.jar to my Android Studio project. When I build the project it works fine but when I try to run it I get the following error from the Gradle Build window: Information:Gradle tasks [:app:assembleDebug] :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:compileDebugNdk UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72103Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42103Library

Java XStream - Ignore tag that doesn't exist in XML

梦想的初衷 提交于 2019-11-30 03:53:39
I currently use a piece of XML like the following <Person> <Name>Frank Smith</Name> <Id>100023412</Id> <DOB>12/05/1954</DOB> <LasLogin>01/09/2010</LasLogin> <FavOS>Windows</FavOS> // Wild card that may occasionally appear </Person> What I am stuck with, is when using XStream I need to be able to ignore certain tags that appear (in the case above 'FavOS') These tags may not be known or change in the future. Is there a way to Ignore all tags that do not match what is currently implemented? (Using XStream 1.3.1) As it took me more than 15 minutes to find this answer, I thought I would post it.

how to create an InputStream from a Document or Node

柔情痞子 提交于 2019-11-30 00:57:59
问题 How can I create an InputStream object from a XML Document or Node object to be used in xstream? I need to replace the ??? with some meaningful code. Thanks. Document doc = getDocument(); InputStream is = ???; MyObject obj = (MyObject) xstream.fromXML(is); 回答1: ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Source xmlSource = new DOMSource(doc); Result outputTarget = new StreamResult(outputStream); TransformerFactory.newInstance().newTransformer().transform(xmlSource,

Security framework of XStream not initialized, XStream is probably vulnerable

杀马特。学长 韩版系。学妹 提交于 2019-11-30 00:17:41
问题 Security framework of XStream not initialized, XStream is probably vulnerable I keep getting this console error in red while using XStream (1.4.10) I tried the following: XStream.setupDefaultSecurity(xs); and xs.addPermission(AnyTypePermission.ANY); xs.addPermission(NoTypePermission.NONE); none of which got rid of it. I do not need any fancy security settings, I just want to silence that warning. Maybe also prepare the code for 1.5.x 回答1: When dealing with security issues, I wouldn't take it

xStream.jar踩坑指南

被刻印的时光 ゝ 提交于 2019-11-29 14:03:47
前言 第一次接触Xstream,是在做一个socket通信的项目,由于是二次重新开发,所以有部分代码沿用了原来的代码(改造前用的webservice),其中xml字符串转换为对象,以及对象转换为xml字符串的代码用到了这个包,所以我也就照葫芦画瓢,最终把项目顺利做完了,由于没有遇到什么问题,所以也就没有对Xstream做深入的了解和探索,直到前几天又接手到一个新的项目,里面接口调用涉及到同样的业务需求,然后就再次想到Xstream,然后很自然地遇到了一些问题,所以也就有了这篇文章,好了,废话少说,直接开始吧。 过程:我太难了^|^ 由于上次用过,所以我就自以为轻车熟路的开始了,下面是收到的消息体(也就是需要转换成对象的xml字符串): <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <result> <message>认证成功</message> <data> <AAC003>张三</AAC003> <AAC002>610123456789012345</AAC002> </data> <code>1</code> </result> 然后我就按照自己的理解,创建了消息体对象: // 为了方便,我省略了get/set方法,一下同 // 文件名: MsgText.java public class MsgText {

XStream XmlPullParserException

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 10:22:46
I'm trying to use XStream. I've added the XStream executable Jar file to my project. Executing the following command: XStream xstream = new XStream(); Is resulting in the following exception: Exception in thread "main" java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserException at com.thoughtworks.xstream.XStream.<init>(XStream.java:350) at xstream_test.XmlTrasformer.objectToXml(XmlTrasformer.java:56) at xstream_test.XmlTrasformer.main(XmlTrasformer.java:31) Caused by: java.lang.ClassNotFoundException: org.xmlpull.v1.XmlPullParserException at java.net.URLClassLoader$1.run

XStream - Root as a collection of objects

夙愿已清 提交于 2019-11-29 02:32:43
I'm consuming an XML payload that looks something like this (for a more comprehensive example, check out : http://api.shopify.com/product.html ). <products type="array"> <product> ... </product> <product> ... </product> </products> Now currently my code does work, but its doing something that appears to be really really "wrong" - namely it associates the "products" with List.class. So the relevant code looks like the following: xstream.alias( "products", List.class ); xstream.alias( "product", ShopifyProduct.class ); This is fine except when I goto externalize any object with that xstream