private void processComponentConfig(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final Module module, final DeploymentReflectionIndex deploymentReflectionIndex, final T description) throws DeploymentUnitProcessingException { final Class<?> componentClass; try { componentClass = module.getClassLoader().loadClass(description.getEJBClassName()); } catch (ClassNotFoundException e) { throw EjbLogger.ROOT_LOGGER.failToLoadEjbClass(description.getEJBClassName(), e); } if (!MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) { handleAnnotations(deploymentUnit, applicationClasses, deploymentReflectionIndex, componentClass, description); } handleDeploymentDescriptor(deploymentUnit, deploymentReflectionIndex, componentClass, description); }
final Collection<ViewDescription> views = sessionBean.getViews(); if (views == null || views.isEmpty()) { EjbLogger.DEPLOYMENT_LOGGER.noJNDIBindingsForSessionBean(sessionBean.getEJBName()); return; final String applicationName = sessionBean.getModuleDescription().getEarApplicationName(); final String distinctName = sessionBean.getModuleDescription().getDistinctName(); // default to empty string final String globalJNDIBaseName = "java:global/" + (applicationName != null ? applicationName + "/" : "") + sessionBean.getModuleName() + "/" + sessionBean.getEJBName(); final String appJNDIBaseName = "java:app/" + sessionBean.getModuleName() + "/" + sessionBean.getEJBName(); final String moduleJNDIBaseName = "java:module/" + sessionBean.getEJBName(); final String remoteExportedJNDIBaseName = "java:jboss/exported/" + (applicationName != null ? applicationName + "/" : "") + sessionBean.getModuleName() + "/" + sessionBean.getEJBName(); final String ejbNamespaceBindingBaseName = "ejb:" + (applicationName != null ? applicationName + "/" : "") + sessionBean.getModuleName() + "/" + (distinctName != "" ? distinctName + "/" : "") + sessionBean.getEJBName(); final String ejbNamespaceBindingName = sessionBean.isStateful() ? ejbNamespaceBindingBaseName + "!" + viewClassName + "?stateful" : ejbNamespaceBindingBaseName + "!" + viewClassName; logBinding(jndiBindingsLogMessage, ejbNamespaceBindingName); EjbLogger.DEPLOYMENT_LOGGER.jndiBindings(sessionBean.getEJBName(), deploymentUnit, jndiBindingsLogMessage);
final Map<String, InjectedValue<ComponentView>> remoteViews = new HashMap<String, InjectedValue<ComponentView>>(); final Map<String, InjectedValue<ComponentView>> localViews = new HashMap<String, InjectedValue<ComponentView>>(); for (final ViewDescription view : ejbComponentDescription.getViews()) { boolean remoteView = false; if (view instanceof EJBViewDescription) { if (ejbComponentDescription.isExposedViaIiop()) { injectedValues.put(ejbComponentDescription.getServiceName().append(EjbIIOPService.SERVICE_NAME), iorFactory); final EjbDeploymentInformation info = new EjbDeploymentInformation(ejbComponentDescription.getEJBName(), componentInjectedValue, remoteViews, localViews, module.getClassLoader(), iorFactory); deploymentInformationMap.put(ejbComponentDescription.getEJBName(), info);
protected EJBViewDescription registerView(final String viewClassName, final MethodIntf viewType, final boolean ejb2xView) { // setup the ViewDescription final EJBViewDescription viewDescription = new EJBViewDescription(this, viewClassName, viewType, ejb2xView); getViews().add(viewDescription); // setup server side view interceptors setupViewInterceptors(viewDescription); // setup client side view interceptors setupClientViewInterceptors(viewDescription); // return created view if (viewType == MethodIntf.REMOTE || viewType == MethodIntf.HOME) { setupRemoteView(viewDescription); } return viewDescription; }
@Override protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription description) throws DeploymentUnitProcessingException { if (description.getDescriptorData() == null) { return; } final SecurityRoleRefsMetaData roleRefs = description.getDescriptorData().getSecurityRoleRefs(); if (roleRefs != null) { for(SecurityRoleRefMetaData ref : roleRefs) { description.addDeclaredRoles(ref.getRoleName()); } } } }
public void addLocalHome(final String localHome) { final EjbHomeViewDescription view = new EjbHomeViewDescription(this, localHome, MethodIntf.LOCAL_HOME); view.getConfigurators().add(new Ejb2ViewTypeConfigurator(Ejb2xViewType.LOCAL_HOME)); getViews().add(view); // setup server side view interceptors setupViewInterceptors(view); // setup client side view interceptors setupClientViewInterceptors(view); // return created view this.ejbLocalHomeView = view; }
final ResourceLoader loader = beanDeploymentArchive.getServices().get(ResourceLoader.class); ejbClass = (Class<T>) loader.classForName(componentDescription.getEJBClassName()); if (componentDescription.getViews() != null) { for (ViewDescription view : componentDescription.getViews()) { this.ejbName = componentDescription.getEJBName(); Map<Class<?>, ServiceName> viewServices = new HashMap<Class<?>, ServiceName>(); for (ViewDescription view : componentDescription.getViews()) { viewServices.put(loader.classForName(view.getViewClassName()), view.getServiceName()); this.localInterfaces = localInterfaces; this.remoteInterfaces = remoteInterfaces; this.baseName = componentDescription.getServiceName(); this.stateless = componentDescription.isStateless(); this.messageDriven = componentDescription.isMessageDriven(); this.stateful = componentDescription.isStateful(); this.singleton = componentDescription.isSingleton();
final Class<?> componentClass; try { componentClass = module.getClassLoader().loadClass(ejbComponentDescription.getComponentClassName()); } catch (ClassNotFoundException e) { throw EjbLogger.ROOT_LOGGER.failToLoadComponentClass(e, ejbComponentDescription.getComponentClassName()); final List<InterceptorBindingMetaData> bindingsApplicableForCurrentEJB = bindingsPerEJB.get(ejbComponentDescription.getComponentName()); final Map<Method, List<InterceptorBindingMetaData>> methodInterceptors = new HashMap<Method, List<InterceptorBindingMetaData>>(); final List<InterceptorBindingMetaData> classLevelBindings = new ArrayList<InterceptorBindingMetaData>(); ejbComponentDescription.setDefaultContainerInterceptors(interceptorDescriptionsForAllEJBs); ejbComponentDescription.setExcludeDefaultContainerInterceptors(true); ejbComponentDescription.setExcludeDefaultContainerInterceptors(true); } else { for (InterceptorBindingMetaData binding : classLevelBindings) { ejbComponentDescription.setClassLevelContainerInterceptors(classLevelInterceptors); excludeDefaultInterceptors = excludeDefaultInterceptors == null ? false : excludeDefaultInterceptors; if (!excludeDefaultInterceptors) { excludeDefaultInterceptors = ejbComponentDescription.isExcludeDefaultContainerInterceptors() || ejbComponentDescription.isExcludeDefaultContainerInterceptors(methodIdentifier); excludeClassInterceptors = excludeClassInterceptors == null ? false : excludeClassInterceptors; if (!excludeClassInterceptors) { excludeClassInterceptors = ejbComponentDescription.isExcludeClassLevelContainerInterceptors(methodIdentifier); ejbComponentDescription.excludeClassLevelContainerInterceptors(methodIdentifier);
private void processEjb(final EJBComponentDescription componentDescription, final DeploymentReflectionIndex deploymentReflectionIndex, final Module module, final ServiceTarget serviceTarget, final IIOPMetaData iiopMetaData) { componentDescription.setExposedViaIiop(true); final EJBViewDescription remoteView = componentDescription.getEjbRemoteView(); final Class<?> remoteClass; try { remoteClass = ClassLoadingUtils.loadClass(remoteView.getViewClassName(), module); } catch (ClassNotFoundException e) { throw EjbLogger.ROOT_LOGGER.failedToLoadViewClassForComponent(e, componentDescription.getEJBClassName()); final EJBViewDescription homeView = componentDescription.getEjbHomeView(); final Class<?> homeClass; try { homeClass = ClassLoadingUtils.loadClass(homeView.getViewClassName(), module); } catch (ClassNotFoundException e) { throw EjbLogger.ROOT_LOGGER.failedToLoadViewClassForComponent(e, componentDescription.getEJBClassName()); componentDescription.getEjbHomeView().getConfigurators().add(new IIOPInterceptorViewConfigurator()); componentDescription.getEjbRemoteView().getConfigurators().add(new IIOPInterceptorViewConfigurator()); throw EjbLogger.ROOT_LOGGER.failedToAnalyzeRemoteInterface(e, componentDescription.getComponentName()); throw EjbLogger.ROOT_LOGGER.failedToAnalyzeRemoteInterface(e, componentDescription.getComponentName()); final ServiceBuilder<EjbIIOPService> builder = serviceTarget.addService(componentDescription.getServiceName().append(EjbIIOPService.SERVICE_NAME), service); builder.addDependency(componentDescription.getCreateServiceName(), EJBComponent.class, service.getEjbComponentInjectedValue()); builder.addDependency(homeView.getServiceName(), ComponentView.class, service.getHomeView()); builder.addDependency(remoteView.getServiceName(), ComponentView.class, service.getRemoteView());
final boolean isSecurityDomainKnown = ejbComponentDescription.isSecurityDomainKnown(); final String viewClassName = viewDescription.getViewClassName(); final EJBViewDescription ejbViewDescription = (EJBViewDescription) viewDescription; viewMethodSecurityAttributesServiceName = EJBViewMethodSecurityAttributesService.getServiceName(ejbComponentDescription.getApplicationName(), ejbComponentDescription.getModuleName(), ejbComponentDescription.getEJBName(), viewClassName); } else { viewMethodSecurityAttributesServiceBuilder = null; if (ejbComponentDescription.getSecurityDomain() == null || ejbComponentDescription.getSecurityDomain().isEmpty()) { if (ROOT_LOGGER.isDebugEnabled()) { ROOT_LOGGER .debug("Security is *not* enabled on EJB: " + ejbComponentDescription.getEJBName() + ", since no explicit security domain is configured for the bean, nor is there any default security domain configured in the EJB3 subsystem"); final ApplicableMethodInformation<EJBMethodSecurityAttribute> permissions = ejbComponentDescription.getDescriptorMethodPermissions(); boolean methodHasSecurityMetadata = handlePermissions(contextID, componentConfiguration, viewConfiguration, deploymentReflectionIndex, viewClassName, ejbViewDescription, viewMethod, permissions, false, viewMethodSecurityAttributesServiceBuilder, ejbComponentDescription); if (!methodHasSecurityMetadata) { methodHasSecurityMetadata = handlePermissions(contextID, componentConfiguration, viewConfiguration, deploymentReflectionIndex, viewClassName, ejbViewDescription, viewMethod, ejbComponentDescription.getAnnotationMethodPermissions(), true, viewMethodSecurityAttributesServiceBuilder, ejbComponentDescription); final boolean securityRequired = beanHasMethodLevelSecurityMetadata || ejbComponentDescription.hasBeanLevelSecurityMetadata(); ejbComponentDescription.setSecurityRequired(securityRequired); final HashMap<Integer, InterceptorFactory> elytronInterceptorFactories = ejbComponentDescription.getElytronInterceptorFactories(contextID, ejbComponentDescription.isEnableJacc(), true); elytronInterceptorFactories.forEach((priority, elytronInterceptorFactory) -> viewConfiguration.addViewInterceptor(elytronInterceptorFactory, priority)); } else { final Boolean denyAccessToMethodsMissingPermissions = ((EJBComponentDescription) componentConfiguration.getComponentDescription()).isMissingMethodPermissionsDeniedAccess();
/** * @param componentConfiguration Component configuration of the EJB component */ public EJBSecurityMetaData(final ComponentConfiguration componentConfiguration) { if (componentConfiguration.getComponentDescription() instanceof EJBComponentDescription == false) { throw MESSAGES.invalidComponentConfiguration(componentConfiguration.getComponentName()); } final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) componentConfiguration.getComponentDescription(); this.ejbClassName = ejbComponentDescription.getEJBClassName(); this.ejbName = ejbComponentDescription.getEJBName(); this.runAsRole = ejbComponentDescription.getRunAs(); this.securityDomain = ejbComponentDescription.getSecurityDomain(); this.runAsPrincipal = ejbComponentDescription.getRunAsPrincipal(); this.securityRoles = ejbComponentDescription.getSecurityRoles(); final Map<String, Collection<String>> links = ejbComponentDescription.getSecurityRoleLinks(); // security role links configured via <security-role-ref> this.securityRoleLinks = links == null ? Collections.<String, Collection<String>>emptyMap() : Collections.unmodifiableMap(links); // @DeclareRoles final Set<String> roles = ejbComponentDescription.getDeclaredRoles(); this.declaredRoles = roles == null ? Collections.<String>emptySet() : Collections.unmodifiableSet(roles); }
ApplicableMethodInformation<EJBMethodSecurityAttribute> permissions = ejbComponentDescription.getDescriptorMethodPermissions(); boolean createdPerms = this.createPermissions(ejbJaccConfig, ejbComponentDescription, ejbViewConfiguration, viewMethod, reflectionIndex, permissions); permissions = ejbComponentDescription.getAnnotationMethodPermissions(); createPermissions(ejbJaccConfig, ejbComponentDescription, ejbViewConfiguration, viewMethod, reflectionIndex, permissions); SecurityRolesMetaData secRolesMetaData = ejbComponentDescription.getSecurityRoles(); if (secRolesMetaData != null) { for (SecurityRoleMetaData secRoleMetaData : secRolesMetaData) { Map<String, Collection<String>> securityRoleRefs = ejbComponentDescription.getSecurityRoleLinks(); for (Map.Entry<String, Collection<String>> entry : securityRoleRefs.entrySet()) { String roleName = entry.getKey(); for (String roleLink : entry.getValue()) { EJBRoleRefPermission p = new EJBRoleRefPermission(ejbComponentDescription.getEJBName(), roleName); ejbJaccConfig.addRole(roleLink, p); Set<String> declaredRoles = ejbComponentDescription.getDeclaredRoles(); for (String role : declaredRoles) { if (!securityRoleRefs.containsKey(role)) { EJBRoleRefPermission p = new EJBRoleRefPermission(ejbComponentDescription.getEJBName(), role); ejbJaccConfig.addRole(role, p); EJBRoleRefPermission p = new EJBRoleRefPermission(ejbComponentDescription.getEJBName(), role); ejbJaccConfig.addRole(role, p); SessionBeanComponentDescription session = SessionBeanComponentDescription.class.cast(ejbComponentDescription); if (session.isStateful()) { EJBMethodPermission p = new EJBMethodPermission(ejbComponentDescription.getEJBName(), "getEJBObject", "Home", null);
private void registerRemoteBinding(final EJBComponentDescription componentDescription, final ViewDescription viewDescription, final String jndiName) { final EEModuleDescription moduleDescription = componentDescription.getModuleDescription(); final InjectedValue<ClassLoader> viewClassLoader = new InjectedValue<ClassLoader>(); moduleDescription.getBindingConfigurations().add(new BindingConfiguration(jndiName, new RemoteViewInjectionSource(null, moduleDescription.getEarApplicationName(), moduleDescription.getModuleName(), moduleDescription.getDistinctName(), componentDescription.getComponentName(), viewDescription.getViewClassName(), componentDescription.isStateful(), viewClassLoader, appclient))); componentDescription.getConfigurators().add(new ComponentConfigurator() { public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException { viewClassLoader.setValue(Values.immediateValue(configuration.getModuleClassLoader())); } }); } private void registerControlPointBinding(final EJBComponentDescription componentDescription, final ViewDescription viewDescription, final String jndiName, final DeploymentUnit deploymentUnit) {
@Override protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription description) throws DeploymentUnitProcessingException { final EnterpriseBeanMetaData descriptorData = description.getDescriptorData(); if (descriptorData != null) { if (description.isSession() || description.isMessageDriven()) { assert descriptorData instanceof ITimeoutTarget : descriptorData + " is not an ITimeoutTarget"; ITimeoutTarget target = (ITimeoutTarget) descriptorData; if (method != null) { final Method otherMethod = description.getTimeoutMethod(); if (otherMethod != null) { if (!otherMethod.equals(method)) { description.setTimeoutMethod(method); break;
this.descriptorData = descriptorData; if (ejbJarDescription.isWar()) { setNamingMode(ComponentNamingMode.USE_MODULE); } else { setNamingMode(ComponentNamingMode.CREATE); getConfigurators().addFirst(new NamespaceConfigurator()); getConfigurators().add(new EjbJarConfigurationConfigurator()); getConfigurators().add(new SecurityDomainDependencyConfigurator(this)); this.addCurrentInvocationContextFactory(); this.addRemoteTransactionsDependency(); this.transactionAttributes = new ApplicableMethodInformation<TransactionAttributeType>(componentName, TransactionAttributeType.REQUIRED); this.transactionTimeouts = new ApplicableMethodInformation<Integer>(componentName, null); addDependency(deploymentUnitServiceName.append(ModuleDeployment.SERVICE_NAME)); getConfigurators().addFirst(EJBValidationConfigurator.INSTANCE); getConfigurators().add(new ComponentConfigurator() { @Override public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { addTransactionManagerDependencies(); addEJBSuspendHandlerDependency(); addServerSecurityManagerDependency();
final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) description; final ServiceName invokerServiceName = ejbComponentDescription.getServiceName().append(TimedObjectInvokerImpl.SERVICE_NAME); final TimedObjectInvokerImpl invoker = new TimedObjectInvokerImpl(deploymentName, module); context.getServiceTarget().addService(invokerServiceName, invoker) final TimerServiceImpl service = new TimerServiceImpl(ejbComponentDescription.getScheduleMethods(), serviceName, timerServiceRegistry); final ServiceBuilder<javax.ejb.TimerService> createBuilder = context.getServiceTarget().addService(serviceName, service); createBuilder.addDependency(TIMER_SERVICE_NAME, Timer.class, service.getTimerInjectedValue()); createBuilder.addDependency(componentDescription.getCreateServiceName(), EJBComponent.class, service.getEjbComponentInjectedValue()); createBuilder.addDependency(timerServiceThreadPool, ExecutorService.class, service.getExecutorServiceInjectedValue()); if (timerPersistenceServices.containsKey(ejbComponentDescription.getEJBName())) { createBuilder.addDependency(timerPersistenceServices.get(ejbComponentDescription.getEJBName()), TimerPersistence.class, service.getTimerPersistence()); } else { createBuilder.addDependency(finalDefaultTimerPersistenceService, TimerPersistence.class, service.getTimerPersistence()); ejbComponentDescription.setTimerService(service);
@Override protected InjectionSource createInjectionSource(final ServiceName serviceName, Value<ClassLoader> viewClassLoader, boolean appclient) { if(methodIntf != MethodIntf.REMOTE && methodIntf != MethodIntf.HOME) { return super.createInjectionSource(serviceName, viewClassLoader, appclient); } else { final EJBComponentDescription componentDescription = getComponentDescription(); final EEModuleDescription desc = componentDescription.getModuleDescription(); final String earApplicationName = desc.getEarApplicationName(); return new RemoteViewInjectionSource(serviceName, earApplicationName, desc.getModuleName(), desc.getDistinctName(), componentDescription.getComponentName(), getViewClassName() , componentDescription.isStateful(),viewClassLoader, appclient); } }
if (component.getDescriptorData() == null) { return; final Class<?> componentClass = ClassLoadingUtils.loadClass(component.getComponentClassName(), module); final EnterpriseBeanMetaData metaData = component.getDescriptorData(); if (aroundInvoke.getClassName() == null || aroundInvoke.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else { component.addInterceptorMethodOverride(aroundInvoke.getClassName(), builder.build()); if (postConstruct.getClassName() == null || postConstruct.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else { component.addInterceptorMethodOverride(postConstruct.getClassName(), builder.build()); if (preDestroy.getClassName() == null || preDestroy.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else { component.addInterceptorMethodOverride(preDestroy.getClassName(), builder.build()); if (component.isStateful()) { if (prePassivate.getClassName() == null || prePassivate.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
private void setupDependencies(final EJBComponentDescription description, final EEApplicationDescription applicationDescription, final ResourceRoot deploymentRoot, final String[] annotationValues) throws DeploymentUnitProcessingException { for (final String annotationValue : annotationValues) { final Set<ComponentDescription> components = applicationDescription.getComponents(annotationValue, deploymentRoot.getRoot()); if (components.isEmpty()) { throw EjbLogger.ROOT_LOGGER.failToFindEjbRefByDependsOn(annotationValue, description.getComponentClassName()); } else if (components.size() != 1) { throw EjbLogger.ROOT_LOGGER.failToCallEjbRefByDependsOn(annotationValue, description.getComponentClassName(), components); } final ComponentDescription component = components.iterator().next(); description.addDependency(component.getStartServiceName()); if (description instanceof SingletonComponentDescription) { ((SingletonComponentDescription)description).getDependsOn().add(component.getStartServiceName()); if (ROOT_LOGGER.isDebugEnabled()) { ROOT_LOGGER.debugf(description.getEJBName() + " bean is dependent on " + component.getComponentName()); } } } } }
if (ejbComponentDescription.getSecurityDomain() == null) { ROOT_LOGGER.debug("Security is *not* enabled on EJB: " + ejbComponentDescription.getEJBName() + ", since no explicit security domain is configured for the bean, nor is there any default security domain configured in the EJB3 subsystem"); return; final ApplicableMethodInformation<EJBMethodSecurityAttribute> permissions = ejbComponentDescription.getDescriptorMethodPermissions(); boolean methodHasSecurityMetadata = handlePermissions(contextID, componentConfiguration, viewConfiguration, deploymentReflectionIndex, viewClassName, ejbViewDescription, viewMethod, permissions, false); if (!methodHasSecurityMetadata) { methodHasSecurityMetadata = handlePermissions(contextID, componentConfiguration, viewConfiguration, deploymentReflectionIndex, viewClassName, ejbViewDescription, viewMethod, ejbComponentDescription.getAnnotationMethodPermissions(), true); final Boolean denyAccessToMethodsMissingPermissions = ((EJBComponentDescription) componentConfiguration.getComponentDescription()).isMissingMethodPermissionsDeniedAccess(); ROOT_LOGGER.debug("Security is *not* enabled on EJB: " + ejbComponentDescription.getEJBName() + ", no security interceptors will apply"); return;