java.security.PermissionCollection Java Examples
The following examples show how to use
java.security.PermissionCollection.
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: Activation.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Prints warning message if installed Policy is the default Policy * implementation and globally granted permissions do not include * AllPermission or any ExecPermissions/ExecOptionPermissions. */ static void checkConfiguration() { Policy policy = AccessController.doPrivileged(new PrivilegedAction<Policy>() { public Policy run() { return Policy.getPolicy(); } }); if (!(policy instanceof PolicyFile)) { return; } PermissionCollection perms = getExecPermissions(); for (Enumeration<Permission> e = perms.elements(); e.hasMoreElements();) { Permission p = e.nextElement(); if (p instanceof AllPermission || p instanceof ExecPermission || p instanceof ExecOptionPermission) { return; } } System.err.println(getTextResource("rmid.exec.perms.inadequate")); }
Example #2
Source File: AccController.java From netbeans with Apache License 2.0 | 6 votes |
/** @return an IOPermissionCollection or <tt>null</tt> if not found */ static IOPermissionCollection getIOPermissionCollection(AccessControlContext acc) { try { ProtectionDomain[] pds = getDomains(acc); PermissionCollection pc; for (int i = 0; i < pds.length; i++) { pc = pds[i].getPermissions(); if (pc instanceof IOPermissionCollection) { return (IOPermissionCollection) pc; } } return null; } catch (final Exception e) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { Logger.getLogger(AccController.class.getName()).log(Level.WARNING, null, e); } }); return null; } }
Example #3
Source File: PermissionsWrapper.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * */ private PermissionCollection makeImplicitPermissionCollection(FrameworkContext fw, Bundle b) { // NYI, perhaps we should optimize this collection. final Permissions pc = new Permissions(); if (dataRoot != null) { pc.add(new FilePermission(dataRoot.getPath(), "read,write")); pc.add(new FilePermission((new File(dataRoot, "-")).getPath(), "read,write,delete")); } final StringBuffer sb = new StringBuffer("(id="); sb.append(b.getBundleId()); sb.append(")"); pc.add(new AdminPermission(sb.toString(), AdminPermission.RESOURCE + "," + AdminPermission.METADATA + "," + AdminPermission.CLASS)); pc.add(new PropertyPermission("org.osgi.framework.*", "read")); pc.add(new CapabilityPermission(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE, CapabilityPermission.REQUIRE)); return pc; }
Example #4
Source File: Activation.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Prints warning message if installed Policy is the default Policy * implementation and globally granted permissions do not include * AllPermission or any ExecPermissions/ExecOptionPermissions. */ static void checkConfiguration() { Policy policy = AccessController.doPrivileged(new PrivilegedAction<Policy>() { public Policy run() { return Policy.getPolicy(); } }); if (!(policy instanceof PolicyFile)) { return; } PermissionCollection perms = getExecPermissions(); for (Enumeration<Permission> e = perms.elements(); e.hasMoreElements();) { Permission p = e.nextElement(); if (p instanceof AllPermission || p instanceof ExecPermission || p instanceof ExecOptionPermission) { return; } } System.err.println(getTextResource("rmid.exec.perms.inadequate")); }
Example #5
Source File: Launcher.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * allow any classes loaded from classpath to exit the VM. */ protected PermissionCollection getPermissions(CodeSource codesource) { PermissionCollection perms = super.getPermissions(codesource); perms.add(new RuntimePermission("exitVM")); return perms; }
Example #6
Source File: LogManagerAppContextDeadlock.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public PermissionsBuilder addAll(PermissionCollection col) { if (col != null) { for (Enumeration<Permission> e = col.elements(); e.hasMoreElements(); ) { perms.add(e.nextElement()); } } return this; }
Example #7
Source File: PermissionsWrapper.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * */ private PermissionCollection getPerms() { if (framework.props.isDoubleCheckedLockingSafe) { if (systemPermissions == null) { synchronized (this) { return getPerms0(); } } return systemPermissions; } else { synchronized (this) { return getPerms0(); } } }
Example #8
Source File: AddonClassLoader.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected PermissionCollection getPermissions(CodeSource codesource) { Permissions pc = new Permissions(); pc.add(new FilePermission("data/-", "read")); // Can read everything from data dir pc.add(new FilePermission(String.format("data/%s/-", spec.getModid()), "read,write,delete")); // Can write everything inside addon data dir return pc; }
Example #9
Source File: FieldSetAccessibleTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public PermissionsBuilder addAll(PermissionCollection col) { if (col != null) { for (Enumeration<Permission> e = col.elements(); e.hasMoreElements(); ) { perms.add(e.nextElement()); } } return this; }
Example #10
Source File: DefaultLoggerFinderTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public PermissionsBuilder addAll(PermissionCollection col) { if (col != null) { for (Enumeration<Permission> e = col.elements(); e.hasMoreElements(); ) { perms.add(e.nextElement()); } } return this; }
Example #11
Source File: ConditionalPermission.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** */ ConditionalPermission(Condition [] conds, PermissionCollection perms, String access, ConditionalPermissionInfoImpl cpi) { conditions = conds; permissions = perms; this.access = access; parent = cpi; }
Example #12
Source File: LoaderHandler.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Return the permissions to be granted to code loaded from the * given code source. */ protected PermissionCollection getPermissions(CodeSource codesource) { PermissionCollection perms = super.getPermissions(codesource); /* * Grant the same permissions that URLClassLoader would grant. */ return perms; }
Example #13
Source File: Activation.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void checkPermission(PermissionCollection perms, Permission p) throws AccessControlException { if (!perms.implies(p)) { throw new AccessControlException( "access denied " + p.toString()); } }
Example #14
Source File: LoaderHandler.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Return the permissions to be granted to code loaded from the * given code source. */ protected PermissionCollection getPermissions(CodeSource codesource) { PermissionCollection perms = super.getPermissions(codesource); /* * Grant the same permissions that URLClassLoader would grant. */ return perms; }
Example #15
Source File: RegistryImpl.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Generates an AccessControlContext with minimal permissions. * The approach used here is taken from the similar method * getAccessControlContext() in the sun.applet.AppletPanel class. */ private static AccessControlContext getAccessControlContext(int port) { // begin with permissions granted to all code in current policy PermissionCollection perms = AccessController.doPrivileged( new java.security.PrivilegedAction<PermissionCollection>() { public PermissionCollection run() { CodeSource codesource = new CodeSource(null, (java.security.cert.Certificate[]) null); Policy p = java.security.Policy.getPolicy(); if (p != null) { return p.getPermissions(codesource); } else { return new Permissions(); } } }); /* * Anyone can connect to the registry and the registry can connect * to and possibly download stubs from anywhere. Downloaded stubs and * related classes themselves are more tightly limited by RMI. */ perms.add(new SocketPermission("*", "connect,accept")); perms.add(new SocketPermission("localhost:"+port, "listen,accept")); perms.add(new RuntimePermission("accessClassInPackage.sun.jvmstat.*")); perms.add(new RuntimePermission("accessClassInPackage.sun.jvm.hotspot.*")); perms.add(new FilePermission("<<ALL FILES>>", "read")); /* * Create an AccessControlContext that consists of a single * protection domain with only the permissions calculated above. */ ProtectionDomain pd = new ProtectionDomain( new CodeSource(null, (java.security.cert.Certificate[]) null), perms); return new AccessControlContext(new ProtectionDomain[] { pd }); }
Example #16
Source File: LogManagerAppContextDeadlock.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public PermissionsBuilder addAll(PermissionCollection col) { if (col != null) { for (Enumeration<Permission> e = col.elements(); e.hasMoreElements(); ) { perms.add(e.nextElement()); } } return this; }
Example #17
Source File: RegistryImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Generates an AccessControlContext with minimal permissions. * The approach used here is taken from the similar method * getAccessControlContext() in the sun.applet.AppletPanel class. */ private static AccessControlContext getAccessControlContext(int port) { // begin with permissions granted to all code in current policy PermissionCollection perms = AccessController.doPrivileged( new java.security.PrivilegedAction<PermissionCollection>() { public PermissionCollection run() { CodeSource codesource = new CodeSource(null, (java.security.cert.Certificate[]) null); Policy p = java.security.Policy.getPolicy(); if (p != null) { return p.getPermissions(codesource); } else { return new Permissions(); } } }); /* * Anyone can connect to the registry and the registry can connect * to and possibly download stubs from anywhere. Downloaded stubs and * related classes themselves are more tightly limited by RMI. */ perms.add(new SocketPermission("*", "connect,accept")); perms.add(new SocketPermission("localhost:"+port, "listen,accept")); perms.add(new RuntimePermission("accessClassInPackage.sun.jvmstat.*")); perms.add(new RuntimePermission("accessClassInPackage.sun.jvm.hotspot.*")); perms.add(new FilePermission("<<ALL FILES>>", "read")); /* * Create an AccessControlContext that consists of a single * protection domain with only the permissions calculated above. */ ProtectionDomain pd = new ProtectionDomain( new CodeSource(null, (java.security.cert.Certificate[]) null), perms); return new AccessControlContext(new ProtectionDomain[] { pd }); }
Example #18
Source File: Launcher.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * allow any classes loaded from classpath to exit the VM. */ protected PermissionCollection getPermissions(CodeSource codesource) { PermissionCollection perms = super.getPermissions(codesource); perms.add(new RuntimePermission("exitVM")); return perms; }
Example #19
Source File: NullCodeSource.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Policy policy = Policy.getPolicy(); PermissionCollection perms = policy.getPermissions((CodeSource)null); if (perms.elements().hasMoreElements()) { System.err.println(perms); throw new Exception("PermissionCollection is not empty"); } }
Example #20
Source File: LoaderHandler.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Return the permissions to be granted to code loaded from the * given code source. */ protected PermissionCollection getPermissions(CodeSource codesource) { PermissionCollection perms = super.getPermissions(codesource); /* * Grant the same permissions that URLClassLoader would grant. */ return perms; }
Example #21
Source File: FieldSetAccessibleTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public PermissionsBuilder addAll(PermissionCollection col) { if (col != null) { for (Enumeration<Permission> e = col.elements(); e.hasMoreElements(); ) { perms.add(e.nextElement()); } } return this; }
Example #22
Source File: ORBUtility.java From JDKSourceCode1.8 with MIT License | 5 votes |
public static String getClassSecurityInfo(final Class cl) { // Returns a String which looks similar to: // PermissionCollection java.security.Permissions@1053693 ... // (java.io.FilePermission <<ALL FILES>> ....) // (java.io.FilePermission /export0/sunwappserv/lib/- ...) // ... other permissions ... // Domain ProtectionDomain (file:/export0/sunwappserv/lib-) // java.security.Permissions@141fedb ( // (java.io.FilePermission <<ALL FILES>> ...) // (java.io.FilePermission /var/tmp//- ...) String result = (String)AccessController.doPrivileged(new PrivilegedAction() { public java.lang.Object run() { StringBuffer sb = new StringBuffer(500); ProtectionDomain pd = cl.getProtectionDomain(); Policy policy = Policy.getPolicy(); PermissionCollection pc = policy.getPermissions(pd); sb.append("\nPermissionCollection "); sb.append(pc.toString()); // Don't need to add 'Protection Domain' string, it's // in ProtectionDomain.toString() already. sb.append(pd.toString()); return sb.toString(); } }); return result; }
Example #23
Source File: ClassDeclaredFieldsTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public PermissionsBuilder addAll(PermissionCollection col) { if (col != null) { for (Enumeration<Permission> e = col.elements(); e.hasMoreElements(); ) { perms.add(e.nextElement()); } } return this; }
Example #24
Source File: Launcher.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * allow any classes loaded from classpath to exit the VM. */ protected PermissionCollection getPermissions(CodeSource codesource) { PermissionCollection perms = super.getPermissions(codesource); perms.add(new RuntimePermission("exitVM")); return perms; }
Example #25
Source File: JarURL.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { String userDir = System.getProperty("user.dir"); String jarURL = "jar:file:" + userDir + File.separator + "foo.jar!/"; URL codeSourceURL = new URL(jarURL); CodeSource cs = new CodeSource(codeSourceURL, new Certificate[0]); PermissionCollection perms = Policy.getPolicy().getPermissions(cs); if (!perms.implies(new AllPermission())) throw new Exception("FAILED: " + codeSourceURL + " not granted AllPermission"); }
Example #26
Source File: LoggerBridgeTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public PermissionCollection getPermissions(CodeSource codesource) { return new PermissionsBuilder().addAll(getPermissions()).toPermissions(); }
Example #27
Source File: XSLTExFuncTest.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public PermissionCollection getPermissions(ProtectionDomain pd) { return perms; }
Example #28
Source File: LoggerFinderLoaderTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public PermissionCollection getPermissions(CodeSource codesource) { return new PermissionsBuilder().addAll(getPermissions()).toPermissions(); }
Example #29
Source File: MBeanServerPermission.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public PermissionCollection newPermissionCollection() { return new MBeanServerPermissionCollection(); }
Example #30
Source File: XPathExFuncTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Override public PermissionCollection getPermissions(CodeSource cs) { return perms; }