Example usage for java.lang.reflect ReflectPermission ReflectPermission

List of usage examples for java.lang.reflect ReflectPermission ReflectPermission

Introduction

In this page you can find the example usage for java.lang.reflect ReflectPermission ReflectPermission.

Prototype

public ReflectPermission(String name) 

Source Link

Document

Constructs a ReflectPermission with the specified name.

Usage

From source file:com.thoughtworks.acceptance.SecurityManagerTest.java

public void testSerializeWithXppDriverAndSun14ReflectionProviderAndActiveSecurityManager() {
    sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.reflect"));
    sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.misc"));
    sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.text.resources"));
    sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.util.resources"));
    sm.addPermission(source, new RuntimePermission("accessDeclaredMembers"));
    sm.addPermission(source, new RuntimePermission("createClassLoader"));
    sm.addPermission(source, new RuntimePermission("fileSystemProvider"));
    sm.addPermission(source, new RuntimePermission("loadLibrary.nio"));
    sm.addPermission(source, new RuntimePermission("modifyThreadGroup"));
    sm.addPermission(source, new RuntimePermission("reflectionFactoryAccess"));
    sm.addPermission(source, new PropertyPermission("ibm.dst.compatibility", "read"));
    sm.addPermission(source, new PropertyPermission("java.home", "read"));
    sm.addPermission(source, new PropertyPermission("java.nio.file.spi.DefaultFileSystemProvider", "read"));
    sm.addPermission(source, new PropertyPermission("java.security.debug", "read"));
    sm.addPermission(source, new PropertyPermission("javax.xml.datatype.DatatypeFactory", "read"));
    sm.addPermission(source, new PropertyPermission("jaxp.debug", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.util.TimeZone.allowSetDefault", "read"));
    sm.addPermission(source, new PropertyPermission("sun.boot.class.path", "read"));
    sm.addPermission(source, new PropertyPermission("sun.nio.fs.chdirAllowed", "read"));
    sm.addPermission(source, new PropertyPermission("sun.timezone.ids.oldmapping", "read"));
    sm.addPermission(source, new PropertyPermission("user.country", "read"));
    sm.addPermission(source, new PropertyPermission("user.dir", "read"));
    sm.addPermission(source, new PropertyPermission("user.timezone", "read,write"));
    sm.addPermission(source, new ReflectPermission("suppressAccessChecks"));
    sm.addPermission(source, new NetPermission("specifyStreamHandler"));
    sm.setReadOnly();/*  w w  w  .  ja  v  a 2s .co m*/
    System.setSecurityManager(sm);

    xstream = new XStream();
    xstream.allowTypesByWildcard(AbstractAcceptanceTest.class.getPackage().getName() + ".*objects.**");
    xstream.allowTypesByWildcard(this.getClass().getName() + "$*");

    assertBothWays();
}

From source file:com.nanyou.framework.jdbc.sql.beans.ClassInfo.java

private boolean canAccessPrivateMethods() {
    try {//w ww .  ja  v  a 2  s .  c om
        System.getSecurityManager().checkPermission(new ReflectPermission("suppressAccessChecks"));
        return true;
    } catch (SecurityException e) {
        return false;
    } catch (NullPointerException e) {
        return true;
    }
}

From source file:com.thoughtworks.acceptance.SecurityManagerTest.java

public void testSerializeWithXppDriverAndPureJavaReflectionProviderAndActiveSecurityManager() {
    sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.misc"));
    sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.text.resources"));
    sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.util.resources"));
    sm.addPermission(source, new RuntimePermission("accessDeclaredMembers"));
    sm.addPermission(source, new RuntimePermission("createClassLoader"));
    sm.addPermission(source, new RuntimePermission("fileSystemProvider"));
    sm.addPermission(source, new RuntimePermission("loadLibrary.nio"));
    sm.addPermission(source, new RuntimePermission("modifyThreadGroup"));
    sm.addPermission(source, new PropertyPermission("ibm.dst.compatibility", "read"));
    sm.addPermission(source, new PropertyPermission("java.home", "read"));
    sm.addPermission(source, new PropertyPermission("java.nio.file.spi.DefaultFileSystemProvider", "read"));
    sm.addPermission(source, new PropertyPermission("java.security.debug", "read"));
    sm.addPermission(source, new PropertyPermission("javax.xml.datatype.DatatypeFactory", "read"));
    sm.addPermission(source, new PropertyPermission("jaxp.debug", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.util.TimeZone.allowSetDefault", "read"));
    sm.addPermission(source, new PropertyPermission("sun.boot.class.path", "read"));
    sm.addPermission(source, new PropertyPermission("sun.io.serialization.extendedDebugInfo", "read"));
    sm.addPermission(source, new PropertyPermission("sun.nio.fs.chdirAllowed", "read"));
    sm.addPermission(source, new PropertyPermission("sun.timezone.ids.oldmapping", "read"));
    sm.addPermission(source, new PropertyPermission("user.country", "read"));
    sm.addPermission(source, new PropertyPermission("user.dir", "read"));
    sm.addPermission(source, new PropertyPermission("user.timezone", "read,write"));
    sm.addPermission(source, new ReflectPermission("suppressAccessChecks"));
    sm.addPermission(source, new NetPermission("specifyStreamHandler"));
    sm.setReadOnly();//from   w ww. j  a  va2 s.  c om
    System.setSecurityManager(sm);

    xstream = new XStream(new PureJavaReflectionProvider());
    xstream.allowTypesByWildcard(AbstractAcceptanceTest.class.getPackage().getName() + ".*objects.**");
    xstream.allowTypesByWildcard(this.getClass().getName() + "$*");

    assertBothWays();
}

From source file:com.thoughtworks.acceptance.SecurityManagerTest.java

public void testSerializeWithDomDriverAndPureJavaReflectionProviderAndActiveSecurityManager() {
    sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.text.resources"));
    sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.util.resources"));
    sm.addPermission(source, new RuntimePermission("accessDeclaredMembers"));
    sm.addPermission(source, new RuntimePermission("createClassLoader"));
    sm.addPermission(source, new RuntimePermission("fileSystemProvider"));
    sm.addPermission(source, new RuntimePermission("loadLibrary.nio"));
    sm.addPermission(source, new RuntimePermission("modifyThreadGroup"));
    sm.addPermission(source, new RuntimePermission("reflectionFactoryAccess"));
    sm.addPermission(source, new PropertyPermission(
            "com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration", "read"));
    sm.addPermission(source, new PropertyPermission("elementAttributeLimit", "read"));
    sm.addPermission(source, new PropertyPermission("entityExpansionLimit", "read"));
    sm.addPermission(source,/*from   w  w  w  .jav  a 2 s . com*/
            new PropertyPermission("http://java.sun.com/xml/dom/properties/ancestor-check", "read"));
    sm.addPermission(source, new PropertyPermission("ibm.dst.compatibility", "read"));
    sm.addPermission(source, new PropertyPermission("java.home", "read"));
    sm.addPermission(source, new PropertyPermission("java.nio.file.spi.DefaultFileSystemProvider", "read"));
    sm.addPermission(source, new PropertyPermission("java.security.debug", "read"));
    sm.addPermission(source, new PropertyPermission("javax.xml.datatype.DatatypeFactory", "read"));
    sm.addPermission(source, new PropertyPermission("javax.xml.parsers.DocumentBuilderFactory", "read"));
    sm.addPermission(source, new PropertyPermission("javax.xml.accessExternalDTD", "read"));
    sm.addPermission(source, new PropertyPermission("javax.xml.accessExternalSchema", "read"));
    sm.addPermission(source, new PropertyPermission("jaxp.debug", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.util.TimeZone.allowSetDefault", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.elementAttributeLimit", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.entityExpansionLimit", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.maxElementDepth", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.maxGeneralEntitySizeLimit", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.maxParameterEntitySizeLimit", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.maxOccurLimit", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.maxXMLNameLimit", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.totalEntitySizeLimit", "read"));
    sm.addPermission(source, new PropertyPermission("maxOccurLimit", "read"));
    sm.addPermission(source, new PropertyPermission("sun.boot.class.path", "read"));
    sm.addPermission(source, new PropertyPermission("sun.nio.fs.chdirAllowed", "read"));
    sm.addPermission(source, new PropertyPermission("sun.timezone.ids.oldmapping", "read"));
    sm.addPermission(source, new PropertyPermission("user.country", "read"));
    sm.addPermission(source, new PropertyPermission("user.dir", "read"));
    sm.addPermission(source, new PropertyPermission("user.timezone", "read,write"));
    sm.addPermission(source, new NetPermission("specifyStreamHandler"));
    sm.addPermission(source, new ReflectPermission("suppressAccessChecks"));
    sm.setReadOnly();
    System.setSecurityManager(sm);

    xstream = new XStream(new PureJavaReflectionProvider(), new DomDriver());
    xstream.allowTypesByWildcard(AbstractAcceptanceTest.class.getPackage().getName() + ".*objects.**");
    xstream.allowTypesByWildcard(this.getClass().getName() + "$*");

    assertBothWays();
}