use of com.sun.enterprise.security.permissionsxml.SetPermissionsAction in project Payara by payara.
the class EjbJarHandler method getClassLoader.
public ClassLoader getClassLoader(final ClassLoader parent, DeploymentContext context) {
ASURLClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<ASURLClassLoader>() {
@Override
public ASURLClassLoader run() {
return new ASURLClassLoader(parent);
}
});
try {
String compatProp = context.getAppProps().getProperty(COMPATIBILITY);
// let's see if it's defined in glassfish-ejb-jar.xml
if (compatProp == null) {
compatProp = new GFEjbJarXMLParser(context.getSource()).getCompatibilityValue();
if (compatProp != null) {
context.getAppProps().put(COMPATIBILITY, compatProp);
}
}
// let's see if it's defined in sun-ejb-jar.xml
if (compatProp == null) {
compatProp = new SunEjbJarXMLParser(context.getSourceDir()).getCompatibilityValue();
if (compatProp != null) {
context.getAppProps().put(DeploymentProperties.COMPATIBILITY, compatProp);
}
}
// compatibility of v2 jar visibility
if (compatProp != null && compatProp.equals("v2")) {
List<URL> moduleRootLibraries = ASClassLoaderUtil.getURLsAsList(null, new File[] { context.getSourceDir() }, true);
for (URL url : moduleRootLibraries) {
cloader.addURL(url);
}
}
cloader.addURL(context.getSource().getURI().toURL());
cloader.addURL(context.getScratchDir("ejb").toURI().toURL());
// Add libraries referenced from manifest
for (URL url : getManifestLibraries(context)) {
cloader.addURL(url);
}
try {
doPrivileged(new SetPermissionsAction(CommponentType.ejb, context, cloader));
} catch (PrivilegedActionException e) {
throw new SecurityException(e.getException());
}
} catch (Exception e) {
_logger.severe(e.getMessage());
throw new RuntimeException(e);
}
return cloader;
}
use of com.sun.enterprise.security.permissionsxml.SetPermissionsAction in project Payara by payara.
the class RarHandler method getClassLoader.
/**
* {@inheritDoc}
*/
public ClassLoader getClassLoader(ClassLoader parent, DeploymentContext context) {
try {
String moduleDir = context.getSource().getURI().getPath();
String moduleName = context.getSource().getName();
List<URI> appLibs = null;
try {
appLibs = context.getAppLibs();
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, "installed libraries (--applibs and EXTENSTION_LIST) for rar " + "[ " + moduleName + " ] : " + appLibs);
}
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
ClassLoader carCL;
if (isEmbedded(context)) {
String applicationName = ConnectorsUtil.getApplicationName(context);
String embeddedRarName = ConnectorsUtil.getEmbeddedRarModuleName(applicationName, moduleName);
// ear's classloader hierarchy is : module-CL -> ear-CL (contains all ejb module classpath)
// -> embedded-RAR-CL -> ear-lib-CL.
// parent provided here is ear-CL, we need to use
// ear-lib-CL as parent for embedded-RAR module-CL
carCL = loader.createRARClassLoader(moduleDir, parent.getParent().getParent(), embeddedRarName, appLibs);
} else {
carCL = loader.createRARClassLoader(moduleDir, null, moduleName, appLibs);
}
try {
doPrivileged(new SetPermissionsAction(CommponentType.rar, context, carCL));
} catch (PrivilegedActionException e) {
throw new SecurityException(e.getException());
}
return carCL;
} catch (ConnectorRuntimeException e) {
throw new RuntimeException(e);
}
}
use of com.sun.enterprise.security.permissionsxml.SetPermissionsAction in project Payara by payara.
the class WarHandler method getClassLoader.
@Override
public ClassLoader getClassLoader(final ClassLoader parent, final DeploymentContext context) {
Application applicationTemp = context.getModuleMetaData(Application.class);
boolean hotDeploy = context.getCommandParameters(DeployCommandParameters.class).hotDeploy;
final Application application = applicationTemp == null ? Application.createApplication() : applicationTemp;
WebappClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {
@Override
public WebappClassLoader run() {
return new WebappClassLoader(parent, application, hotDeploy);
}
});
try {
WebDirContext r = new WebDirContext();
File base = new File(context.getSource().getURI());
r.setDocBase(base.getAbsolutePath());
cloader.setResources(r);
cloader.addRepository("WEB-INF/classes/", new File(base, "WEB-INF/classes/"));
if (context.getScratchDir("ejb") != null) {
cloader.addRepository(context.getScratchDir("ejb").toURI().toURL().toString().concat("/"));
}
if (context.getScratchDir("jsp") != null) {
cloader.setWorkDir(context.getScratchDir("jsp"));
}
// add libraries referenced from manifest
for (URL url : getManifestLibraries(context)) {
cloader.addRepository(url.toString());
}
WebXmlParser webXmlParser = getWebXmlParser(context.getSource(), application);
configureLoaderAttributes(cloader, webXmlParser, base);
configureLoaderProperties(cloader, webXmlParser, base);
configureContextXmlAttribute(cloader, base, context);
try {
doPrivileged(new SetPermissionsAction(CommponentType.war, context, cloader));
} catch (PrivilegedActionException e) {
throw new SecurityException(e.getException());
}
} catch (XMLStreamException xse) {
logger.log(SEVERE, xse.getMessage());
if (logger.isLoggable(FINE)) {
logger.log(FINE, xse.getMessage(), xse);
}
xse.printStackTrace();
} catch (IOException ioe) {
logger.log(SEVERE, ioe.getMessage());
if (logger.isLoggable(FINE)) {
logger.log(FINE, ioe.getMessage(), ioe);
}
ioe.printStackTrace();
}
cloader.start();
return cloader;
}
Aggregations