當前位置: 首頁>>代碼示例>>Java>>正文


Java PropertyPermission類代碼示例

本文整理匯總了Java中java.util.PropertyPermission的典型用法代碼示例。如果您正苦於以下問題:Java PropertyPermission類的具體用法?Java PropertyPermission怎麽用?Java PropertyPermission使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PropertyPermission類屬於java.util包,在下文中一共展示了PropertyPermission類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRestrictedPermissions

import java.util.PropertyPermission; //導入依賴的package包/類
static PermissionCollection getRestrictedPermissions() {
    Permissions perms = new Permissions();
    // property/env access needed for parsing
    perms.add(new PropertyPermission("*", "read"));
    perms.add(new RuntimePermission("getenv.TIKA_CONFIG"));

    // add permissions for resource access:
    // classpath
    addReadPermissions(perms, JarHell.parseClassPath());
    // plugin jars
    if (TikaImpl.class.getClassLoader() instanceof URLClassLoader) {
        addReadPermissions(perms, ((URLClassLoader)TikaImpl.class.getClassLoader()).getURLs());
    }
    // jvm's java.io.tmpdir (needs read/write)
    perms.add(new FilePermission(System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "-",
                                 "read,readlink,write,delete"));
    // current hacks needed for POI/PDFbox issues:
    perms.add(new SecurityPermission("putProviderProperty.BC"));
    perms.add(new SecurityPermission("insertProvider"));
    perms.add(new ReflectPermission("suppressAccessChecks"));
    // xmlbeans, use by POI, needs to get the context classloader
    perms.add(new RuntimePermission("getClassLoader"));
    perms.setReadOnly();
    return perms;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:26,代碼來源:TikaImpl.java

示例2: getTestPermissions

import java.util.PropertyPermission; //導入依賴的package包/類
/**
 * Returns the list of permissions for the running test.
 * 
 * @return
 */
protected List<Permission> getTestPermissions() {
	List<Permission> perms = new ArrayList<Permission>();
	perms.add(new PackagePermission("*", PackagePermission.EXPORT));
	perms.add(new PackagePermission("*", PackagePermission.IMPORT));
	perms.add(new BundlePermission("*", BundlePermission.HOST));
	perms.add(new BundlePermission("*", BundlePermission.PROVIDE));
	perms.add(new BundlePermission("*", BundlePermission.REQUIRE));
	perms.add(new ServicePermission("*", ServicePermission.REGISTER));
	perms.add(new ServicePermission("*", ServicePermission.GET));
	perms.add(new PropertyPermission("*", "read,write"));
	// required by Spring
	perms.add(new RuntimePermission("*", "accessDeclaredMembers"));
	perms.add(new ReflectPermission("*", "suppressAccessChecks"));
	// logging permission
	perms.add(new FilePermission("-", "write"));
	perms.add(new FilePermission("-", "read"));
	return perms;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:24,代碼來源:BaseIntegrationTest.java

示例3: getIAndTPermissions

import java.util.PropertyPermission; //導入依賴的package包/類
protected List<Permission> getIAndTPermissions() {
	List<Permission> perms = new ArrayList<Permission>();
	// export package
	perms.add(new PackagePermission("*", PackagePermission.EXPORT));
	perms.add(new PackagePermission("*", PackagePermission.IMPORT));
	perms.add(new BundlePermission("*", BundlePermission.FRAGMENT));
	perms.add(new BundlePermission("*", BundlePermission.PROVIDE));
	perms.add(new ServicePermission("*", ServicePermission.REGISTER));
	perms.add(new ServicePermission("*", ServicePermission.GET));
	perms.add(new PropertyPermission("*", "read,write"));

	// required by Spring
	perms.add(new RuntimePermission("*", "accessDeclaredMembers"));
	perms.add(new ReflectPermission("*", "suppressAccessChecks"));

	// logging permission
	perms.add(new FilePermission("-", "write"));
	perms.add(new FilePermission("-", "read"));

	return perms;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:22,代碼來源:BaseIntegrationTest.java

示例4: getSysPropertyValues

import java.util.PropertyPermission; //導入依賴的package包/類
private static String getSysPropertyValues(String propertyName, String permissionsToGet)
{
	final Permissions permissions = new Permissions();
	permissions.add(new PropertyPermission(propertyName, permissionsToGet));
	LOGGER.info("Added " + permissionsToGet + " property permission for " + propertyName);

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

	LinuxOpener.EnvPropertyGetter proppy = new EnvPropertyGetter(propertyName, false); // false
																						// =
																						// don't
																						// call
																						// getenv
																						// (rather
																						// getProperty)

	AccessController.doPrivileged(proppy, context);

	return proppy.getPropertyValue();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:22,代碼來源:MacOpener.java

示例5: getSystemProperty

import java.util.PropertyPermission; //導入依賴的package包/類
/**
 * Returns the requested System Property.  If a {@code SecurityException}
 * occurs, just return NULL
 * @param propName - System property to retrieve
 * @return The System property value or NULL if the property does not exist
 * or a {@code SecurityException} occurs.
 */
static private String getSystemProperty(final String propName) {
    String property = null;
    try {
        property = AccessController.doPrivileged(new PrivilegedAction<String>() {

            public String run() {
                return System.getProperty(propName);
            }
        }, null, new PropertyPermission(propName, "read"));
    } catch (SecurityException se) {
        trace("error getting " + propName + ":  "+ se);
        if (debug) {
            se.printStackTrace();
        }
    }
    return property;
}
 
開發者ID:madHEYsia,項目名稱:ClassroomFlipkart,代碼行數:25,代碼來源:RowSetProvider.java

示例6: main

import java.util.PropertyPermission; //導入依賴的package包/類
public static void main(String arg[]) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        System.out.println("Security manager detected");
        try {
            security.checkPermission(new FilePermission("<<ALL FILES>>", "read,write"));
            security.checkPermission(new PropertyPermission("user.dir", "read"));
        } catch (SecurityException se) {
            System.out.println("Security requirement not obtained.  TEST PASSED");
            return;
        }
    }
    String[] testStr = {".", ""};
    for (int i=0; i<testStr.length; i++) {
        System.out.println("Testing file name = \""+testStr[i]+"\"");
        doPrinterJob(testStr[i], OrientationRequested.PORTRAIT);
        PrintToDir ptd = new PrintToDir();
        ptd.doPrintJob(testStr[i]);
        ptd.dispose();
    }
    System.out.println("TEST PASSED");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:PrintToDir.java

示例7: SimplePolicy

import java.util.PropertyPermission; //導入依賴的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

示例8: SimplePolicy

import java.util.PropertyPermission; //導入依賴的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

示例9: setBasicPermissions

import java.util.PropertyPermission; //導入依賴的package包/類
public void setBasicPermissions() {
    permissions.add(new SecurityPermission("getPolicy"));
    permissions.add(new SecurityPermission("setPolicy"));
    permissions.add(new RuntimePermission("getClassLoader"));
    permissions.add(new RuntimePermission("setSecurityManager"));
    permissions.add(new RuntimePermission("createSecurityManager"));
    permissions.add(new PropertyPermission("testng.show.stack.frames",
            "read"));
    permissions.add(new PropertyPermission("user.dir", "read"));
    permissions.add(new PropertyPermission("test.src", "read"));
    permissions.add(new PropertyPermission("file.separator", "read"));
    permissions.add(new PropertyPermission("line.separator", "read"));
    permissions.add(new PropertyPermission("fileStringBuffer", "read"));
    permissions.add(new PropertyPermission("dataproviderthreadcount", "read"));
    permissions.add(new FilePermission("<<ALL FILES>>", "execute"));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:PermissionTest.java

示例10: SimplePolicy

import java.util.PropertyPermission; //導入依賴的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 RuntimePermission("accessSystemModules"));
    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:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:FieldSetAccessibleTest.java

示例11: SimplePolicy

import java.util.PropertyPermission; //導入依賴的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

示例12: permissivePolicy

import java.util.PropertyPermission; //導入依賴的package包/類
/**
 * Returns a policy containing all the permissions we ever need.
 */
public static Policy permissivePolicy() {
    return new AdjustablePolicy
        // Permissions j.u.c. needs directly
        (new RuntimePermission("modifyThread"),
         new RuntimePermission("getClassLoader"),
         new RuntimePermission("setContextClassLoader"),
         // Permissions needed to change permissions!
         new SecurityPermission("getPolicy"),
         new SecurityPermission("setPolicy"),
         new RuntimePermission("setSecurityManager"),
         // Permissions needed by the junit test harness
         new RuntimePermission("accessDeclaredMembers"),
         new PropertyPermission("*", "read"),
         new java.io.FilePermission("<<ALL FILES>>", "read"));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:JSR166TestCase.java

示例13: isLanguageEditable

import java.util.PropertyPermission; //導入依賴的package包/類
/**
 * Returns <code>true</code> if the language in preferences can be set.
 * @return <code>true</code> except if <code>user.language</code> System property isn't writable.
 * @since 3.4 
 */
public boolean isLanguageEditable()
{
	try
	{
		SecurityManager securityManager = System.getSecurityManager();
		if (securityManager != null)
		{
			securityManager.checkPermission(new PropertyPermission("user.language", "write"));
		}
		return true;
	}
	catch (AccessControlException ex)
	{
		return false;
	}
}
 
開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:22,代碼來源:UserPreferences.java

示例14: createGroovySourcePermissions

import java.util.PropertyPermission; //導入依賴的package包/類
/**
 * Create permission for groovy scripts of the {@link ScriptingOperator}.
 *
 * @return the permissions, never {@code null}
 */
private static PermissionCollection createGroovySourcePermissions() {
	if (ProductConstraintManager.INSTANCE.isInitialized()) {
		if (ProductConstraintManager.INSTANCE.getActiveLicense()
				.getPrecedence() >= StudioLicenseConstants.UNLIMITED_LICENSE_PRECEDENCE
				|| ProductConstraintManager.INSTANCE.isTrialLicense()) {
			return createAllPermissions();
		}
	}

	Permissions permissions = new Permissions();

	// grant some permissions because the script is something the user himself created
	permissions.add(new PropertyPermission("*", "read, write"));
	permissions.add(new FilePermission("<<ALL FILES>>", "read, write, delete"));

	addCommonPermissions(permissions);

	return permissions;
}
 
開發者ID:rapidminer,項目名稱:rapidminer-studio,代碼行數:25,代碼來源:PluginSandboxPolicy.java

示例15: getProxiesWithoutCaching

import java.util.PropertyPermission; //導入依賴的package包/類
/**
 * Get the proxies for accessing a given URL. The result is obtained by
 * evaluating the PAC file with the given url (and the host) as input.
 *
 * @param url the url for which a proxy is desired
 * @return a list of proxies in a string like
 * <pre>"PROXY example.com:3128; DIRECT"</pre>
 *
 * @see #getProxies(URL)
 */
private String getProxiesWithoutCaching(URL url) {
    if (pacHelperFunctionContents == null) {
        OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Error loading pac functions");
        return "DIRECT";
    }

    EvaluatePacAction evaluatePacAction = new EvaluatePacAction(pacContents, pacUrl.toString(),
            pacHelperFunctionContents, url);

    // Purposefully giving only these permissions rather than using java.policy. The "evaluatePacAction"
    // isn't supposed to do very much and so doesn't require all the default permissions given by
    // java.policy
    Permissions p = new Permissions();
    p.add(new RuntimePermission("accessClassInPackage.org.mozilla.javascript"));
    p.add(new SocketPermission("*", "resolve"));
    p.add(new PropertyPermission("java.vm.name", "read"));

    ProtectionDomain pd = new ProtectionDomain(null, p);
    AccessControlContext context = new AccessControlContext(new ProtectionDomain[] { pd });

    return AccessController.doPrivileged(evaluatePacAction, context);
}
 
開發者ID:GITNE,項目名稱:icedtea-web,代碼行數:33,代碼來源:RhinoBasedPacEvaluator.java


注:本文中的java.util.PropertyPermission類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。