本文整理汇总了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());
}
示例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;
}
示例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"));
}
示例4: getPermissions
import java.security.Permissions; //导入方法依赖的package包/类
protected PermissionCollection getPermissions(CodeSource codesource) {
Permissions permissions = new Permissions();
permissions.add(new AllPermission());
permissions.setReadOnly();
return permissions;
}
示例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);
}
示例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"));
}
}
}
示例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);
}
}
}
示例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});
}
示例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());
}
示例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) });
}
示例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"));
}
示例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);
}
}
示例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) });
}
示例15: SimplePolicy
import java.security.Permissions; //导入方法依赖的package包/类
public SimplePolicy(Permission... permissions) {
perms = new Permissions();
for (Permission permission : permissions) {
perms.add(permission);
}
}