use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.
the class SecurityDeployer method commitEjbs.
/**
* commits ejb policy contexts. This should occur in EjbApplication, being done here until issue with
* ejb-ejb31-singleton-multimoduleApp.ear is resolved
*
* @param ejbs
*/
private void commitEjbs(Application app) throws DeploymentException {
Set<EjbBundleDescriptor> ejbDescriptors = app.getBundleDescriptors(EjbBundleDescriptor.class);
try {
for (EjbBundleDescriptor ejbBD : ejbDescriptors) {
String pcid = SecurityUtil.getContextID(ejbBD);
ejbProbeProvider.policyCreationStartedEvent(pcid);
SecurityUtil.generatePolicyFile(pcid);
ejbProbeProvider.policyCreationEndedEvent(pcid);
ejbProbeProvider.policyCreationEvent(pcid);
}
} catch (Exception se) {
String msg = "Error in committing security policy for ejbs of " + app.getRegistrationName();
throw new DeploymentException(msg, se);
}
}
use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.
the class SecurityDeployer method linkPolicies.
/**
* Links the policy contexts of the application
*
* @param app
* @param webs
*/
private void linkPolicies(Application app, Collection<WebBundleDescriptor> webs) throws DeploymentException {
try {
String linkName = null;
boolean lastInService = false;
for (WebBundleDescriptor wbd : webs) {
String name = SecurityUtil.getContextID(wbd);
lastInService = SecurityUtil.linkPolicyFile(name, linkName, lastInService);
linkName = name;
}
// reset link name
linkName = null;
Set<EjbBundleDescriptor> ejbs = app.getBundleDescriptors(EjbBundleDescriptor.class);
for (EjbBundleDescriptor ejbd : ejbs) {
String name = SecurityUtil.getContextID(ejbd);
lastInService = SecurityUtil.linkPolicyFile(name, linkName, lastInService);
linkName = name;
}
// extra commit (see above)
} catch (IASSecurityException se) {
String msg = "Error in linking security policy for " + app.getRegistrationName();
throw new DeploymentException(msg, se);
}
}
use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.
the class SecurityUtil method createUniquePseudoModuleID.
/**
* create pseudo module context id, and make sure it is unique, by chacking it against the names of all the other
* modules in the app.
*
* @param ejbDesc
* @return
*/
private static String createUniquePseudoModuleID(EjbBundleDescriptor ejbDesc) {
Application app = ejbDesc.getApplication();
Collection<WebBundleDescriptor> webModules = app.getBundleDescriptors(WebBundleDescriptor.class);
Collection<EjbBundleDescriptor> ejbModules = app.getBundleDescriptors(EjbBundleDescriptor.class);
String moduleName = ejbDesc.getUniqueFriendlyId();
String pseudonym;
int uniquifier = 0;
boolean unique;
do {
unique = true;
pseudonym = moduleName + (uniquifier == 0 ? "_internal" : "_internal_" + uniquifier);
if (webModules != null) {
for (WebBundleDescriptor w : webModules) {
if (pseudonym.equals(w.getUniqueFriendlyId())) {
unique = false;
break;
}
}
}
if (unique && ejbModules != null) {
for (EjbBundleDescriptor e : ejbModules) {
if (pseudonym.equals(e.getUniqueFriendlyId())) {
unique = false;
break;
}
}
}
uniquifier += 1;
} while (!unique);
return VersioningUtils.getRepositoryName(app.getRegistrationName()) + "/" + pseudonym;
}
use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.
the class EJBContainerProviderImpl method getRequestedEJBModuleOrLibrary.
/**
* @returns DeploymentElement if this file represents an EJB module or a library.
* Returns null if it's an EJB module which name is not present in the list of requested
* module names.
*/
private DeploymentElement getRequestedEJBModuleOrLibrary(File file, Map<String, Boolean> moduleNames) throws Exception {
DeploymentElement result = null;
String fileName = file.getName();
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("... Testing ... " + fileName);
}
ReadableArchive archive = null;
InputStream is = null;
try {
boolean isEJBModule = false;
String moduleName = DeploymentUtils.getDefaultEEName(fileName);
archive = archiveFactory.openArchive(file);
is = getDeploymentDescriptor(archive);
if (is != null) {
isEJBModule = true;
EjbDeploymentDescriptorFile eddf = new EjbDeploymentDescriptorFile();
eddf.setXMLValidation(false);
EjbBundleDescriptor bundleDesc = (EjbBundleDescriptor) eddf.read(is);
ModuleDescriptor moduleDesc = bundleDesc.getModuleDescriptor();
moduleDesc.setArchiveUri(fileName);
moduleName = moduleDesc.getModuleName();
} else {
GenericAnnotationDetector detector = new GenericAnnotationDetector(ejbAnnotations);
isEJBModule = detector.hasAnnotationInArchive(archive);
}
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("... is EJB module: " + isEJBModule);
if (isEJBModule) {
_logger.fine("... is Requested EJB module [" + moduleName + "]: " + (moduleNames.isEmpty() || moduleNames.containsKey(moduleName)));
}
}
if (!isEJBModule || moduleNames.isEmpty()) {
result = new DeploymentElement(file, isEJBModule, moduleName);
} else if (moduleNames.containsKey(moduleName) && !moduleNames.get(moduleName)) {
// Is a requested EJB module and was not found already
result = new DeploymentElement(file, isEJBModule, moduleName);
moduleNames.put(moduleName, true);
}
return result;
} finally {
if (archive != null)
archive.close();
if (is != null)
is.close();
}
}
use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.
the class MessageBeanContainer method createComponentInvocation.
private ComponentInvocation createComponentInvocation() {
EjbBundleDescriptor ejbBundleDesc = getEjbDescriptor().getEjbBundleDescriptor();
ComponentInvocation newInv = new ComponentInvocation(getComponentId(), ComponentInvocation.ComponentInvocationType.SERVLET_INVOCATION, this, ejbBundleDesc.getApplication().getAppName(), ejbBundleDesc.getModuleName());
// newInv.setJNDIEnvironment(getJNDIEnvironment()); ???
return newInv;
}
Aggregations