java类java.net.NetPermission的实例源码

PolicyFile.java 文件源码 项目:OpenJSharp 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Creates one of the well-known permissions directly instead of
 * via reflection. Keep list short to not penalize non-JDK-defined
 * permissions.
 */
private static final Permission getKnownInstance(Class<?> claz,
    String name, String actions) {
    if (claz.equals(FilePermission.class)) {
        return new FilePermission(name, actions);
    } else if (claz.equals(SocketPermission.class)) {
        return new SocketPermission(name, actions);
    } else if (claz.equals(RuntimePermission.class)) {
        return new RuntimePermission(name, actions);
    } else if (claz.equals(PropertyPermission.class)) {
        return new PropertyPermission(name, actions);
    } else if (claz.equals(NetPermission.class)) {
        return new NetPermission(name, actions);
    } else if (claz.equals(AllPermission.class)) {
        return SecurityConstants.ALL_PERMISSION;
    } else {
        return null;
    }
}
PolicyFile.java 文件源码 项目:jdk8u-jdk 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Creates one of the well-known permissions directly instead of
 * via reflection. Keep list short to not penalize non-JDK-defined
 * permissions.
 */
private static final Permission getKnownInstance(Class<?> claz,
    String name, String actions) {
    if (claz.equals(FilePermission.class)) {
        return new FilePermission(name, actions);
    } else if (claz.equals(SocketPermission.class)) {
        return new SocketPermission(name, actions);
    } else if (claz.equals(RuntimePermission.class)) {
        return new RuntimePermission(name, actions);
    } else if (claz.equals(PropertyPermission.class)) {
        return new PropertyPermission(name, actions);
    } else if (claz.equals(NetPermission.class)) {
        return new NetPermission(name, actions);
    } else if (claz.equals(AllPermission.class)) {
        return SecurityConstants.ALL_PERMISSION;
    } else {
        return null;
    }
}
PolicyFile.java 文件源码 项目:openjdk-jdk10 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Creates one of the well-known permissions in the java.base module
 * directly instead of via reflection. Keep list short to not penalize
 * permissions from other modules.
 */
private static Permission getKnownPermission(Class<?> claz, String name,
                                             String actions) {
    if (claz.equals(FilePermission.class)) {
        return new FilePermission(name, actions);
    } else if (claz.equals(SocketPermission.class)) {
        return new SocketPermission(name, actions);
    } else if (claz.equals(RuntimePermission.class)) {
        return new RuntimePermission(name, actions);
    } else if (claz.equals(PropertyPermission.class)) {
        return new PropertyPermission(name, actions);
    } else if (claz.equals(NetPermission.class)) {
        return new NetPermission(name, actions);
    } else if (claz.equals(AllPermission.class)) {
        return SecurityConstants.ALL_PERMISSION;
    } else if (claz.equals(SecurityPermission.class)) {
        return new SecurityPermission(name, actions);
    } else {
        return null;
    }
}
GetAuthenticatorTest.java 文件源码 项目:openjdk-jdk10 阅读 24 收藏 0 点赞 0 评论 0
public static void main (String args[]) throws Exception {
    Authenticator defaultAuth = Authenticator.getDefault();
    if (defaultAuth != null) {
        throw new RuntimeException("Unexpected authenticator: null expected");
    }
    MyAuthenticator auth = new MyAuthenticator();
    Authenticator.setDefault(auth);
    defaultAuth = Authenticator.getDefault();
    if (defaultAuth != auth) {
        throw new RuntimeException("Unexpected authenticator: auth expected");
    }
    System.setSecurityManager(new SecurityManager());
    try {
        defaultAuth = Authenticator.getDefault();
        throw new RuntimeException("Expected security exception not raised");
    } catch (AccessControlException s) {
        System.out.println("Got expected exception: " + s);
        if (!s.getPermission().equals(new NetPermission("requestPasswordAuthentication"))) {
            throw new RuntimeException("Unexpected permission check: " + s.getPermission());
        }
    }
    System.out.println("Test passed with default authenticator "
                       + defaultAuth);
}
PolicyFile.java 文件源码 项目:openjdk9 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Creates one of the well-known permissions in the java.base module
 * directly instead of via reflection. Keep list short to not penalize
 * permissions from other modules.
 */
