java.util.PropertyPermission Java Examples
The following examples show how to use
java.util.PropertyPermission.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluginSandboxPolicy.java From rapidminer-studio with GNU Affero General Public License v3.0 | 7 votes |
/** * 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; }
Example #2
Source File: JSR166TestCase.java From j2objc with Apache License 2.0 | 7 votes |
/** * 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")); }
Example #3
Source File: PrintToDir.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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"); }
Example #4
Source File: JSR166TestCase.java From database with GNU General Public License v2.0 | 6 votes |
/** * 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")); }
Example #5
Source File: PrintToDir.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example #6
Source File: FileHandlerPath.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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()); }
Example #7
Source File: PrintToDir.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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"); }
Example #8
Source File: RowSetProvider.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #9
Source File: FieldSetAccessibleTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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()); }
Example #10
Source File: PrintToDir.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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"); }
Example #11
Source File: RowSetProvider.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #12
Source File: PrintToDir.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example #13
Source File: RowSetProvider.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #14
Source File: SecurityActions.java From keycloak with Apache License 2.0 | 6 votes |
/** * Set the system property * * @param key * @param defaultValue * * @return */ public static void setSystemProperty(final String key, final String value) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new PropertyPermission(key, "write")); AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { System.setProperty(key, value); return null; } }); } else { System.setProperty(key, value); } }
Example #15
Source File: FieldSetAccessibleTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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()); }
Example #16
Source File: FileHandlerPath.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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()); }
Example #17
Source File: FileHandlerPath.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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()); }
Example #18
Source File: ProGradePolicyEntryTestCase.java From pro-grade with Apache License 2.0 | 6 votes |
@Test public void testImpliesCodeSource() throws Exception { ProGradePolicyEntry ppe = createWithAllPermission(); ppe.setCodeSource(new CodeSource(new URL("file:./path/to/file/-"), new Certificate[0])); // test whether PD with null CodeSource passes ProgradePolicyEntryTestCase implies method ProtectionDomain pd = createPD(); assertTrue(ppe.implies(pd, new PropertyPermission("java.home", "read"))); // test whether PD with same CodeSource passes ProgradePolicyEntryTestCase implies method pd = createPD(new CodeSource(new URL("file:./path/to/file/-"), new Certificate[0])); assertTrue(ppe.implies(pd, new PropertyPermission("java.home", "read"))); // test whether PD with "wrong" CodeSource doesn't pass ProgradePolicyEntryTestCase implies method pd = createPD(new CodeSource(new URL("file:./wrong/path"), new Certificate[0])); assertFalse(ppe.implies(pd, new PropertyPermission("java.home", "read"))); // test whether PD with implied CodeSource pass ProgradePolicyEntryTestCase implies method pd = createPD(new CodeSource(new URL("file:./path/to/file/which/is/implied"), new Certificate[0])); assertTrue(ppe.implies(pd, new PropertyPermission("java.home", "read"))); }
Example #19
Source File: RowSetProvider.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #20
Source File: TestSetResourceBundle.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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")); }
Example #21
Source File: TestPolicy.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void setMinimalPermissions() { 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("line.separator", "read")); permissions.add(new PropertyPermission("fileStringBuffer", "read")); permissions.add(new PropertyPermission("dataproviderthreadcount", "read")); permissions.add(new PropertyPermission("java.io.tmpdir", "read")); permissions.add(new FilePermission("<<ALL FILES>>", "read, write, delete")); }
Example #22
Source File: TestSetResourceBundle.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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")); }
Example #23
Source File: DynamicPolicy.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void initStaticPolicy(PermissionCollection perms) { perms.add(new java.security.SecurityPermission("getPolicy")); perms.add(new java.security.SecurityPermission("setPolicy")); perms.add(new java.lang.RuntimePermission("stopThread")); perms.add(new java.net.SocketPermission("localhost:1024-", "listen")); perms.add(new PropertyPermission("java.version","read")); perms.add(new PropertyPermission("java.vendor","read")); perms.add(new PropertyPermission("java.vendor.url","read")); perms.add(new PropertyPermission("java.class.version","read")); perms.add(new PropertyPermission("os.name","read")); perms.add(new PropertyPermission("os.version","read")); perms.add(new PropertyPermission("os.arch","read")); perms.add(new PropertyPermission("file.separator","read")); perms.add(new PropertyPermission("path.separator","read")); perms.add(new PropertyPermission("line.separator","read")); perms.add(new PropertyPermission("java.specification.version", "read")); perms.add(new PropertyPermission("java.specification.vendor", "read")); perms.add(new PropertyPermission("java.specification.name", "read")); perms.add(new PropertyPermission("java.vm.specification.version", "read")); perms.add(new PropertyPermission("java.vm.specification.vendor", "read")); perms.add(new PropertyPermission("java.vm.specification.name", "read")); perms.add(new PropertyPermission("java.vm.version", "read")); perms.add(new PropertyPermission("java.vm.vendor", "read")); perms.add(new PropertyPermission("java.vm.name", "read")); return; }
Example #24
Source File: WildcardPrincipalName.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { X500Principal duke = new X500Principal("CN=Duke"); PropertyPermission pp = new PropertyPermission("user.home", "read"); RunAsPrivilegedUserAction runAsPrivilegedUserAction = new RunAsPrivilegedUserAction(duke, new CheckPermissionAction(pp)); AccessController.doPrivileged(runAsPrivilegedUserAction); System.out.println("test PASSED"); }
Example #25
Source File: DynamicPolicy.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public PermissionCollection getPermissions(CodeSource cs) { Permissions perms = new Permissions(); initStaticPolicy(perms); // Defalut policy in the beginning... // toggle from refresh to refresh if (refresher == 1) perms.add(new PropertyPermission("user.name","read")); System.err.println("perms=[" + perms + "]"); return perms; }
Example #26
Source File: TestPolicy.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void setMinimalPermissions() { 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("line.separator", "read")); permissions.add(new PropertyPermission("fileStringBuffer", "read")); permissions.add(new PropertyPermission("dataproviderthreadcount", "read")); permissions.add(new PropertyPermission("java.io.tmpdir", "read")); permissions.add(new FilePermission("<<ALL FILES>>", "read, write, delete")); }
Example #27
Source File: SecuritySupport.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static SafePath getPathInProperty(String prop, String subPath) { return doPrivilegedWithReturn(() -> { String path = System.getProperty(prop); if (path == null) { return null; } File file = subPath == null ? new File(path) : new File(path, subPath); return new SafePath(file.getAbsolutePath()); }, new PropertyPermission("*", "read")); }
Example #28
Source File: TestSetResourceBundle.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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")); }
Example #29
Source File: SecurityRestrictionsTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private boolean isJvmciPermission(Permission perm) { String name = perm.getName(); boolean isJvmciRuntime = perm instanceof RuntimePermission && (JVMCI_SERVICES.equals(name) || name.startsWith(JVMCI_RT_PERM_START)); boolean isJvmciProperty = perm instanceof PropertyPermission && name.startsWith(JVMCI_PROP_START); return isJvmciRuntime || isJvmciProperty; }
Example #30
Source File: RootLevelInConfigFile.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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")); }