Search in sources :

Example 1 with PermissionFactory

use of org.jboss.modules.security.PermissionFactory in project wildfly by wildfly.

the class EEDefaultPermissionsProcessor method deploy.

public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleSpecification attachment = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    if (attachment == null) {
        return;
    }
    final List<PermissionFactory> permissions = attachment.getPermissionFactories();
    final Enumeration<Permission> e = DEFAULT_PERMISSIONS.elements();
    while (e.hasMoreElements()) {
        permissions.add(new ImmediatePermissionFactory(e.nextElement()));
    }
    //make sure they can read the contents of the deployment
    ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
    try {
        File file = root.getRoot().getPhysicalFile();
        if (file != null && file.isDirectory()) {
            FilePermission permission = new FilePermission(file.getAbsolutePath() + File.separatorChar + "-", "read");
            permissions.add(new ImmediatePermissionFactory(permission));
        }
    } catch (IOException ex) {
        throw new DeploymentUnitProcessingException(ex);
    }
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ImmediatePermissionFactory(org.jboss.modules.security.ImmediatePermissionFactory) PermissionFactory(org.jboss.modules.security.PermissionFactory) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) Permission(java.security.Permission) FilePermission(java.io.FilePermission) JndiPermission(org.wildfly.naming.java.permission.JndiPermission) ImmediatePermissionFactory(org.jboss.modules.security.ImmediatePermissionFactory) IOException(java.io.IOException) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) File(java.io.File) FilePermission(java.io.FilePermission)

Aggregations

File (java.io.File)1 FilePermission (java.io.FilePermission)1 IOException (java.io.IOException)1 Permission (java.security.Permission)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)1 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)1 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)1 ImmediatePermissionFactory (org.jboss.modules.security.ImmediatePermissionFactory)1 PermissionFactory (org.jboss.modules.security.PermissionFactory)1 JndiPermission (org.wildfly.naming.java.permission.JndiPermission)1