/** * Use this method to register complex types that cannot be simply represented as a string in a * {@link BreifMapConverter}. The {@code typeId} will be used as a type discriminator in the * brief map, as well as the element root for the complex object to be converted. * * @param typeId * @param clazz */ public void registerBreifMapComplexType(String typeId, Class clazz) { forwardBreifMap.put(typeId, clazz); backwardBreifMap.put(clazz, typeId); xs.allowTypes(new Class[] {clazz}); }
xs.allowTypeHierarchy(Multimap.class); xs.allowTypeHierarchy(JAIInfo.class); xs.allowTypes(new Class[] {DynamicProxyMapper.DynamicProxy.class}); xs.allowTypes(new String[] {"java.util.Collections$SingletonList"}); xs.allowTypesByWildcard(new String[] {"org.geoserver.catalog.**"}); xs.allowTypesByWildcard(new String[] {"org.geoserver.security.**"});
private XStream xstream() { XStream xstream = new XStream(); // allow annotations on models for maximum flexibility xstream.autodetectAnnotations(true); // prevent xstream from creating complex XML graphs xstream.setMode(XStream.NO_REFERENCES); // setup security (see http://x-stream.github.io/security.html) xstream.allowTypes(WhitelistObjectInputStream.getWhiteClassNames()); xstream.allowTypesByRegExp(WhitelistObjectInputStream.getWhiteRegEx()); return xstream; }
/** * @param xStreamAnnotations never null * @see XStream#processAnnotations(Class[]) */ public void addXStreamAnnotations(Class<?>... xStreamAnnotations) { xStream.processAnnotations(xStreamAnnotations); xStream.allowTypes(xStreamAnnotations); }
/** * @param xStreamAnnotations never null * @see XStream#processAnnotations(Class[]) */ public void addXStreamAnnotations(Class... xStreamAnnotations) { xStream.processAnnotations(xStreamAnnotations); xStream.allowTypes(xStreamAnnotations); }
classes[i] = (Class)iter.next(); xstream.allowTypes(classes); } else { throw new IllegalArgumentException("Security framework of XStream instance already initialized");
@Test public void read() { String xml = "<keyAsElementMapConverterTestBean>\n" + " <customProperties>\n" + " <alpha>value1</alpha>\n" + " <beta>7</beta>\n" + " </customProperties>\n" + "</keyAsElementMapConverterTestBean>"; XStream xStream = XStreamXmlSolverFactory.buildXStream(); xStream.processAnnotations(KeyAsElementMapConverterTestBean.class); xStream.allowTypes(new Class[]{KeyAsElementMapConverterTestBean.class}); KeyAsElementMapConverterTestBean bean = (KeyAsElementMapConverterTestBean) xStream.fromXML(xml); assertEquals("value1", bean.customProperties.get("alpha")); assertEquals("7", bean.customProperties.get("beta")); }
private void configureXstream(XStream xs) { xs.alias("GeoServerGWCConfig", GWCConfig.class); xs.alias("defaultCachingGridSetIds", HashSet.class); xs.alias("defaultCoverageCacheFormats", HashSet.class); xs.alias("defaultVectorCacheFormats", HashSet.class); xs.alias("defaultOtherCacheFormats", HashSet.class); xs.alias("InnerCacheConfiguration", CacheConfiguration.class); xs.allowTypes(new Class[] {GWCConfig.class, CacheConfiguration.class}); }
public static void initXStream(XStream xstreamInstance) { Class<?>[] classes = new Class[] { Properties.class,ArrayList.class,List.class,AnalysisEnginePerformanceMetrics.class}; XStream.setupDefaultSecurity(xstreamInstance); xstreamInstance.allowTypes(classes); } }
/** Ensures compatibility with old style configuration files. */ @Override protected XStream buildXStream() { XStream xstream = super.buildXStream(); // setup OGR-specific aliases xstream.alias("OgrConfiguration", OgrConfiguration.class); xstream.alias("Format", OgrFormat.class); xstream.allowTypes(new Class[] {OgrConfiguration.class, OgrFormat.class}); return xstream; } }
DefaultTileLayerCatalog(GeoServerResourceLoader resourceLoader, XStream configuredXstream) throws IOException { this.resourceLoader = resourceLoader; this.baseDirectory = LAYERINFO_DIRECTORY; this.layersByName = new ConcurrentHashMap<>(); this.layersById = new ConcurrentHashMap<>(); this.initialized = false; // setup xstream security for local classes this.serializer = configuredXstream; this.serializer.allowTypeHierarchy(GeoServerTileLayerInfo.class); // have to use a string here because UnmodifiableSet is private this.serializer.allowTypes(new String[] {"java.util.Collections$UnmodifiableSet"}); }
@Override public void init(XStreamPersister persister) { persister.getXStream().allowTypes(new String[] { "mil.nga.giat.data.elasticsearch.ElasticAttribute" }); }
@Override public void configurePersister(XStreamPersister persister, XStreamMessageConverter converter) { XStream xstream = persister.getXStream(); xstream.alias("Attributes", LayerAttributesList.class); xstream.registerConverter(new LayerAttributesListConverter()); xstream.allowTypes(new Class[] {LayerAttributesList.class}); }
@Override public void configure(XStreamPersister xp) { LOG.log(Level.FINER, "GeoServerKeycloakAuthenticationProvider.configure ENTRY"); super.configure(xp); XStream xs = xp.getXStream(); xs.allowTypes(new Class[] {GeoServerKeycloakFilterConfig.class}); xs.alias("keycloakAdapter", GeoServerKeycloakFilterConfig.class); }
@Override public void configurePersister(XStreamPersister persister, XStreamMessageConverter converter) { XStream xstream = persister.getXStream(); xstream.alias("Rules", RulesList.class); xstream.registerConverter(new StyleConverter()); xstream.allowTypes(new Class[] {RulesList.class, JSONObject.class}); }
@Override public void init(XStreamPersister persister) { persister.registerBreifMapComplexType( "solrLayerConfiguration", SolrLayerConfiguration.class); XStream xs = persister.getXStream(); xs.alias("solrAttribute", SolrAttribute.class); xs.allowTypes(new Class[] {SolrAttribute.class, SolrLayerConfiguration.class}); } }
public NerdModel() { xstream = new XStream(); XStream.setupDefaultSecurity(xstream); Class[] classArray = new Class[] { GradientTreeBoost.class, RandomForest.class, RegressionTree.class, NumericAttribute.class, NominalAttribute.class, Attribute.class}; xstream.allowTypes(classArray); arffParser = new ArffParser(); }
/** * Sets up aliases and allowed types for the xstream persister * * @param xs */ public static void initXStreamPersister(XStreamPersister xp) { XStream xs = xp.getXStream(); xs.alias("wms", WMSInfo.class, WMSInfoImpl.class); xs.registerConverter(new WMSInfoConverter(xp)); xs.addDefaultImplementation(WatermarkInfoImpl.class, WatermarkInfo.class); xs.allowTypes(new Class[] {WatermarkInfo.class, WatermarkInfoImpl.class}); }
@Override public void configurePersister(XStreamPersister persister, XStreamMessageConverter converter) { XStream xs = persister.getXStream(); xs.processAnnotations(ModuleStatus.class); xs.allowTypes(new Class[] {ModuleStatus.class}); xs.alias("about", List.class); xs.alias("status", ModuleStatus.class); xs.addDefaultImplementation(ModuleStatusImpl.class, ModuleStatus.class); xs.addDefaultImplementation(RenderingEngineStatus.class, ModuleStatus.class); }
@Override public XStream answer() throws Throwable { XStream xs = xsCap.getValue(); xs.allowTypes(new Class[] {org.easymock.Capture.class}); return xs; } });