granted.add(new PropertyPermission("java.version", "read")); granted.add(new PropertyPermission("java.vendor", "read")); granted.add(new PropertyPermission("java.vendor.url", "read")); granted.add(new PropertyPermission("java.class.version", "read")); granted.add(new PropertyPermission("os.name", "read")); granted.add(new PropertyPermission("os.version", "read")); granted.add(new PropertyPermission("os.arch", "read")); granted.add(new PropertyPermission("file.encoding", "read")); granted.add(new PropertyPermission("file.separator", "read")); granted.add(new PropertyPermission("path.separator", "read")); granted.add(new PropertyPermission("line.separator", "read")); granted.add(new PropertyPermission("java.specification.version", "read")); granted.add(new PropertyPermission("java.specification.vendor", "read")); granted.add(new PropertyPermission("java.specification.name", "read")); granted.add(new PropertyPermission("java.vm.specification.version", "read")); granted.add(new PropertyPermission("java.vm.specification.vendor", "read")); granted.add(new PropertyPermission("java.vm.specification.name", "read")); granted.add(new PropertyPermission("java.vm.version", "read")); granted.add(new PropertyPermission("java.vm.vendor", "read")); granted.add(new PropertyPermission("java.vm.name", "read"));
private static void checkPropertyWritePermission(Class<?> clazz, String propertyName) { final ProtectionDomain protectionDomain; final ClassLoader classLoader; if (getSecurityManager() instanceof WildFlySecurityManager) { protectionDomain = clazz.getProtectionDomain(); classLoader = clazz.getClassLoader(); } else { protectionDomain = doPrivileged(new GetProtectionDomainAction(clazz)); classLoader = doPrivileged(new GetClassLoaderAction(clazz)); } if (protectionDomain.implies(PROPERTIES_PERMISSION)) { return; } final PropertyPermission permission = new PropertyPermission(propertyName, "write"); if (protectionDomain.implies(permission)) { return; } access.accessCheckFailed(permission, protectionDomain.getCodeSource(), classLoader); if (! LOG_ONLY) { throw access.accessControlException(permission, permission, protectionDomain.getCodeSource(), classLoader); } }
private static void checkPropertyReadPermission(Class<?> clazz, String propertyName) { final ProtectionDomain protectionDomain; final ClassLoader classLoader; if (getSecurityManager() instanceof WildFlySecurityManager) { protectionDomain = clazz.getProtectionDomain(); classLoader = clazz.getClassLoader(); } else { protectionDomain = doPrivileged(new GetProtectionDomainAction(clazz)); classLoader = doPrivileged(new GetClassLoaderAction(clazz)); } if (protectionDomain.implies(PROPERTIES_PERMISSION)) { return; } final PropertyPermission permission = new PropertyPermission(propertyName, "read"); if (protectionDomain.implies(permission)) { return; } access.accessCheckFailed(permission, protectionDomain.getCodeSource(), classLoader); if (! LOG_ONLY) { throw access.accessControlException(permission, permission, protectionDomain.getCodeSource(), classLoader); } }
public void testForbiddenProperty() { String script = "System.getProperty(\"user.home\")"; assertExecute(script, null, new PropertyPermission("user.home", "read")); }
return; final PropertyPermission permission = new PropertyPermission(key, "read"); if (protectionDomain.implies(permission)) { return;
AccessControlContext acc = provider.getAccessControlContext(); try { acc.checkPermission(new PropertyPermission("*", "read")); fail("Acc should not have any permissions");
/** 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")); }
/** * 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")); }
/** * 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")); }
public class MinimalPolicy extends Policy { private static PermissionCollection perms; public MinimalPolicy() { super(); if (perms == null) { perms = new MyPermissionCollection(); addPermissions(); } } @Override public PermissionCollection getPermissions(CodeSource codesource) { return perms; } private void addPermissions() { SocketPermission socketPermission = new SocketPermission("*:1024-", "connect, resolve"); PropertyPermission propertyPermission = new PropertyPermission("*", "read, write"); FilePermission filePermission = new FilePermission("<<ALL FILES>>", "read"); perms.add(socketPermission); perms.add(propertyPermission); perms.add(filePermission); } }
public static String setProperty(String key, String value) { checkKey(key); SecurityManager sm = getSecurityManager(); if (sm != null) { sm.checkPermission(new PropertyPermission(key, SecurityConstants.PROPERTY_WRITE_ACTION)); } return (String) props.setProperty(key, value); }
public static String setProperty(String key, String value) { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new PropertyPermission(key, "write")); //$NON-NLS-1$ return (String) internalGetProperties(null).put(key, value); }
public static String clearProperty(String key) { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new PropertyPermission(key, "write")); //$NON-NLS-1$ return (String) internalGetProperties(null).remove(key); }
public static String clearProperty(String key) { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new PropertyPermission(key, "write")); //$NON-NLS-1$ return (String) internalGetProperties(null).remove(key); }
/** * @return Returns the {@link Set} of default permissions. */ public static Set<Permission> getDefaultPermissions() { Set<Permission> defaultPermissions = new HashSet<>(); defaultPermissions.add(new PropertyPermission("*", "read")); defaultPermissions.add(new RuntimePermission("accessClassInPackage.sun.util.logging.resources")); return defaultPermissions; }
public static String setProperty(String key, String value) { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new PropertyPermission(key, "write")); //$NON-NLS-1$ return (String) internalGetProperties(null).put(key, value); }
@Override public String getProperty(String key) { ClassLoader cl = getClassLoader(); if (cl instanceof PermissionCheck) { Permission p = new PropertyPermission(key, "read"); if (!((PermissionCheck) cl).check(p)) { return null; } } return System.getProperty(key); } }
@Override public String getProperty(String key) { ClassLoader cl = getClassLoader(); if (cl instanceof PermissionCheck) { Permission p = new PropertyPermission(key, "read"); if (!((PermissionCheck) cl).check(p)) { return null; } } return System.getProperty(key); } }
private boolean checkProperty(String key) { if(key.equals("javax.net.ssl.keyStorePassword") || key.equals("javax.net.ssl.trustStorePassword")){ SSLUtils.checkPermission(key); } if (cacheEnabled()) { return cache.checkPermission(new PropertyPermission(key, "read")); } return false; }
private boolean checkProperty(String key) { if(key.equals("javax.net.ssl.keyStorePassword") || key.equals("javax.net.ssl.trustStorePassword")){ SSLUtils.checkPermission(key); } if (cacheEnabled()) { return cache.checkPermission(new PropertyPermission(key, "read")); } return false; }