private static Permission getKnownPermission(Class<?> claz, String name,
                                             String actions) {
    if (claz.equals(FilePermission.class)) {
        return new FilePermission(name, actions);
    } else if (claz.equals(SocketPermission.class)) {
        return new SocketPermission(name, actions);
    } else if (claz.equals(RuntimePermission.class)) {
        return new RuntimePermission(name, actions);
    } else if (claz.equals(PropertyPermission.class)) {
        return new PropertyPermission(name, actions);
    } else if (claz.equals(NetPermission.class)) {
        return new NetPermission(name, actions);
    } else if (claz.equals(AllPermission.class)) {
        return SecurityConstants.ALL_PERMISSION;
    } else if (claz.equals(SecurityPermission.class)) {
        return new SecurityPermission(name, actions);
    } else {
        return null;
    }
}
PolicyFile.java 文件源码 项目:jdk8u_jdk 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Creates one of the well-known permissions directly instead of
 * via reflection. Keep list short to not penalize non-JDK-defined
 * permissions.
 */
private static final Permission getKnownInstance(Class<?> claz,
    String name, String actions) {
    if (claz.equals(FilePermission.class)) {
        return new FilePermission(name, actions);
    } else if (claz.equals(SocketPermission.class)) {
        return new SocketPermission(name, actions);
    } else if (claz.equals(RuntimePermission.class)) {
        return new RuntimePermission(name, actions);
    } else if (claz.equals(PropertyPermission.class)) {
        return new PropertyPermission(name, actions);
    } else if (claz.equals(NetPermission.class)) {
        return new NetPermission(name, actions);
    } else if (claz.equals(AllPermission.class)) {
        return SecurityConstants.ALL_PERMISSION;
    } else {
        return null;
    }
}
PolicyFile.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Creates one of the well-known permissions directly instead of
 * via reflection. Keep list short to not penalize non-JDK-defined
 * permissions.
 */
private static final Permission getKnownInstance(Class<?> claz,
    String name, String actions) {
    if (claz.equals(FilePermission.class)) {
        return new FilePermission(name, actions);
    } else if (claz.equals(SocketPermission.class)) {
        return new SocketPermission(name, actions);
    } else if (claz.equals(RuntimePermission.class)) {
        return new RuntimePermission(name, actions);
    } else if (claz.equals(PropertyPermission.class)) {
        return new PropertyPermission(name, actions);
    } else if (claz.equals(NetPermission.class)) {
        return new NetPermission(name, actions);
    } else if (claz.equals(AllPermission.class)) {
        return SecurityConstants.ALL_PERMISSION;
    } else {
        return null;
    }
}
PluginSandboxPolicy.java 文件源码 项目:rapidminer-studio 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Adds a couple of common permissions for both unsigned extensions as well as Groovy scripts.
 *
 * @param permissions
 *            the permissions object which will get the permissions added to it
 */
