Search in sources :

Example 16 with EjbBundleDescriptor

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);
    }
}
Also used : EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) DeploymentException(org.glassfish.deployment.common.DeploymentException) IASSecurityException(com.sun.enterprise.security.util.IASSecurityException) DeploymentException(org.glassfish.deployment.common.DeploymentException)

Example 17 with EjbBundleDescriptor

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);
    }
}
Also used : EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) DeploymentException(org.glassfish.deployment.common.DeploymentException) IASSecurityException(com.sun.enterprise.security.util.IASSecurityException)

Example 18 with EjbBundleDescriptor

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;
}
Also used : EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) Application(com.sun.enterprise.deployment.Application)

Example 19 with EjbBundleDescriptor

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();
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) EjbDeploymentDescriptorFile(org.glassfish.ejb.deployment.io.EjbDeploymentDescriptorFile) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) GenericAnnotationDetector(org.glassfish.deployment.common.GenericAnnotationDetector) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive)

Example 20 with EjbBundleDescriptor

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;
}
Also used : EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation)

Aggregations

EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)28 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)15 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)14 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)7 Application (com.sun.enterprise.deployment.Application)5 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)5 ManagedBeanDescriptor (com.sun.enterprise.deployment.ManagedBeanDescriptor)4 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)4 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)3 WebService (com.sun.enterprise.deployment.WebService)3 Iterator (java.util.Iterator)3 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)2 JMSDestinationDefinitionDescriptor (com.sun.enterprise.deployment.JMSDestinationDefinitionDescriptor)2 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)2 ServiceReferenceDescriptor (com.sun.enterprise.deployment.ServiceReferenceDescriptor)2 EjbsContext (com.sun.enterprise.deployment.annotation.context.EjbsContext)2 IASSecurityException (com.sun.enterprise.security.util.IASSecurityException)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)2