Search in sources :

Example 21 with EjbDescriptor

use of com.sun.enterprise.deployment.EjbDescriptor in project Payara by payara.

the class AbstractAuthAnnotationHandler method postProcessAnnotation.

/**
 * This method is for processing security annotation associated to ejb.
 * Dervied class call this method may like to override
 *
 * protected void processEjbMethodSecurity(Annotation authAnnotation,
 *         MethodDescriptor md, EjbDescriptor ejbDesc)
 */
@Override
public void postProcessAnnotation(AnnotationInfo ainfo, AnnotatedElementHandler aeHandler) throws AnnotationProcessorException {
    EjbContext ejbContext = (EjbContext) aeHandler;
    EjbDescriptor ejbDesc = ejbContext.getDescriptor();
    Annotation authAnnotation = ainfo.getAnnotation();
    if (!ejbContext.isInherited() && (ejbDesc.getMethodPermissionsFromDD() == null || ejbDesc.getMethodPermissionsFromDD().size() == 0)) {
        for (MethodDescriptor md : getMethodAllDescriptors(ejbDesc)) {
            processEjbMethodSecurity(authAnnotation, md, ejbDesc);
        }
    } else {
        Class classAn = (Class) ainfo.getAnnotatedElement();
        for (Object next : ejbDesc.getSecurityBusinessMethodDescriptors()) {
            MethodDescriptor md = (MethodDescriptor) next;
            // override by existing info
            if (classAn.equals(ejbContext.getDeclaringClass(md)) && !hasMethodPermissionsFromDD(md, ejbDesc)) {
                processEjbMethodSecurity(authAnnotation, md, ejbDesc);
            }
        }
    }
}
Also used : MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor) Annotation(java.lang.annotation.Annotation)

Example 22 with EjbDescriptor

use of com.sun.enterprise.deployment.EjbDescriptor in project Payara by payara.

the class RunAsHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    RunAs runAsAn = (RunAs) ainfo.getAnnotation();
    for (EjbContext ejbContext : ejbContexts) {
        EjbDescriptor ejbDesc = ejbContext.getDescriptor();
        // override by xml
        if (ejbDesc.getUsesCallerIdentity() != null) {
            continue;
        }
        String roleName = runAsAn.value();
        Role role = new Role(roleName);
        // add Role if not exists
        ejbDesc.getEjbBundleDescriptor().addRole(role);
        RunAsIdentityDescriptor runAsDesc = new RunAsIdentityDescriptor();
        runAsDesc.setRoleName(roleName);
        ejbDesc.setUsesCallerIdentity(false);
        if (ejbDesc.getRunAsIdentity() == null) {
            ejbDesc.setRunAsIdentity(runAsDesc);
        }
    }
    return getDefaultProcessedResult();
}
Also used : Role(org.glassfish.security.common.Role) RunAsIdentityDescriptor(com.sun.enterprise.deployment.RunAsIdentityDescriptor) EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) RunAs(javax.annotation.security.RunAs) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 23 with EjbDescriptor

use of com.sun.enterprise.deployment.EjbDescriptor in project Payara by payara.

the class BeanManagerNamingProxy method handle.

@Override
public Object handle(String name) throws NamingException {
    Object beanManager = null;
    if (BEAN_MANAGER_CONTEXT.equals(name)) {
        try {
            // Use invocation context to find applicable BeanDeploymentArchive.
            ComponentInvocation inv = invocationManager.getCurrentInvocation();
            if (inv != null) {
                JndiNameEnvironment componentEnv = compEnvManager.getJndiNameEnvironment(inv.getComponentId());
                if (componentEnv != null) {
                    BundleDescriptor bundle = null;
                    if (componentEnv instanceof EjbDescriptor) {
                        bundle = (BundleDescriptor) ((EjbDescriptor) componentEnv).getEjbBundleDescriptor().getModuleDescriptor().getDescriptor();
                    } else if (componentEnv instanceof WebBundleDescriptor) {
                        bundle = (BundleDescriptor) componentEnv;
                    }
                    if (bundle != null) {
                        BeanDeploymentArchive bda = weldDeployer.getBeanDeploymentArchiveForBundle(bundle);
                        if (bda != null) {
                            WeldBootstrap bootstrap = weldDeployer.getBootstrapForApp(bundle.getApplication());
                            // System.out.println("BeanManagerNamingProxy:: getting BeanManagerImpl for" + bda);
                            beanManager = bootstrap.getManager(bda);
                        }
                    }
                    if (beanManager == null) {
                        throw new IllegalStateException("Cannot resolve bean manager");
                    }
                } else {
                    throw new IllegalStateException("No invocation context found");
                }
            }
        } catch (Throwable t) {
            NamingException ne = new NamingException("Error retrieving java:comp/BeanManager");
            ne.initCause(t);
            throw ne;
        }
    }
    return beanManager;
}
Also used : WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) WeldBootstrap(org.jboss.weld.bootstrap.WeldBootstrap) BeanDeploymentArchive(org.jboss.weld.bootstrap.spi.BeanDeploymentArchive) NamingException(javax.naming.NamingException) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 24 with EjbDescriptor

