Class clazz = unitCl.loadClass(webClassLoaderName);
wcl = WebClassLoaderFactory.createWebClassLoader(clazz, container.getJmxName(), (RealClassLoader) unitCl);
}
catch (Exception e)
{
throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e);
}
if (webServiceName != null)
{
WebServiceMBean webServer = (WebServiceMBean) MBeanProxyExt.create(WebServiceMBean.class, webServiceName);
URL[] codebase = {webServer.addClassLoader(wcl)};
wcl.setWebURLs(codebase);
} // end of if ()
container.setWebClassLoader(wcl);
// Create classloader for this container
// Only used to unique the bean ENC and does not augment class loading
container.setClassLoader(new DelegatingClassLoader(wcl));
// Set transaction manager
InitialContext iniCtx = new InitialContext();
container.setTransactionManager(tmFactory.getTransactionManager());
// Set
container.setTimerService(timerService);
// Set security domain manager
String securityDomain = bean.getApplicationMetaData().getSecurityDomain();
// JBAS-5960: Set default security domain if there is security metadata
boolean hasSecurityMetaData = hasSecurityMetaData(bean);
if (securityDomain == null && hasSecurityMetaData)
{
securityDomain = SecurityConstants.DEFAULT_EJB_APPLICATION_POLICY;
}
String confSecurityDomain = conf.getSecurityDomain();
// Default the config security to the application security manager
if (confSecurityDomain == null)
confSecurityDomain = securityDomain;
// Check for an empty confSecurityDomain which signifies to disable security
if (confSecurityDomain != null && confSecurityDomain.length() == 0)
confSecurityDomain = null;
if (confSecurityDomain != null)
{ // Either the application has a security domain or the container has security setup
try
{
String unprefixed = SecurityUtil.unprefixSecurityDomain(confSecurityDomain);
log.debug("Setting security domain from: " + confSecurityDomain);
String domainCtx = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + unprefixed + "/domainContext";
SecurityDomainContext sdc = (SecurityDomainContext) iniCtx.lookup(domainCtx);
Object securityMgr = sdc.getSecurityManager();
// Object securityMgr = iniCtx.lookup(confSecurityDomain);
AuthenticationManager ejbS = (AuthenticationManager) securityMgr;
RealmMapping rM = (RealmMapping) securityMgr;
container.setSecurityManager(ejbS);
container.setRealmMapping(rM);
container.setSecurityManagement(securityManagement);
container.setPolicyRegistration(policyRegistration);
container.setDefaultSecurityDomain((String) unit.getAttachment("EJB.defaultSecurityDomain"));
container.setSecurityContextClassName((String) unit.getAttachment("EJB.securityContextClassName"));
}
catch (NamingException e)
{
throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e);
}
catch (Exception e)
{
throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e);
}
}
else
{
if ("".equals(securityDomain) && hasSecurityMetaData)
log.warn("EJB configured to bypass security. Please verify if this is intended. Bean=" + bean.getEjbName()
+ " Deployment=" + unit.getName());
}
// Load the security proxy instance if one was configured
String securityProxyClassName = bean.getSecurityProxy();
if (securityProxyClassName != null)
{
try
{
Class proxyClass = unitCl.loadClass(securityProxyClassName);
Object proxy = proxyClass.newInstance();
container.setSecurityProxy(proxy);
log.debug("setSecurityProxy, " + proxy);
}
catch (Exception e)
{
throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e);
}
}
// Install the container interceptors based on the configuration
addInterceptors(container, transType, conf.getContainerInterceptorsConf());