當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。