当前位置: 首页>>代码示例>>Java>>正文


Java NoTypePermission类代码示例

本文整理汇总了Java中com.thoughtworks.xstream.security.NoTypePermission的典型用法代码示例。如果您正苦于以下问题:Java NoTypePermission类的具体用法?Java NoTypePermission怎么用?Java NoTypePermission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NoTypePermission类属于com.thoughtworks.xstream.security包,在下文中一共展示了NoTypePermission类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
/**
 * Setup the data to deserialize.
 *
 * @param params the parameters of the benchmark
 * @since 1.4.9
 */
@Setup(Level.Trial)
public void setUp(final BenchmarkParams params) {
    xstream = new XStream(new Xpp3Driver());
    xstream.addPermission(NoTypePermission.NONE);
    xstream.addPermission(ArrayTypePermission.ARRAYS);
    xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
    xstream.allowTypes(Model.class, String.class, BigInteger.class, UUID.class);
    final String benchmark = params.getBenchmark();
    switch (benchmark.substring(ConverterTypeBenchmark.class.getName().length() + 1)) {
    case "reflection":
        xstream.registerConverter(new ReflectionConverter(xstream.getMapper(), xstream.getReflectionProvider(),
            Model.class));
        break;
    case "javaBean":
        xstream.registerConverter(new JavaBeanConverter(xstream.getMapper(), Model.class));
        break;
    case "custom":
        xstream.registerConverter(new ModelConverter());
        break;
    default:
        throw new IllegalStateException("Unsupported benchmark type: " + benchmark);
    }
    xml = xstream.toXML(array);
    // System.out.println(xstream.toXML(array[0]));
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:32,代码来源:ConverterTypeBenchmark.java

示例2: readFromXml

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
static Object readFromXml(InputStream bufferedInput) throws IOException {
	final XStream xstream = createXStream(false);
	// see http://x-stream.github.io/security.html
	// clear out existing permissions and set own ones
	xstream.addPermission(NoTypePermission.NONE);
	// allow some basics
	xstream.addPermission(NullPermission.NULL);
	xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
	xstream.allowTypesByWildcard(
			new String[] { "java.lang.*", "java.util.*", "java.util.concurrent.*" });
	// allow any type from the same package
	xstream.allowTypesByWildcard(new String[] { PACKAGE_NAME + ".*" });
	final InputStreamReader reader = new InputStreamReader(bufferedInput, XML_CHARSET_NAME);
	try {
		return xstream.fromXML(reader);
	} finally {
		reader.close();
	}
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:20,代码来源:TransportFormat.java

示例3: parse

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
@Override
public Suite parse(InputStream suiteInputStream) throws Exception
{
    XStream xStream = new XStream(new StaxDriver());
    xStream.addPermission(NoTypePermission.NONE);
    xStream.allowTypesByWildcard(new String[]{
            "com.surenpi.autotest.suite.runner.**"
    });

    xStream.aliasSystemAttribute(null, "class");

    xStream.alias("suite", Suite.class);
    xStream.aliasField("pageConfig", Suite.class, "xmlConfPath");
    xStream.useAttributeFor(Suite.class, "xmlConfPath");
    xStream.aliasField("pages", Suite.class, "pageList");
    xStream.useAttributeFor(Suite.class, "pagePackage");
    xStream.useAttributeFor(Suite.class, "rows");
    xStream.useAttributeFor(Suite.class, "afterSleep");

    xStream.alias("page", SuitePage.class);
    xStream.aliasField("class", SuitePage.class, "pageCls");
    xStream.useAttributeFor(SuitePage.class, "pageCls");
    xStream.aliasField("actions", SuitePage.class, "actionList");
    xStream.useAttributeFor(SuitePage.class, "repeat");

    xStream.alias("action", SuiteAction.class);
    xStream.useAttributeFor(SuiteAction.class, "field");
    xStream.useAttributeFor(SuiteAction.class, "name");

    Object obj = xStream.fromXML(suiteInputStream);

    return (Suite) obj;
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.suite.runner,代码行数:34,代码来源:XStreamSuiteParser.java

示例4: createXStream1

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
private static XStream createXStream1(boolean ignoreMissingMembers, StaxDriver staxDriver,
        Class... annotatedClassesToProcess) {
    XStream xstream = new ResilientXStream(ignoreMissingMembers, staxDriver);
    xstream.registerConverter(new RepoPathConverter());
    xstream.registerConverter(new PropertiesConverter());
    xstream.registerConverter(new ChecksumsInfoConverter());
    xstream.registerConverter(new UserGroupInfoConverter());
    for (Class annotatedClass : annotatedClassesToProcess) {
        xstream.processAnnotations(annotatedClass);
    }
    xstream.alias("repoPath", RepoPath.class, RepoPathImpl.class);

    // clear out existing permissions and set own ones
    xstream.addPermission(NoTypePermission.NONE);
    // allow some basics
    xstream.addPermission(NullPermission.NULL);
    xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
    xstream.addPermission(ArrayTypePermission.ARRAYS);
    xstream.allowTypeHierarchy(Collection.class);
    xstream.allowTypeHierarchy(String.class);
    // allow any type from the same package
    xstream.allowTypesByWildcard(new String[]{"org.artifactory.**", "org.jfrog.**"});

    return xstream;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:26,代码来源:XStreamFactory.java

示例5: setUp

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
/**
 * Setup the data to deserialize.
 *
 * @param params the parameters of the benchmark
 * @since 1.4.9
 */
@Setup(Level.Trial)
public void setUp(final BenchmarkParams params) {
    final String benchmark = params.getBenchmark();
    final SingleValueConverter converter;
    switch (benchmark.substring(StringConverterBenchmark.class.getName().length() + 1)) {
    case "nonCaching":
        converter = new NonCachingStringConverter();
        break;
    case "intern":
        converter = new InternStringConverter();
        break;
    case "unlimitedSynchronizedWeakCache":
        converter = new SynchronizedWeakCacheStringConverter(Integer.MAX_VALUE);
        break;
    case "limitedSynchronizedWeakCache":
        converter = new SynchronizedWeakCacheStringConverter(UUID.randomUUID().toString().length());
        break;
    case "unlimitedConcurrentMap":
        converter = new SynchronizedWeakCacheStringConverter(Integer.MAX_VALUE);
        break;
    case "limitedConcurrentMap":
        converter = new SynchronizedWeakCacheStringConverter(UUID.randomUUID().toString().length());
        break;
    default:
        throw new IllegalStateException("Unsupported benchmark type: " + benchmark);
    }
    xstream = new XStream(new Xpp3Driver());
    xstream.addPermission(NoTypePermission.NONE);
    xstream.addPermission(ArrayTypePermission.ARRAYS);
    xstream.allowTypes(String.class);
    xstream.registerConverter(converter);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:39,代码来源:StringConverterBenchmark.java

示例6: init

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
/**
 * Initialize the XStream instance and instantiate the driver for the benchmark.
 *
 * @since 1.4.9
 */
@Setup
public void init() {
    xstream = new XStream();
    xstream.addPermission(NoTypePermission.NONE);
    xstream.addPermission(ArrayTypePermission.ARRAYS);
    xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
    xstream.allowTypes(List.class, String.class);
    xstream.setMode(XStream.NO_REFERENCES);
    driver = driverFactory.getDriver();
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:16,代码来源:ParserBenchmark.java

示例7: testAnyType

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
public void testAnyType() {
    register(String.class, URL.class, List.class);
    mapper.addPermission(NoTypePermission.NONE);
    mapper.addPermission(AnyTypePermission.ANY);
    assertSame(String.class, mapper.realClass(String.class.getName()));
    assertSame(List.class, mapper.realClass(List.class.getName()));
    assertNull(mapper.realClass(null));
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:9,代码来源:SecurityMapperTest.java

示例8: initXStream

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
private static XStream initXStream() {
	XStream xstream = new XStream();
	// clear out existing permissions and set own ones
	xstream.addPermission(NoTypePermission.NONE);
	// allow some classes
	xstream.addPermission(NullPermission.NULL);
	xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
	xstream.allowTypeHierarchy(Collection.class);
	xstream.allowTypesByWildcard(new String[] { "java.lang.**", "java.util.**", "java.awt.**", "java.time.**",
		"org.zephyrsoft.sdb2.**" });
	
	// aliases and omitted fields of model classes are defined via annotations
	xstream.processAnnotations(SongsModel.class);
	xstream.processAnnotations(Song.class);
	xstream.processAnnotations(SettingsModel.class);
	xstream.processAnnotations(StatisticsModel.class);
	xstream.processAnnotations(SongStatistics.class);
	
	// custom converters
	xstream.registerConverter(new GenericEnumConverter<>(FilterTypeEnum.class));
	xstream.registerConverter(new GenericEnumConverter<>(LanguageEnum.class));
	xstream.registerConverter(new GenericEnumConverter<>(ScreenContentsEnum.class));
	xstream.registerConverter(new FontConverter());
	xstream.registerConverter(new DateWithoutTimeConverter());
	
	// unknown XML elements can be ignored (e.g. <linkedSongs> which was removed)
	xstream.ignoreUnknownElements();
	
	return xstream;
}
 
开发者ID:mathisdt,项目名称:sdb2,代码行数:31,代码来源:XMLConverter.java

示例9: createXStream

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
/**
 * Creates the instance of XStream to us for all reading and writing operations
 * @param driver an XStream driver (see createDriver())
 * @param patientConverter a patient converter (see createPatientConverter())
 * @return an instance of XStream, never null
 */
protected XStream createXStream(HierarchicalStreamDriver driver, NaaccrPatientConverter patientConverter) {
    XStream xstream = new XStream(driver);

    // setup proper security environment
    xstream.addPermission(NoTypePermission.NONE);
    xstream.addPermission(new WildcardTypePermission(new String[] {"com.imsweb.naaccrxml.**"}));

    // tell XStream how to read/write our main entities
    xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_ROOT, NaaccrData.class);
    xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_ITEM, Item.class);
    xstream.alias(NaaccrXmlUtils.NAACCR_XML_TAG_PATIENT, Patient.class);

    // add some attributes
    xstream.aliasAttribute(NaaccrData.class, "_baseDictionaryUri", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_BASE_DICT);
    xstream.aliasAttribute(NaaccrData.class, "_userDictionaryUri", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_USER_DICT);
    xstream.aliasAttribute(NaaccrData.class, "_recordType", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_REC_TYPE);
    xstream.aliasAttribute(NaaccrData.class, "_timeGenerated", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_TIME_GENERATED);
    xstream.aliasAttribute(NaaccrData.class, "_specificationVersion", NaaccrXmlUtils.NAACCR_XML_ROOT_ATT_SPEC_VERSION);

    // all collections should be wrap into collection tags, but it's nicer to omit them in the XML; we have to tell XStream though
    xstream.addImplicitCollection(NaaccrData.class, "_items", Item.class);
    xstream.addImplicitCollection(NaaccrData.class, "_patients", Patient.class);

    // handle patients
    xstream.registerConverter(patientConverter);

    return xstream;
}
 
开发者ID:imsweb,项目名称:naaccr-xml,代码行数:35,代码来源:NaaccrStreamConfiguration.java

示例10: initXStream

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
protected void initXStream() {

        _xStream = new XStream(null, new XppDriver(), new ClassLoaderReference(
                XStreamConfiguratorRegistryUtil.getConfiguratorsClassLoader(XStream.class.getClassLoader())));

        _xStream.omitField(HashMap.class, "cache_bitmask");

        Set<XStreamConfigurator> xStreamConfigurators = XStreamConfiguratorRegistryUtil.getXStreamConfigurators();

        if (SetUtil.isEmpty(xStreamConfigurators)) {
            return;
        }

        List<String> allowedTypeNames = new ArrayList<>();

        for (XStreamConfigurator xStreamConfigurator : xStreamConfigurators) {
            List<XStreamAlias> xStreamAliases = xStreamConfigurator.getXStreamAliases();

            if (ListUtil.isNotEmpty(xStreamAliases)) {
                for (XStreamAlias xStreamAlias : xStreamAliases) {
                    _xStream.alias(xStreamAlias.getName(), xStreamAlias.getClazz());
                }
            }

            List<XStreamConverter> xStreamConverters = xStreamConfigurator.getXStreamConverters();

            if (ListUtil.isNotEmpty(xStreamConverters)) {
                for (XStreamConverter xStreamConverter : xStreamConverters) {
                    _xStream.registerConverter(new ConverterAdapter(xStreamConverter), XStream.PRIORITY_VERY_HIGH);
                }
            }

            List<XStreamType> xStreamTypes = xStreamConfigurator.getAllowedXStreamTypes();

            if (ListUtil.isNotEmpty(xStreamTypes)) {
                for (XStreamType xStreamType : xStreamTypes) {
                    allowedTypeNames.add(xStreamType.getTypeExpression());
                }
            }
        }

        // For default permissions, first wipe than add default

        _xStream.addPermission(NoTypePermission.NONE);

        // Add permissions

        _xStream.addPermission(PrimitiveTypePermission.PRIMITIVES);
        _xStream.addPermission(XStreamStagedModelTypeHierarchyPermission.STAGED_MODELS);

        _xStream.allowTypes(_XSTREAM_DEFAULT_ALLOWED_TYPES);

        _xStream.allowTypeHierarchy(List.class);
        _xStream.allowTypeHierarchy(Map.class);
        _xStream.allowTypeHierarchy(Timestamp.class);
        _xStream.allowTypeHierarchy(Set.class);

        _xStream.allowTypes(allowedTypeNames.toArray(new String[0]));

        _xStream.allowTypesByWildcard(new String[] { "com.thoughtworks.xstream.mapper.DynamicProxyMapper*" });
    }
 
开发者ID:inofix,项目名称:ch-inofix-timetracker,代码行数:62,代码来源:BaseExportImportController.java

示例11: addPermission

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
public void addPermission(TypePermission paramTypePermission)
{
  if ((paramTypePermission.equals(NoTypePermission.NONE)) || (paramTypePermission.equals(AnyTypePermission.ANY)))
    this.permissions.clear();
  this.permissions.add(0, paramTypePermission);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:7,代码来源:SecurityMapper.java

示例12: loadFromFile

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
@Override
public List<Song> loadFromFile(File inputFile) {
	LOG.debug("importing songs from file {}", inputFile.getAbsolutePath());
	
	try {
		XStream xstream = new XStream();
		// clear out existing permissions and set own ones
		xstream.addPermission(NoTypePermission.NONE);
		// allow some classes
		xstream.addPermission(NullPermission.NULL);
		xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
		xstream.allowTypeHierarchy(Collection.class);
		xstream.allowTypesByWildcard(new String[] { "java.lang.**", "java.util.**", "java.awt.**",
			"org.zephyrsoft.sdb2.**" });
		// aliases and omitted fields of model classes are defined via annotations
		xstream.processAnnotations(EasiSlides.class);
		xstream.processAnnotations(EasiSlidesSong.class);
		// unknown XML elements can be ignored (e.g. <linkedSongs> which was removed)
		xstream.ignoreUnknownElements();
		
		InputStream xmlInputStream = new FileInputStream(inputFile);
		EasiSlides easiSlides = (EasiSlides) xstream.fromXML(xmlInputStream);
		xmlInputStream.close();
		
		List<Song> songs = new LinkedList<>();
		
		// map EasiSlides items to SDB2 songs
		for (EasiSlidesSong easiSlidesSong : easiSlides.getEasiSlidesSongs()) {
			Song song = new Song(StringTools.createUUID());
			
			song.setTitle(easiSlidesSong.getTitle1());
			String lyrics = easiSlidesSong.getContents().replaceAll("([^\n])\n\\[", "$1\n\n[");
			song.setLyrics(lyrics);
			if (StringUtils.isBlank(easiSlidesSong.getWriter())) {
				easiSlidesSong.setWriter(null);
			}
			if (StringUtils.isBlank(easiSlidesSong.getCopyright())) {
				easiSlidesSong.setCopyright(null);
			}
			if (StringUtils.isBlank(easiSlidesSong.getLicenceAdmin1())) {
				easiSlidesSong.setLicenceAdmin1(null);
			}
			String copyrightNotes = Joiner.on(", ").skipNulls()
				.join(easiSlidesSong.getWriter(), easiSlidesSong.getCopyright(), easiSlidesSong.getLicenceAdmin1());
			song.setAdditionalCopyrightNotes(copyrightNotes);
			
			songs.add(song);
		}
		
		return songs;
	} catch (IOException e) {
		LOG.error("could not import songs from " + inputFile.getAbsolutePath());
		return null;
	}
}
 
开发者ID:mathisdt,项目名称:sdb2,代码行数:56,代码来源:ImportFromEasiSlides.java

示例13: instanciateXStream

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
/**
 * Helper method to create the XStream object used to read and write XML.
 * @return a configured <code>XStream</code> object
 */
private static XStream instanciateXStream() {
    XStream xstream = new XStream(new PureJavaReflectionProvider());

    // setup proper security environment
    xstream.addPermission(NoTypePermission.NONE);
    xstream.addPermission(new WildcardTypePermission(new String[] {"com.imsweb.naaccrxml.**"}));

    xstream.alias("NaaccrDictionary", NaaccrDictionary.class);
    xstream.aliasAttribute(NaaccrDictionary.class, "_dictionaryUri", "dictionaryUri");
    xstream.aliasAttribute(NaaccrDictionary.class, "_naaccrVersion", "naaccrVersion");
    xstream.aliasAttribute(NaaccrDictionary.class, "_specificationVersion", "specificationVersion");
    xstream.aliasAttribute(NaaccrDictionary.class, "_description", "description");
    xstream.aliasAttribute(NaaccrDictionary.class, "_items", "ItemDefs");
    xstream.aliasAttribute(NaaccrDictionary.class, "_groupedItems", "GroupedItemDefs");
    xstream.omitField(NaaccrDictionary.class, "_cachedById");
    xstream.omitField(NaaccrDictionary.class, "_cachedByNumber");

    xstream.alias("ItemDef", NaaccrDictionaryItem.class);
    xstream.aliasAttribute(NaaccrDictionaryItem.class, "_naaccrId", "naaccrId");
    xstream.aliasAttribute(NaaccrDictionaryItem.class, "_naaccrNum", "naaccrNum");
    xstream.aliasAttribute(NaaccrDictionaryItem.class, "_naaccrName", "naaccrName");
    xstream.aliasAttribute(NaaccrDictionaryItem.class, "_startColumn", "startColumn");
    xstream.aliasAttribute(NaaccrDictionaryItem.class, "_length", "length");
    xstream.aliasAttribute(NaaccrDictionaryItem.class, "_recordTypes", "recordTypes");
    xstream.aliasAttribute(NaaccrDictionaryItem.class, "_sourceOfStandard", "sourceOfStandard");
    xstream.aliasAttribute(NaaccrDictionaryItem.class, "_parentXmlElement", "parentXmlElement");
    xstream.aliasAttribute(NaaccrDictionaryItem.class, "_dataType", "dataType");
    xstream.aliasAttribute(NaaccrDictionaryItem.class, "_regexValidation", "regexValidation");
    xstream.aliasAttribute(NaaccrDictionaryItem.class, "_padding", "padding");
    xstream.aliasAttribute(NaaccrDictionaryItem.class, "_trim", "trim");
    xstream.aliasAttribute(NaaccrDictionaryItem.class, "_allowUnlimitedText", "allowUnlimitedText");

    xstream.alias("GroupedItemDef", NaaccrDictionaryGroupedItem.class);
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_naaccrId", "naaccrId");
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_naaccrNum", "naaccrNum");
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_naaccrName", "naaccrName");
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_startColumn", "startColumn");
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_length", "length");
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_recordTypes", "recordTypes");
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_sourceOfStandard", "sourceOfStandard");
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_parentXmlElement", "parentXmlElement");
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_dataType", "dataType");
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_regexValidation", "regexValidation");
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_padding", "padding");
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_trim", "trim");
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_allowUnlimitedText", "allowUnlimitedText");
    xstream.aliasAttribute(NaaccrDictionaryGroupedItem.class, "_contains", "contains");

    return xstream;
}
 
开发者ID:imsweb,项目名称:naaccr-xml,代码行数:55,代码来源:NaaccrXmlDictionaryUtils.java

示例14: addPermission

import com.thoughtworks.xstream.security.NoTypePermission; //导入依赖的package包/类
/**
 * Add a new permission.
 * <p>
 * Permissions are evaluated in the added sequence. An instance of {@link NoTypePermission} or
 * {@link AnyTypePermission} will implicitly wipe any existing permission.
 * </p>
 * 
 * @param permission the permission to add.
 * @since 1.4.7
 */
public void addPermission(final TypePermission permission) {
    if (permission.equals(NoTypePermission.NONE) || permission.equals(AnyTypePermission.ANY)) {
        permissions.clear();
    }
    permissions.add(0, permission);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:SecurityMapper.java


注:本文中的com.thoughtworks.xstream.security.NoTypePermission类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。