private static void addCommonPermissions(Permissions permissions) {
    permissions.add(new AudioPermission("play"));
    permissions.add(new AWTPermission("listenToAllAWTEvents"));
    permissions.add(new AWTPermission("setWindowAlwaysOnTop"));
    permissions.add(new AWTPermission("watchMousePointer"));
    permissions.add(new LoggingPermission("control", ""));
    permissions.add(new SocketPermission("*", "connect, listen, accept, resolve"));
    permissions.add(new URLPermission("http://-", "*:*"));
    permissions.add(new URLPermission("https://-", "*:*"));

    // because random Java library calls use sun classes which may or may not do an acess check,
    // we have to grant access to all of them
    // this is a very unfortunate permission and I would love to not have it
    // so if at any point in the future this won't be necessary any longer, remove it!!!
    permissions.add(new RuntimePermission("accessClassInPackage.sun.*"));

    permissions.add(new RuntimePermission("accessDeclaredMembers"));
    permissions.add(new RuntimePermission("getenv.*"));
    permissions.add(new RuntimePermission("getFileSystemAttributes"));
    permissions.add(new RuntimePermission("readFileDescriptor"));
    permissions.add(new RuntimePermission("writeFileDescriptor"));
    permissions.add(new RuntimePermission("queuePrintJob"));
    permissions.add(new NetPermission("specifyStreamHandler"));
}
SecurityDialogs.java 文件源码 项目:icedtea-web 阅读 14 收藏 0 点赞 0 评论 0
/**
 * Present a dialog to the user asking them for authentication information,
 * and returns the user's response. The caller must have
 * NetPermission("requestPasswordAuthentication") for this to work.
 *
 * @param host The host for with authentication is needed
 * @param port The port being accessed
 * @param prompt The prompt (realm) as presented by the server
 * @param type The type of server (proxy/web)
 * @return an array of objects representing user's authentication tokens
 * @throws SecurityException if the caller does not have the appropriate permissions.
 */
public static NamePassword showAuthenicationPrompt(String host, int port, String prompt, String type) {

    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        NetPermission requestPermission
            = new NetPermission("requestPasswordAuthentication");
        sm.checkPermission(requestPermission);
    }

    final SecurityDialogMessage message = new SecurityDialogMessage(null);

    message.dialogType = DialogType.AUTHENTICATION;
    message.extras = new Object[] { host, port, prompt, type };

    DialogResult response = getUserResponse(message);
    OutputController.getLogger().log(OutputController.Level.MESSAGE_DEBUG, "Decided action for matching alaca at  was " + response);
    return (NamePassword) response;
}
PolicyFile.java 文件源码 项目:infobip-open-jdk-8 阅读 29 收藏 0 点赞 0 评论 0
/**
 * Creates one of the well-known permissions directly instead of
 * via reflection. Keep list short to not penalize non-JDK-defined
 * permissions.
 */
private static final Permission getKnownInstance(Class<?> claz,
    String name, String actions) {
    if (claz.equals(FilePermission.class)) {
        return new FilePermission(name, actions);
    } else if (claz.equals(SocketPermission.class)) {
        return new SocketPermission(name, actions);
    } else if (claz.equals(RuntimePermission.class)) {
        return new RuntimePermission(name, actions);
    } else if (claz.equals(PropertyPermission.class)) {
        return new PropertyPermission(name, actions);
    } else if (claz.equals(NetPermission.class)) {
        return new NetPermission(name, actions);
    } else if (claz.equals(AllPermission.class)) {
        return SecurityConstants.ALL_PERMISSION;
    } else {
        return null;
    }
}
PolicyFile.java 文件源码 项目:jdk8u-dev-jdk 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Creates one of the well-known permissions directly instead of
 * via reflection. Keep list short to not penalize non-JDK-defined
 * permissions.
 */
