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);
}
}
}
}
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();
}
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;
}
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;
}
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;
}
Aggregations