Search in sources :

Example 1 with JndiPermission

use of org.apache.naming.JndiPermission in project Payara by payara.

the class WebappClassLoader method addPermission.

/**
 * If there is a Java SecurityManager create a read FilePermission
 * or JndiPermission for the file directory path.
 *
 * @param path file directory path
 */
public void addPermission(String path) {
    if (path == null) {
        return;
    }
    if (securityManager != null) {
        securityManager.checkSecurityAccess(DDPermissionsLoader.SET_EE_POLICY);
        Permission permission = null;
        if (path.startsWith("jndi:") || path.startsWith("jar:jndi:")) {
            if (!path.endsWith("/")) {
                path = path + "/";
            }
            permission = new JndiPermission(path + "*");
            permissionList.add(permission);
        } else {
            if (!path.endsWith(File.separator)) {
                permission = new FilePermission(path, "read");
                permissionList.add(permission);
                path = path + File.separator;
            }
            permission = new FilePermission(path + "-", "read");
            permissionList.add(permission);
        }
    }
}
Also used : JndiPermission(org.apache.naming.JndiPermission) JndiPermission(org.apache.naming.JndiPermission)

Example 2 with JndiPermission

use of org.apache.naming.JndiPermission in project tomcat70 by apache.

the class WebappClassLoaderBase method addPermission.

/**
 * If there is a Java SecurityManager create a read FilePermission
 * or JndiPermission for the file directory path.
 *
 * @param filepath file directory path
 */
public void addPermission(String filepath) {
    if (filepath == null) {
        return;
    }
    String path = filepath;
    if (securityManager != null) {
        Permission permission = null;
        if (path.startsWith("jndi:") || path.startsWith("jar:jndi:")) {
            if (!path.endsWith("/")) {
                path = path + "/";
            }
            permission = new JndiPermission(path + "*");
            addPermission(permission);
        } else {
            if (!path.endsWith(File.separator)) {
                permission = new FilePermission(path, "read");
                addPermission(permission);
                path = path + File.separator;
            }
            permission = new FilePermission(path + "-", "read");
            addPermission(permission);
        }
    }
}
Also used : JndiPermission(org.apache.naming.JndiPermission) FilePermission(java.io.FilePermission) Permission(java.security.Permission) JndiPermission(org.apache.naming.JndiPermission) FilePermission(java.io.FilePermission)

Aggregations

JndiPermission (org.apache.naming.JndiPermission)2 FilePermission (java.io.FilePermission)1 Permission (java.security.Permission)1