Java Code Examples for com.thoughtworks.xstream.XStream#allowTypeHierarchy()
The following examples show how to use
com.thoughtworks.xstream.XStream#allowTypeHierarchy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SesarSample.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * gets an <code>XStream</code> reader. Creates, customizes, and returns * <code>XStream</code> for XML serialization * * @pre <code>XStream</code> package is available @post <code>XStream</code> * for XML decoding is returned * * @return <code>XStream</code> - for XML serialization decoding */ public static XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example 2
Source File: WbConverter.java From openmeetings with Apache License 2.0 | 6 votes |
public static List<?> loadWmlFile(String hash) { String name = OmFileHelper.getName(hash, EXTENSION_WML); File file = new File(OmFileHelper.getUploadWmlDir(), name); log.debug("filepathComplete: {}", file); XStream xstream = new XStream(new XppDriver()); xstream.setMode(XStream.NO_REFERENCES); xstream.addPermission(NoTypePermission.NONE); xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(List.class); xstream.allowTypeHierarchy(String.class); xstream.ignoreUnknownElements(); try (InputStream is = new FileInputStream(file); BufferedReader reader = new BufferedReader(new InputStreamReader(is, UTF_8))) { return (List<?>) xstream.fromXML(reader); } catch (Exception err) { log.error("loadWmlFile", err); } return new ArrayList<>(); }
Example 3
Source File: PhysicalConstants.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ private XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example 4
Source File: UThReduxAliquot.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ public XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example 5
Source File: PbBlank.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * gets an <code>XStream</code> reader. Creates, customizes, and returns * <code>XStream</code> for XML serialization * * @pre <code>XStream</code> package is available @post <code>XStream</code> * for XML decoding is returned * * @return <code>XStream</code> - for XML serialization decoding */ public XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example 6
Source File: MineralStandardModel.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ private XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example 7
Source File: ValueModel.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * gets an <code>XStream</code> reader. Creates, customizes, and returns * <code>XStream</code> for XML serialization * * @pre <code>XStream</code> package is available @post <code>XStream</code> * for XML decoding is returned * * @return <code>XStream</code> - for XML serialization decoding */ public XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example 8
Source File: AnalysisFraction.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ public XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example 9
Source File: UPbFraction.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ private XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example 10
Source File: UPbReduxAliquot.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ public XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example 11
Source File: SampleMetaData.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * gets an <code>XStream</code> reader. Creates, customizes, and returns * <code>XStream</code> for XML serialization * * @pre <code>XStream</code> package is available * @post <code>XStream</code> for XML decoding is returned * @return <code>XStream</code> - for XML serialization decoding */ public XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example 12
Source File: SESARSampleMetadata.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * gets an <code>XStream</code> reader. Creates, customizes, and returns * <code>XStream</code> for XML serialization * * @pre <code>XStream</code> package is available * @post <code>XStream</code> for XML decoding is returned * @return <code>XStream</code> - for XML serialization decoding */ public XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example 13
Source File: AbstractRatiosDataModel.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ protected XStream getXStream() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example 14
Source File: ReportSettingsInterface.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ public default XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example 15
Source File: XStreamFactory.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Sets up the security framework for the passed <code>XStream</code> object. * * @param xStream the <code>XStream</code> object to set the security framework up for * @see <a * href="https://x-stream.github.io/security.html">https://x-stream.github.io/security.html</a> */ private static void setUpSecurityFramework(XStream xStream) { // forbid all classes by default xStream.addPermission(NoTypePermission.NONE); // allow default java stuff xStream.addPermission(NullPermission.NULL); xStream.addPermission(PrimitiveTypePermission.PRIMITIVES); xStream.allowTypeHierarchy(Collection.class); xStream.allowTypeHierarchy(Map.class); xStream.allowTypes(new Class[] {String.class}); // allow all saros classes xStream.allowTypesByWildcard(new String[] {"saros.**"}); }
Example 16
Source File: FoldersServiceBean.java From cuba with Apache License 2.0 | 5 votes |
protected XStream createXStream() { XStream xStream = new CubaXStream(); XStream.setupDefaultSecurity(xStream); xStream.allowTypeHierarchy(Serializable.class); //createTs and createdBy removed from BaseGenericIdEntity, //and import from old versions (platform 6.2) is performed with errors //so omit field processing xStream.omitField(BaseGenericIdEntity.class, "createTs"); xStream.omitField(BaseGenericIdEntity.class, "createdBy"); return xStream; }
Example 17
Source File: UserDashboardPersister.java From openmeetings with Apache License 2.0 | 5 votes |
public XStreamDashboardPersister() { this.file = getUserDashboard(getUserId()); xstream = new XStream(new DomDriver(UTF_8.name())); xstream.setMode(XStream.NO_REFERENCES); xstream.addPermission(NoTypePermission.NONE); xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypesByWildcard(new String[] {"org.apache.openmeetings.web.**"}); xstream.allowTypeHierarchy(ArrayList.class); xstream.alias("dashboard", UserDashboard.class); }
Example 18
Source File: EntitySnapshotManager.java From cuba with Apache License 2.0 | 5 votes |
protected Object fromXML(String xml) { final List exclUpdateFields = Arrays.asList("updateTs", "updatedBy"); XStream xStream = new CubaXStream() { @Override protected MapperWrapper wrapMapper(MapperWrapper next) { return new MapperWrapper(next) { @Override public boolean shouldSerializeMember(Class definedIn, String fieldName) { boolean result = super.shouldSerializeMember(definedIn, fieldName); if (!result) { return false; } if (fieldName != null) { if (exclUpdateFields.contains(fieldName) && Updatable.class.isAssignableFrom(definedIn)) { return false; } if ("uuid".equals(fieldName)) { if (!HasUuid.class.isAssignableFrom(definedIn) && BaseGenericIdEntity.class.isAssignableFrom(definedIn)) { return false; } } } return true; } }; } }; XStream.setupDefaultSecurity(xStream); xStream.allowTypeHierarchy(Serializable.class); xStream.omitField(BaseGenericIdEntity.class, "createTs"); xStream.omitField(BaseGenericIdEntity.class, "createdBy"); return xStream.fromXML(xml); }