private static final Permission getKnownInstance(Class<?> claz,
    String name, String actions) {
    if (claz.equals(FilePermission.class)) {
        return new FilePermission(name, actions);
    } else if (claz.equals(SocketPermission.class)) {
        return new SocketPermission(name, actions);
    } else if (claz.equals(RuntimePermission.class)) {
        return new RuntimePermission(name, actions);
    } else if (claz.equals(PropertyPermission.class)) {
        return new PropertyPermission(name, actions);
    } else if (claz.equals(NetPermission.class)) {
        return new NetPermission(name, actions);
    } else if (claz.equals(AllPermission.class)) {
        return SecurityConstants.ALL_PERMISSION;
    } else {
        return null;
    }
}
OldResponseCacheTest.java 文件源码 项目:In-the-Box-Fork 阅读 15 收藏 0 点赞 0 评论 0
public void checkPermission(Permission permission) {
    if (permission instanceof NetPermission) {
        if ("setResponseCache".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof NetPermission) {
        if ("getResponseCache".equals(permission.getName())) {

            throw new SecurityException();
        }
    }

    if (permission instanceof RuntimePermission) {
        if ("setSecurityManager".equals(permission.getName())) {
            return;
        }
    }
}
PolicyFile.java 文件源码 项目:OLD-OpenJDK8 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Creates one of the well-known permissions directly instead of
 * via reflection. Keep list short to not penalize non-JDK-defined
 * permissions.
 */
private static final Permission getKnownInstance(Class<?> claz,
    String name, String actions) {
    if (claz.equals(FilePermission.class)) {
        return new FilePermission(name, actions);
    } else if (claz.equals(SocketPermission.class)) {
        return new SocketPermission(name, actions);
    } else if (claz.equals(RuntimePermission.class)) {
        return new RuntimePermission(name, actions);
    } else if (claz.equals(PropertyPermission.class)) {
        return new PropertyPermission(name, actions);
    } else if (claz.equals(NetPermission.class)) {
        return new NetPermission(name, actions);
    } else if (claz.equals(AllPermission.class)) {
        return SecurityConstants.ALL_PERMISSION;
    } else {
        return null;
    }
}
CookieHandlerTest.java 文件源码 项目:cn1 阅读 17 收藏 0 点赞 0 评论 0
public void checkPermission(Permission permission) {
    if (permission instanceof NetPermission) {
        if ("setCookieHandler".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof NetPermission) {
        if ("getCookieHandler".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof RuntimePermission) {
        if ("setSecurityManager".equals(permission.getName())) {
            return;
        }
    }
}
ResponseCacheTest.java 文件源码 项目:cn1 阅读 19 收藏 0 点赞 0 评论 0
public void checkPermission(Permission permission) {
    if (permission instanceof NetPermission) {
        if ("setResponseCache".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof NetPermission) {
        if ("getResponseCache".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof RuntimePermission) {
        if ("setSecurityManager".equals(permission.getName())) {
            return;
        }
    }
}
ProxySelectorTest.java 文件源码 项目:cn1 阅读 15 收藏 0 点赞 0 评论 0
public void checkPermission(Permission permission) {
    if (permission instanceof NetPermission) {
        if ("getProxySelector".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof NetPermission) {
        if ("setProxySelector".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof RuntimePermission) {
        if ("setSecurityManager".equals(permission.getName())) {
            return;
        }
    }
}
CookieHandlerTest.java 文件源码 项目:freeVM 阅读 17 收藏 0 点赞 0 评论 0
public void checkPermission(Permission permission) {
    if (permission instanceof NetPermission) {
        if ("setCookieHandler".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof NetPermission) {
        if ("getCookieHandler".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof RuntimePermission) {
        if ("setSecurityManager".equals(permission.getName())) {
            return;
        }
    }
}
ResponseCacheTest.java 文件源码 项目:freeVM 阅读 35 收藏 0 点赞 0 评论 0
public void checkPermission(Permission permission) {
    if (permission instanceof NetPermission) {
        if ("setResponseCache".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof NetPermission) {
        if ("getResponseCache".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof RuntimePermission) {
        if ("setSecurityManager".equals(permission.getName())) {
            return;
        }
    }
}
ProxySelectorTest.java 文件源码 项目:freeVM 阅读 15 收藏 0 点赞 0 评论 0
public void checkPermission(Permission permission) {
    if (permission instanceof NetPermission) {
        if ("getProxySelector".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof NetPermission) {
        if ("setProxySelector".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof RuntimePermission) {
        if ("setSecurityManager".equals(permission.getName())) {
            return;
        }
    }
}
CookieHandlerTest.java 文件源码 项目:freeVM 阅读 20 收藏 0 点赞 0 评论 0
public void checkPermission(Permission permission) {
    if (permission instanceof NetPermission) {
        if ("setCookieHandler".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof NetPermission) {
        if ("getCookieHandler".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof RuntimePermission) {
        if ("setSecurityManager".equals(permission.getName())) {
            return;
        }
    }
}
ResponseCacheTest.java 文件源码 项目:freeVM 阅读 31 收藏 0 点赞 0 评论 0
public void checkPermission(Permission permission) {
    if (permission instanceof NetPermission) {
        if ("setResponseCache".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof NetPermission) {
        if ("getResponseCache".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof RuntimePermission) {
        if ("setSecurityManager".equals(permission.getName())) {
            return;
        }
    }
}
ProxySelectorTest.java 文件源码 项目:freeVM 阅读 16 收藏 0 点赞 0 评论 0
public void checkPermission(Permission permission) {
    if (permission instanceof NetPermission) {
        if ("getProxySelector".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof NetPermission) {
        if ("setProxySelector".equals(permission.getName())) {
            throw new SecurityException();
        }
    }

    if (permission instanceof RuntimePermission) {
        if ("setSecurityManager".equals(permission.getName())) {
            return;
        }
    }
}
SideEffectSecurityManager.java 文件源码 项目:marshalsec 阅读 22 收藏 0 点赞 0 评论 0
/**
 * {@inheritDoc}
 *
 * @see java.lang.SecurityManager#checkPermission(java.security.Permission)
 */
@Override
public void checkPermission ( Permission perm ) {
    if ( perm instanceof RuntimePermission ) {
        if ( checkRuntimePermission((RuntimePermission) perm) ) {
            return;
        }
    }
    else if ( perm instanceof ReflectPermission ) {
        return;
    }
    else if ( perm instanceof LoggingPermission ) {
        return;
    }
    else if ( perm instanceof SecurityPermission ) {
        return;
    }
    else if ( perm instanceof PropertyPermission ) {
        return;
    }
    else if ( perm instanceof NetPermission && perm.getName().equals("specifyStreamHandler") ) {
        return;
    }
    else if ( perm instanceof FilePermission && perm.getActions().equals("read") ) {
        return;
    }
    else if ( perm instanceof SerializablePermission ) {
        return;
    }

    super.checkPermission(perm);
}
Utils.java 文件源码 项目:openjdk-jdk10 阅读 18 收藏 0 点赞 0 评论 0
public static void checkNetPermission(String target) {
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        return;
    }
    NetPermission np = new NetPermission(target);
    sm.checkPermission(np);
}
LookupTest.java 文件源码 项目:openjdk-jdk10 阅读 24 收藏 0 点赞 0 评论 0
LookupTestPolicy() throws Exception {
    perms.add(new NetPermission("setProxySelector"));
    perms.add(new SocketPermission("localhost:1024-", "resolve,accept"));
    perms.add(new URLPermission("http://allowedAndFound.com:" + port + "/-", "*:*"));
    perms.add(new URLPermission("http://allowedButNotfound.com:" + port + "/-", "*:*"));
    perms.add(new FilePermission("<<ALL FILES>>", "read,write,delete"));
    //perms.add(new PropertyPermission("java.io.tmpdir", "read"));
}
Utils.java 文件源码 项目:openjdk9 阅读 23 收藏 0 点赞 0 评论 0
static void checkNetPermission(String target) {
    SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        return;
    NetPermission np = new NetPermission(target);
    sm.checkPermission(np);
}
SecurityManagerTest.java 文件源码 项目:xstream 阅读 18 收藏 0 点赞 0 评论 0
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();
    System.setSecurityManager(sm);

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

    assertBothWays();
}
SecurityManagerTest.java 文件源码 项目:xstream 阅读 21 收藏 0 点赞 0 评论 0
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();
    System.setSecurityManager(sm);

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

    assertBothWays();
}
MSecurityManager.java 文件源码 项目:evosuite 阅读 26 收藏 0 点赞 0 评论 0
protected boolean checkNetPermission(NetPermission perm) {
    /*
     * "specifyStreamHandler" seems the only tricky one. But because a URL cannot be used to write to file-system (although it can be used for
     * remote resources), it should be fine
     */
    return true;
}
PipeTest.java 文件源码 项目:cn1 阅读 31 收藏 0 点赞 0 评论 0
public void checkPermission(Permission permission) {
    if (permission instanceof NetPermission) {
        throw new SecurityException();
    }

    if (permission instanceof RuntimePermission) {
        if ("setSecurityManager".equals(permission.getName())) {
            return;
        }
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号