Search in sources :

Example 46 with Permissions

use of java.security.Permissions in project Payara by payara.

the class PermsHolder method getPermissions.

public PermissionCollection getPermissions(CodeSource codesource, PermissionCollection parentPC) {
    String codeUrl = codesource.getLocation().toString();
    PermissionCollection cachedPermissons = loaderPC.get(codeUrl);
    if (cachedPermissons != null)
        return cachedPermissons;
    else
        cachedPermissons = new Permissions();
    PermissionCollection pc = parentPC;
    if (pc != null) {
        Enumeration<Permission> perms = pc.elements();
        while (perms.hasMoreElements()) {
            Permission p = perms.nextElement();
            cachedPermissons.add(p);
        }
    }
    if (declaredPermissionCollection != null) {
        Enumeration<Permission> dperms = this.declaredPermissionCollection.elements();
        while (dperms.hasMoreElements()) {
            Permission p = dperms.nextElement();
            cachedPermissons.add(p);
        }
    }
    if (eePermissionCollection != null) {
        Enumeration<Permission> eeperms = eePermissionCollection.elements();
        while (eeperms.hasMoreElements()) {
            Permission p = eeperms.nextElement();
            cachedPermissons.add(p);
        }
    }
    PermissionCollection tmpPc = loaderPC.putIfAbsent(codeUrl, cachedPermissons);
    if (tmpPc != null) {
        cachedPermissons = tmpPc;
    }
    return cachedPermissons;
}
Also used : PermissionCollection(java.security.PermissionCollection) Permissions(java.security.Permissions) Permission(java.security.Permission)

Aggregations

Permissions (java.security.Permissions)46 ProtectionDomain (java.security.ProtectionDomain)22 PermissionCollection (java.security.PermissionCollection)19 Permission (java.security.Permission)18 AccessControlContext (java.security.AccessControlContext)14 FilePermission (java.io.FilePermission)11 CodeSource (java.security.CodeSource)11 SocketPermission (java.net.SocketPermission)7 Path (java.nio.file.Path)6 AllPermission (java.security.AllPermission)6 Policy (java.security.Policy)6 Certificate (java.security.cert.Certificate)5 URLClassLoader (java.net.URLClassLoader)4 File (java.io.File)3 IOException (java.io.IOException)3 SecurityPermission (java.security.SecurityPermission)3 ArrayList (java.util.ArrayList)3 PrivilegedActionException (java.security.PrivilegedActionException)2 UnresolvedPermission (java.security.UnresolvedPermission)2 HashMap (java.util.HashMap)2