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


Java LoggingPermission类代码示例

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


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

示例1: SimplePolicy

import java.util.logging.LoggingPermission; //导入依赖的package包/类
public SimplePolicy(TestCase test, AtomicBoolean allowAll) {
    this.allowAll = allowAll;
    permissions = new Permissions();
    permissions.add(new LoggingPermission("control", null)); // needed by new FileHandler()
    permissions.add(new FilePermission("<<ALL FILES>>", "read")); // needed by new FileHandler()
    permissions.add(new FilePermission(logFile, "write,delete")); // needed by new FileHandler()
    permissions.add(new FilePermission(logFile+".lck", "write,delete")); // needed by FileHandler.close()
    permissions.add(new FilePermission(logFile+".1", "write,delete")); // needed by new FileHandler()
    permissions.add(new FilePermission(logFile+".1.lck", "write,delete")); // needed by FileHandler.close()
    permissions.add(new FilePermission(tmpLogFile, "write,delete")); // needed by new FileHandler()
    permissions.add(new FilePermission(tmpLogFile+".lck", "write,delete")); // needed by FileHandler.close()
    permissions.add(new FilePermission(tmpLogFile+".1", "write,delete")); // needed by new FileHandler()
    permissions.add(new FilePermission(tmpLogFile+".1.lck", "write,delete")); // needed by FileHandler.close()
    permissions.add(new FilePermission(userDir, "write")); // needed by new FileHandler()
    permissions.add(new FilePermission(tmpDir, "write")); // needed by new FileHandler()
    permissions.add(new PropertyPermission("user.dir", "read"));
    permissions.add(new PropertyPermission("java.io.tmpdir", "read"));
    allPermissions = new Permissions();
    allPermissions.add(new java.security.AllPermission());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:FileHandlerPath.java

示例2: testPermission

import java.util.logging.LoggingPermission; //导入依赖的package包/类
/**
 * Test the LoggingPermission("control") is required.
 * @param loggerName The logger to use.
 */
public static void testPermission(String loggerName) {
    if (System.getSecurityManager() != null) {
        throw new Error("Security manager is already set");
    }
    Policy.setPolicy(new SimplePolicy(TestCase.PERMISSION));
    System.setSecurityManager(new SecurityManager());
    final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME);
    Logger foobar = Logger.getLogger(loggerName);
    try {
        foobar.setResourceBundle(bundle);
        throw new RuntimeException("Permission not checked!");
    } catch (AccessControlException x) {
        if (x.getPermission() instanceof LoggingPermission) {
            if ("control".equals(x.getPermission().getName())) {
                System.out.println("Got expected exception: " + x);
                return;
            }
        }
        throw new RuntimeException("Unexpected exception: "+x, x);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:TestSetResourceBundle.java

示例3: SimplePolicy

import java.util.logging.LoggingPermission; //导入依赖的package包/类
public SimplePolicy(TestCase test) {
    basic = new Permissions();
    control = new Permissions();
    control.add(new LoggingPermission("control", null));

    // These permissions are required to call updateConfiguration(Function)
    control.add(new PropertyPermission("java.util.logging.config.file", "read"));
    control.add(new PropertyPermission("java.home", "read"));
    control.add(new FilePermission(
            Paths.get(System.getProperty("user.dir", "."),"-").toString(), "read"));
    control.add(new FilePermission(
            Paths.get(System.getProperty("java.home"),"conf","-").toString(), "read"));

    // these are used for configuring the test itself...
    all = new Permissions();
    all.add(new java.security.AllPermission());

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:SimpleUpdateConfigurationTest.java

示例4: addCommonPermissions

import java.util.logging.LoggingPermission; //导入依赖的package包/类
/**
 * 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"));
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:31,代码来源:PluginSandboxPolicy.java

示例5: grantMode

import java.util.logging.LoggingPermission; //导入依赖的package包/类
/**
 * Sets grant mode
 * all permissions are denied, test can only grant specific permission
 */
public void grantMode() {
    mode = false;

    permissionsDenied.add(new AllPermission());
    permissionsGranted = new Permissions();

    // junit harness stuff
    permissionsGranted
            .add(new PropertyPermission("line.separator", "read"));
    permissionsGranted.add(new RuntimePermission("exitVM"));
    permissionsGranted.add(new LoggingPermission("control", null));

    //grant permission to install security manager :-)
    permissionsGranted.add(new RuntimePermission("setSecurityManager"));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:SecurityTest.java

示例6: setLog

import java.util.logging.LoggingPermission; //导入依赖的package包/类
/**
 * @ar.org.fitc.spec_ref
 * 
 */
public static void setLog(OutputStream out) {

	// Check security permission as stated in specification
	SecurityManager security = System.getSecurityManager();
	if (security != null) {
		security.checkPermission(new LoggingPermission("control", null));
	}

	logger.removeHandler(logHandler);
	if (out != null) {
		logStream = new PrintStream(out);
		logHandler = new PrintStreamHandler(logStream);
		logHandler.setLevel(Level.ALL);
		logger.addHandler(logHandler);
	} else {
		logStream = null;
	}
	return;
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:24,代码来源:RemoteServer.java

示例7: checkPermission

import java.util.logging.LoggingPermission; //导入依赖的package包/类
/**
 * {@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);
}
 
开发者ID:mbechler,项目名称:marshalsec,代码行数:37,代码来源:SideEffectSecurityManager.java

示例8: TestPolicy

import java.util.logging.LoggingPermission; //导入依赖的package包/类
public TestPolicy(String policy) {

        switch (policy) {
            case "all":
                permissions.add(new AllPermission());
                break;
            case "setLog":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setLog"));
                break;
            case "deregisterDriver":
                setMinimalPermissions();
                permissions.add(new SQLPermission("deregisterDriver"));
                break;
            case "setSyncFactory":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                break;
            case "setSyncFactoryLogger":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                permissions.add(new LoggingPermission("control", null));
                break;
            default:
                setMinimalPermissions();
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:TestPolicy.java

示例9: SimplePolicy

import java.util.logging.LoggingPermission; //导入依赖的package包/类
public SimplePolicy(TestCase test) {
    permissions = new Permissions();
    if (test != TestCase.PERMISSION) {
        permissions.add(new LoggingPermission("control", null));
    }
    // required for calling Locale.setDefault in the test.
    permissions.add(new PropertyPermission("user.language", "write"));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:TestSetResourceBundle.java

示例10: init

import java.util.logging.LoggingPermission; //导入依赖的package包/类
public static void init() {
    SharedSecrets.setJavaAWTAccess(javaAwtAccess);
    if (System.getProperty("test.security", "on").equals("on")) {
        Policy p = new SimplePolicy(new LoggingPermission("control", null),
            new RuntimePermission("setContextClassLoader"),
            new RuntimePermission("shutdownHooks"));
        Policy.setPolicy(p);
        System.setSecurityManager(new SecurityManager());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TestAppletLoggerContext.java

示例11: SimplePolicy

import java.util.logging.LoggingPermission; //导入依赖的package包/类
public SimplePolicy(String configFile) {
    perms.add(new LoggingPermission("control", null));
    perms.add(new PropertyPermission("java.util.logging.config.class","read"));
    perms.add(new PropertyPermission("java.util.logging.config.file","read"));
    perms.add(new FilePermission(configFile, "read"));
    perms.add(new RuntimePermission("accessClassInPackage.sun.misc"));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:RootLevelInConfigFile.java

示例12: SimplePolicy

import java.util.logging.LoggingPermission; //导入依赖的package包/类
public SimplePolicy(TestCase test, AtomicBoolean allowAll) {
    this.allowAll = allowAll;
    permissions = new Permissions();
    permissions.add(new LoggingPermission("control", null));
    permissions.add(new FilePermission(PREFIX+".lck", "read,write,delete"));
    permissions.add(new FilePermission(PREFIX, "read,write"));

    // these are used for configuring the test itself...
    allPermissions = new Permissions();
    allPermissions.add(new java.security.AllPermission());

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:FileHandlerLongLimit.java

示例13: SimplePolicy

import java.util.logging.LoggingPermission; //导入依赖的package包/类
public SimplePolicy(TestCase test) {
    permissions = new Permissions();
    if (test != TestCase.PERMISSION) {
        permissions.add(new LoggingPermission("control", null));
        permissions.add(new PropertyPermission("java.util.logging.config.class", "read"));
        permissions.add(new PropertyPermission("java.util.logging.config.file", "read"));
        permissions.add(new PropertyPermission("java.home", "read"));
        permissions.add(new FilePermission("<<ALL FILES>>", "read"));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:TestConfigurationListeners.java

示例14: SimplePolicy

import java.util.logging.LoggingPermission; //导入依赖的package包/类
public SimplePolicy(TestCase test, ThreadLocal<AtomicBoolean> allowAll) {
    this.allowAll = allowAll;
    permissions = new Permissions();
    permissions.add(new LoggingPermission("control", null));
    permissions.add(new FilePermission(PREFIX+".lck", "read,write,delete"));
    permissions.add(new FilePermission(PREFIX, "read,write"));

    // these are used for configuring the test itself...
    allPermissions = new Permissions();
    allPermissions.add(new java.security.AllPermission());

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:HandlersOnComplexUpdate.java

示例15: SimplePolicy

import java.util.logging.LoggingPermission; //导入依赖的package包/类
public SimplePolicy(TestCase test) {
    basic = new Permissions();
    control = new Permissions();
    control.add(new LoggingPermission("control", null));

    // these are used for configuring the test itself...
    all = new Permissions();
    all.add(new java.security.AllPermission());

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:SimpleUpdateConfigWithInputStreamTest.java


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