com.thoughtworks.xstream.XStream.allowTypes()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(251)

本文整理了Java中com.thoughtworks.xstream.XStream.allowTypes()方法的一些代码示例,展示了XStream.allowTypes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XStream.allowTypes()方法的具体详情如下:
包路径:com.thoughtworks.xstream.XStream
类名称:XStream
方法名:allowTypes

XStream.allowTypes介绍

[英]Add security permission for explicit types.
[中]为显式类型添加安全权限。

代码示例

代码示例来源:origin: geoserver/geoserver

/**
 * 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});
}

代码示例来源:origin: geoserver/geoserver

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.**"});

代码示例来源:origin: pippo-java/pippo

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;
}

代码示例来源:origin: kiegroup/optaplanner

/**
 * @param xStreamAnnotations never null
 * @see XStream#processAnnotations(Class[])
 */
public void addXStreamAnnotations(Class<?>... xStreamAnnotations) {
  xStream.processAnnotations(xStreamAnnotations);
  xStream.allowTypes(xStreamAnnotations);
}

代码示例来源:origin: kiegroup/optaplanner

/**
 * @param xStreamAnnotations never null
 * @see XStream#processAnnotations(Class[])
 */
public void addXStreamAnnotations(Class... xStreamAnnotations) {
  xStream.processAnnotations(xStreamAnnotations);
  xStream.allowTypes(xStreamAnnotations);
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

classes[i] = (Class)iter.next();
  xstream.allowTypes(classes);
} else {
  throw new IllegalArgumentException("Security framework of XStream instance already initialized");

代码示例来源:origin: kiegroup/optaplanner

@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"));
}

代码示例来源:origin: org.geoserver/gs-gwc

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});
}

代码示例来源:origin: org.apache.uima/uimaj-as-core

public static void initXStream(XStream xstreamInstance) {
  Class<?>[] classes = new Class[] { Properties.class,ArrayList.class,List.class,AnalysisEnginePerformanceMetrics.class};
  XStream.setupDefaultSecurity(xstreamInstance);
  xstreamInstance.allowTypes(classes);
 }
}

代码示例来源:origin: org.geoserver.extension/gs-ogr-wfs

/** 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;
  }
}

代码示例来源:origin: org.geoserver/gs-gwc

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"});
}

代码示例来源:origin: ngageoint/elasticgeo

@Override
public void init(XStreamPersister persister) {
  persister.getXStream().allowTypes(new String[] {
      "mil.nga.giat.data.elasticsearch.ElasticAttribute"
  });
}

代码示例来源:origin: org.geoserver.community/gs-sldservice

@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});
}

代码示例来源:origin: org.geoserver.community/gs-sec-keycloak

@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);
}

代码示例来源:origin: org.geoserver.community/gs-sldservice

@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});
}

代码示例来源:origin: org.geoserver.community/gs-web-solr

@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});
  }
}

代码示例来源:origin: kermitt2/entity-fishing

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();
}

代码示例来源:origin: org.geoserver/gs-wms

/**
 * 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});
}

代码示例来源:origin: org.geoserver/gs-restconfig

@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);
}

代码示例来源:origin: GeoWebCache/geowebcache

@Override
  public XStream answer() throws Throwable {
    XStream xs = xsCap.getValue();
    xs.allowTypes(new Class[] {org.easymock.Capture.class});
    return xs;
  }
});

相关文章