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);
}
}
Aggregations