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


Java Permissions.add方法代码示例

本文整理汇总了Java中java.security.Permissions.add方法的典型用法代码示例。如果您正苦于以下问题:Java Permissions.add方法的具体用法?Java Permissions.add怎么用?Java Permissions.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.Permissions的用法示例。


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

示例1: SimplePolicy

import java.security.Permissions; //导入方法依赖的package包/类
public SimplePolicy(TestCase test, ThreadLocal<AtomicBoolean> allowAll) {
    this.allowAll = allowAll;

    // Permission needed by the tested code exercised in the test
    permissions = new Permissions();
    permissions.add(new RuntimePermission("fileSystemProvider"));
    permissions.add(new RuntimePermission("createClassLoader"));
    permissions.add(new RuntimePermission("closeClassLoader"));
    permissions.add(new RuntimePermission("getClassLoader"));
    permissions.add(new RuntimePermission("accessDeclaredMembers"));
    permissions.add(new ReflectPermission("suppressAccessChecks"));
    permissions.add(new PropertyPermission("*", "read"));
    permissions.add(new FilePermission("<<ALL FILES>>", "read"));

    // these are used for configuring the test itself...
    allPermissions = new Permissions();
    allPermissions.add(new java.security.AllPermission());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:FieldSetAccessibleTest.java

示例2: getPermissions

import java.security.Permissions; //导入方法依赖的package包/类
@Override
protected PermissionCollection getPermissions(CodeSource codeSource) {
    Permissions perms = new Permissions();
    perms.add(new AllPermission());
    perms.setReadOnly();
    return perms;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:CustomClassLoader.java

示例3: SimplePolicy

import java.security.Permissions; //导入方法依赖的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

示例4: getPermissions

import java.security.Permissions; //导入方法依赖的package包/类
protected PermissionCollection getPermissions(CodeSource codesource) {
    Permissions permissions = new Permissions();
    permissions.add(new AllPermission());
    permissions.setReadOnly();
    
    return permissions;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:DriverClassLoader.java

示例5: testParsePermissions

import java.security.Permissions; //导入方法依赖的package包/类
/** Test that we can parse the set of permissions correctly for a simple policy */
public void testParsePermissions() throws Exception {
    assumeTrue("test cannot run with security manager enabled", System.getSecurityManager() == null);
    Path scratch = createTempDir();
    Path testFile = this.getDataPath("security/simple-plugin-security.policy");
    Permissions expected = new Permissions();
    expected.add(new RuntimePermission("queuePrintJob"));
    PermissionCollection actual = PluginSecurity.parsePermissions(Terminal.DEFAULT, testFile, scratch);
    assertEquals(expected, actual);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:PluginSecurityTests.java

示例6: addClasspathPermissions

import java.security.Permissions; //导入方法依赖的package包/类
/** Adds access to classpath jars/classes for jar hell scan, etc */
@SuppressForbidden(reason = "accesses fully qualified URLs to configure security")
static void addClasspathPermissions(Permissions policy) throws IOException {
    // add permissions to everything in classpath
    // really it should be covered by lib/, but there could be e.g. agents or similar configured)
    for (URL url : JarHell.parseClassPath()) {
        Path path;
        try {
            path = PathUtils.get(url.toURI());
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
        // resource itself
        policy.add(new FilePermission(path.toString(), "read,readlink"));
        // classes underneath
        if (Files.isDirectory(path)) {
            policy.add(new FilePermission(path.toString() + path.getFileSystem().getSeparator() + "-", "read,readlink"));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:Security.java

示例7: addPathIfExists

import java.security.Permissions; //导入方法依赖的package包/类
/**
 * Add access to a directory iff it exists already
 * @param policy current policy to add permissions to
 * @param configurationName the configuration name associated with the path (for error messages only)
 * @param path the path itself
 * @param permissions set of file permissions to grant to the path
 */
static void addPathIfExists(Permissions policy, String configurationName, Path path, String permissions) {
    if (Files.isDirectory(path)) {
        // add each path twice: once for itself, again for files underneath it
        policy.add(new FilePermission(path.toString(), permissions));
        policy.add(new FilePermission(path.toString() + path.getFileSystem().getSeparator() + "-", permissions));
        try {
            path.getFileSystem().provider().checkAccess(path.toRealPath(), AccessMode.READ);
        } catch (IOException e) {
            throw new IllegalStateException("Unable to access '" + configurationName + "' (" + path + ")", e);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:Security.java

示例8: getAccessControlContext

import java.security.Permissions; //导入方法依赖的package包/类
private static AccessControlContext getAccessControlContext(Permission... ps) {
    Permissions perms = new Permissions();
    for (Permission p : ps) {
        perms.add(p);
    }
    /*
     *Create an AccessControlContext that consist a single protection domain
     * with only the permissions calculated above
     */
    ProtectionDomain pd = new ProtectionDomain(null, perms);
    return new AccessControlContext(new ProtectionDomain[]{pd});
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:SocketPermissionTest.java

示例9: execLoadPermissions

import java.security.Permissions; //导入方法依赖的package包/类
@Override
protected Permissions execLoadPermissions(String userId) {
  Permissions permissions = new Permissions();
  permissions.add(new RemoteServiceAccessPermission("*.shared.*", "*"));
  permissions.add(new AllPermission());
  return permissions;
}
 
开发者ID:BSI-Business-Systems-Integration-AG,项目名称:trading-network,代码行数:8,代码来源:ServerAccessControlService.java

示例10: SimplePolicy

import java.security.Permissions; //导入方法依赖的package包/类
public SimplePolicy(TestCase test, ThreadLocal<AtomicBoolean> allowAll) {
    this.allowAll = allowAll;
    // we don't actually need any permission to create our
    // FileHandlers because we're passing invalid parameters
    // which will make the creation fail...
    permissions = new Permissions();
    permissions.add(new RuntimePermission("accessDeclaredMembers"));
    permissions.add(new ReflectPermission("suppressAccessChecks"));

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

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:ClassDeclaredFieldsTest.java

示例11: createPermAccCtxt

import java.security.Permissions; //导入方法依赖的package包/类
private static AccessControlContext createPermAccCtxt(final String permName) {
    final Permissions perms = new Permissions();
    perms.add(new RuntimePermission(permName));
    return new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, perms) });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:Context.java

示例12: SimplePolicy

import java.security.Permissions; //导入方法依赖的package包/类
public SimplePolicy(ThreadLocal<AtomicBoolean> allowControl, ThreadLocal<AtomicBoolean> allowAccess) {
    this.allowControl = allowControl;
    this.allowAccess = allowAccess;
    permissions = new Permissions();
    permissions.add(new RuntimePermission("setIO"));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:BaseDefaultLoggerFinderTest.java

示例13: doSyncFile

import java.security.Permissions; //导入方法依赖的package包/类
private void doSyncFile()
{
	try
	{
		logger.entering("InPlaceEditAppletLauncher", "syncFile");
		if( file == null )
		{
			logger.severe("File not loaded yet!");
			return;
		}

		debug("Entering synchronized block...");
		synchronized( file )
		{
			debug("Entered synchronized block - " + file.getAbsolutePath());
			debug("Synchronising: " + synchronising + ", file.hasChangedSinceLastSync: "
				+ file.hasChangedSinceLastSync());

			// Determine if file actually *needs* syncing.
			// This method could be invoked via web or it could be a
			// backlogged TimerTask that is no
			// longer relevant
			if( !synchronising && file.hasChangedSinceLastSync() )
			{
				final long fileLength = file.length();
				logger.info("File size is " + fileLength);

				final Permissions permissions = new Permissions();
				// permissions.add(new SocketPermission(host, "connect"));
				// debug("Added SocketPermission for 'connect' on " + host);
				// permissions.add(new SocketPermission(host, "resolve"));
				// debug("Added SocketPermission for 'resolve' on " + host);
				// permissions.add(new
				// AWTPermission("showWindowWithoutWarningBanner"));
				// debug("Added AWTPermission for 'showWindowWithoutWarningBanner'");
				// permissions.add(new
				// AWTPermission("listenToAllAWTEvents"));
				// logger.info("Added AWTPermission for 'listenToAllAWTEvents'");
				// permissions.add(new AWTPermission("accessEventQueue"));
				// debug("Added AWTPermission for 'accessEventQueue'");
				permissions.add(new AllPermission());

				final AccessControlContext context = new AccessControlContext(
					new ProtectionDomain[]{new ProtectionDomain(null, permissions)});

				AccessController.doPrivileged(new PrivilegedAction<Object>()
				{
					@Override
					public Object run()
					{
						final UploadWorker progWorker = new UploadWorker(CurrentLocale.get("label.uploading"),
							(int) fileLength, false);
						progWorker.setComponent(InPlaceEditAppletLauncher.this);
						progWorker.start();
						return null;
					}
				}, context);
			}
			else
			{
				debug("Not invoking doSync");
			}
		}
	}
	catch( Exception e )
	{
		throw logException("Error invoking syncFile", e);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:70,代码来源:InPlaceEditAppletLauncher.java

示例14: createLoggerControlAccCtxt

import java.security.Permissions; //导入方法依赖的package包/类
/**
 * Access control context for logger level and instantiation permissions
 * @return access control context
 */
private static AccessControlContext createLoggerControlAccCtxt() {
    final Permissions perms = new Permissions();
    perms.add(new LoggingPermission("control", null));
    return new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, perms) });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:DebugLogger.java

示例15: SimplePolicy

import java.security.Permissions; //导入方法依赖的package包/类
public SimplePolicy(Permission... permissions) {
    perms = new Permissions();
    for (Permission permission : permissions) {
        perms.add(permission);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:XSLTExFuncTest.java


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