use of com.sun.enterprise.deployment.EjbDescriptor in project Payara by payara.

the class ValidationNamingProxy method obtainBeanManager.

/**
 * Obtain the BeanManagerNamingProxy from hk2, so the BeanManager can be looked up
 *
 * @throws NamingException
 */
private synchronized BeanManager obtainBeanManager() throws NamingException {
    BeanManager beanManager = null;
    // Use invocation context to find applicable BeanDeploymentArchive.
    ComponentInvocation inv = invocationManager.getCurrentInvocation();
    if (inv != null) {
        JndiNameEnvironment componentEnv = compEnvManager.getJndiNameEnvironment(inv.getComponentId());
        if (componentEnv != null) {
            BundleDescriptor bundle = null;
            if (componentEnv instanceof EjbDescriptor) {
                bundle = (BundleDescriptor) ((EjbDescriptor) componentEnv).getEjbBundleDescriptor().getModuleDescriptor().getDescriptor();
            } else if (componentEnv instanceof WebBundleDescriptor) {
                bundle = (BundleDescriptor) componentEnv;
            }
            if (bundle != null) {
                BeanDeploymentArchive bda = weldDeployer.getBeanDeploymentArchiveForBundle(bundle);
                if (bda != null) {
                    WeldBootstrap bootstrap = weldDeployer.getBootstrapForApp(bundle.getApplication());
                    beanManager = bootstrap.getManager(bda);
                }
            }
        }
    }
    return beanManager;
}
Also used : WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) WeldBootstrap(org.jboss.weld.bootstrap.WeldBootstrap) BeanDeploymentArchive(org.jboss.weld.bootstrap.spi.BeanDeploymentArchive) BeanManager(javax.enterprise.inject.spi.BeanManager) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 25 with EjbDescriptor

use of com.sun.enterprise.deployment.EjbDescriptor in project Payara by payara.

the class JCDIServiceImpl method isCurrentModuleJCDIEnabled.

@Override
public boolean isCurrentModuleJCDIEnabled() {
    BundleDescriptor bundle = null;
    ComponentInvocation inv = invocationManager.getCurrentInvocation();
    if (inv == null) {
        return false;
    }
    JndiNameEnvironment componentEnv = compEnvManager.getJndiNameEnvironment(inv.getComponentId());
    if (componentEnv != null) {
        if (componentEnv instanceof BundleDescriptor) {
            bundle = (BundleDescriptor) componentEnv;
        } else if (componentEnv instanceof EjbDescriptor) {
            bundle = ((EjbDescriptor) componentEnv).getEjbBundleDescriptor();
        }
    }
    return (bundle != null) ? isJCDIEnabled(bundle) : false;
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Aggregations

EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)48 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)16 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)11 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)10 Application (com.sun.enterprise.deployment.Application)6 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)6 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)5 ManagedBeanDescriptor (com.sun.enterprise.deployment.ManagedBeanDescriptor)4 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)4 ArrayList (java.util.ArrayList)4 Descriptor (org.glassfish.deployment.common.Descriptor)4 BeanDeploymentArchive (org.jboss.weld.bootstrap.spi.BeanDeploymentArchive)4 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)3 EjbInterceptor (com.sun.enterprise.deployment.EjbInterceptor)3 EjbMessageBeanDescriptor (com.sun.enterprise.deployment.EjbMessageBeanDescriptor)3 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)3 RunAsIdentityDescriptor (com.sun.enterprise.deployment.RunAsIdentityDescriptor)3 ServiceReferenceDescriptor (com.sun.enterprise.deployment.ServiceReferenceDescriptor)3 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)3 Method (java.lang.reflect.Method)3