final EJBComponent component = getComponent(context, EJBComponent.class); final ComponentInstance componentInstance = component.createInstance(); context.putPrivateData(ComponentInstance.class, componentInstance); final EJBComponent ejbComponent = component; if (ejbComponent.getApplicationException(ex.getClass(), context.getMethod()) != null) {
public EJBLocalHome getEJBLocalHome() throws IllegalStateException { if (ejbLocalHomeViewServiceName == null) { throw EjbLogger.ROOT_LOGGER.beanLocalHomeInterfaceIsNull(getComponentName()); } return createViewInstanceProxy(EJBLocalHome.class, Collections.emptyMap(), ejbLocalHomeViewServiceName); }
public EJBHome getEJBHome() throws IllegalStateException { if (ejbHomeViewServiceName == null) { throw EjbLogger.ROOT_LOGGER.beanHomeInterfaceIsNull(getComponentName()); } final ServiceController<?> serviceController = currentServiceContainer().getRequiredService(ejbHomeViewServiceName); final ComponentView view = (ComponentView) serviceController.getValue(); final String locatorAppName = earApplicationName == null ? "" : earApplicationName; return EJBClient.createProxy(createHomeLocator(view.getViewClass().asSubclass(EJBHome.class), locatorAppName, moduleName, getComponentName(), distinctName)); }
@Override protected Interceptor create(final Component component, final InterceptorFactoryContext context) { if (! (component instanceof EJBComponent)) { throw EjbLogger.ROOT_LOGGER.unexpectedComponent(component, EJBComponent.class); } final EJBComponent ejbComponent = (EJBComponent) component; final EJBSecurityMetaData securityMetaData = ejbComponent.getSecurityMetaData(); String securityDomainName = securityMetaData.getSecurityDomain(); if (securityDomainName == null) { securityDomainName = DEFAULT_DOMAIN; } final SecurityDomain securityDomain = ejbComponent.getSecurityDomain(); if (securityDomain == null) { throw EjbLogger.ROOT_LOGGER.invalidSecurityForDomainSet(ejbComponent.getComponentName()); } if (ROOT_LOGGER.isTraceEnabled()) { ROOT_LOGGER.trace("Using security domain: " + securityDomainName + " for EJB " + ejbComponent.getComponentName()); } return new SecurityDomainInterceptor(securityDomain); } }
final String earApplicationName = component.getEarApplicationName(); if (iiopMetaData != null && iiopMetaData.getBindingName() != null) { name = iiopMetaData.getBindingName(); } else if (useQualifiedName) { if (component.getDistinctName() == null || component.getDistinctName().isEmpty()) { name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/"; name = name + component.getModuleName() + "/" + component.getComponentName(); } else { name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/"; name = name + component.getModuleName() + "/" + component.getDistinctName() + "/" + component.getComponentName(); name = component.getComponentName(); if (component.getSecurityMetaData() != null) { securityDomain = component.getSecurityMetaData().getSecurityDomain(); component.getSecurityDomain()); module.getClassLoader(), false, securityDomain, component.getSecurityDomain()); beanReferenceFactory = beanServantRegistry.bind(beanServantName(name), beanServant, policies); EjbLogger.ROOT_LOGGER.debugf("Home IOR for %s bound to %s in CORBA naming service", component.getComponentName(), this.name);
final String earApplicationName = component.getEarApplicationName(); if (iiopMetaData != null && iiopMetaData.getBindingName() != null) { name = iiopMetaData.getBindingName(); } else if (useQualifiedName) { if (component.getDistinctName() == null || component.getDistinctName().isEmpty()) { name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/"; name = name + component.getModuleName() + "/" + component.getComponentName(); } else { name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/"; name = name + component.getModuleName() + "/" + component.getDistinctName() + "/" + component.getComponentName(); name = component.getComponentName(); if (component.getSecurityMetaData() != null) { securityDomain = component.getSecurityMetaData().getSecurityDomain(); orb, homeView.getValue(), factory, configuration, component.getTransactionManager(), module.getClassLoader(), true, securityDomain); beanInterfaceDef, orb, remoteView.getValue(), factory, configuration, component.getTransactionManager(), module.getClassLoader(), false, securityDomain); beanReferenceFactory = beanServantRegistry.bind(beanServantName(name), beanServant, policies); EjbLogger.ROOT_LOGGER.debug("Home IOR for " + component.getComponentName() + " bound to " + this.name + " in CORBA naming service");
final EJBComponent ejbComponent = ejbComponentInjectedValue.getValue(); try { final String earApplicationName = ejbComponent.getEarApplicationName() == null ? "" : ejbComponent.getEarApplicationName(); if (locator.getBeanName().equals(ejbComponent.getComponentName()) && locator.getAppName().equals(earApplicationName) && locator.getModuleName().equals(ejbComponent.getModuleName()) && locator.getDistinctName().equals(ejbComponent.getDistinctName())) { if (locator instanceof EJBHomeLocator) { return (org.omg.CORBA.Object) ejbHome; throw EjbLogger.ROOT_LOGGER.incorrectEJBLocatorForBean(locator, ejbComponent.getComponentName());
final ServerSecurityManager securityManager; if(propagateSecurity) { securityManager = ejbComponent.getSecurityManager(); } else { securityManager = new SimpleSecurityManager((SimpleSecurityManager) ejbComponent.getSecurityManager()); final EJBSecurityMetaData securityMetaData = ejbComponent.getSecurityMetaData(); String securityDomain = securityMetaData.getSecurityDomain(); if (securityDomain == null) { ROOT_LOGGER.trace("Using security domain: " + securityDomain + " for EJB " + ejbComponent.getComponentName());
/** * Returns true if the passed <code>exceptionClass</code> is an application exception. Else returns false. * * @param ejbComponent The EJB component * @param exceptionClass The exception class * @return */ private boolean isApplicationException(final EJBComponent ejbComponent, final Class<?> exceptionClass, final Method invokedMethod) { return ejbComponent.getApplicationException(exceptionClass, invokedMethod) != null; }
public boolean isCallerInRole(final String roleName) throws IllegalStateException { if (isSecurityDomainKnown()) { if (enableJacc) { Policy policy = WildFlySecurityManager.isChecking() ? doPrivileged((PrivilegedAction<Policy>) Policy::getPolicy) : Policy.getPolicy(); ProtectionDomain domain = new ProtectionDomain(null, null, null, JaccInterceptor.getGrantedRoles(getCallerSecurityIdentity())); return policy.implies(domain, new EJBRoleRefPermission(getComponentName(), roleName)); } else { return checkCallerSecurityIdentityRole(roleName); } } else if (WildFlySecurityManager.isChecking()) { return WildFlySecurityManager.doUnchecked((PrivilegedAction<Boolean>) () -> serverSecurityManager.isCallerInRole(getComponentName(), policyContextID, securityMetaData.getSecurityRoles(), securityMetaData.getSecurityRoleLinks(), roleName)); } else { return this.serverSecurityManager.isCallerInRole(getComponentName(), policyContextID, securityMetaData.getSecurityRoles(), securityMetaData.getSecurityRoleLinks(), roleName); } }
@Override public Object processInvocation(InterceptorContext interceptorContext) throws Exception { final EJBComponent component = (EJBComponent) interceptorContext.getPrivateData(Component.class); if(!component.isExceptionLoggingEnabled()) { return interceptorContext.proceed(); final Method invokedMethod = interceptorContext.getMethod(); final ApplicationExceptionDetails appException = component.getApplicationException(t.getClass(), invokedMethod); if (appException == null) { EjbLogger.EJB3_INVOCATION_LOGGER.invocationFailed(component.getComponentName(), invokedMethod, t);
@Override public String getTimedObjectId() { return deploymentString + "." + ejbComponent.getValue().getComponentName(); }
public static void addTimers(final EJBComponent ejb, final ModelNode response) { response.setEmptyList(); final String name = ejb.getComponentName(); TimerService ts = ejb.getTimerService(); if (ts != null) { for (Timer timer : ts.getTimers()) { ModelNode timerNode = response.add(); addTimeRemaining(timer, timerNode, name); addNextTimeout(timer, timerNode, name); addCalendarTimer(timer, timerNode, name); addPersistent(timer, timerNode, name); addSchedule(timer, timerNode, name); } } }
private void checkBadStateful() { int status = Status.STATUS_NO_TRANSACTION; TransactionManager tm = getComponent().getTransactionManager(); try { status = tm.getStatus(); } catch (SystemException ex) { EjbLogger.ROOT_LOGGER.failedToGetStatus(ex); } switch (status) { case Status.STATUS_COMMITTING: case Status.STATUS_MARKED_ROLLBACK: case Status.STATUS_PREPARING: case Status.STATUS_ROLLING_BACK: try { tm.rollback(); } catch (Exception ex) { EjbLogger.ROOT_LOGGER.failedToRollback(ex); } EjbLogger.ROOT_LOGGER.transactionNotComplete(getComponent().getComponentName(), statusAsString(status)); } }
final ServerSecurityManager securityManager = ejbComponent.getSecurityManager(); final MethodInterfaceType methodIntfType = this.getMethodInterfaceType(componentView.getPrivateData(MethodIntf.class)); if (!securityManager.authorize(ejbComponent.getComponentName(), componentView.getProxyClass().getProtectionDomain().getCodeSource(), methodIntfType.name(), this.viewMethod, this.getMethodRolesAsPrincipals(), this.contextID)) { throw EjbLogger.ROOT_LOGGER.invocationOfMethodNotAllowed(invokedMethod,ejbComponent.getComponentName());
protected void executeReadAttribute(final String attributeName, final OperationContext context, final T component, final PathAddress address) { final boolean hasPool = componentType.hasPool(); if (COMPONENT_CLASS_NAME.getName().equals(attributeName)) { context.getResult().set(component.getComponentName()); } else if (SECURITY_DOMAIN.getName().equals(attributeName)) { final ModelNode result = context.getResult(); EJBSecurityMetaData md = component.getSecurityMetaData(); if (md != null && md.getSecurityDomain() != null) { result.set(md.getSecurityDomain()); EJBSecurityMetaData md = component.getSecurityMetaData(); if (md != null && md.getRunAs() != null) { result.set(md.getRunAs()); EJBSecurityMetaData md = component.getSecurityMetaData(); if (md != null) { result.setEmptyList();
public Class<?> getEjbObjectType() { if (ejbObjectViewServiceName == null) { return null; } final ServiceController<?> serviceController = currentServiceContainer().getRequiredService(ejbObjectViewServiceName); final ComponentView view = (ComponentView) serviceController.getValue(); return view.getViewClass(); }
public EJBHome getEJBHome() throws IllegalStateException { if (ejbHomeViewServiceName == null) { throw MESSAGES.beanHomeInterfaceIsNull(getComponentName()); } final ServiceController<?> serviceController = currentServiceContainer().getRequiredService(ejbHomeViewServiceName); final ComponentView view = (ComponentView) serviceController.getValue(); final String locatorAppName = earApplicationName == null ? "" : earApplicationName; return EJBClient.createProxy(new EJBHomeLocator<EJBHome>((Class<EJBHome>) view.getViewClass(), locatorAppName, moduleName, getComponentName(), distinctName)); }
@Override public Object processInvocation(InterceptorContext interceptorContext) throws Exception { try { // we just pass on the control and do our work only when an exception occurs return interceptorContext.proceed(); } catch (Throwable t) { final EJBComponent component = (EJBComponent) interceptorContext.getPrivateData(Component.class); final Method invokedMethod = interceptorContext.getMethod(); // check if it's an application exception. If yes, then *don't* log final ApplicationExceptionDetails appException = component.getApplicationException(t.getClass(), invokedMethod); if (appException == null) { EjbLogger.EJB3_INVOCATION_LOGGER.invocationFailed(component.getComponentName(), invokedMethod, t); } if (t instanceof Exception) { throw (Exception) t; } // Typically, this interceptor (which would be the first one in the chain) would catch Exception and not Throwable since the other EJB interceptors // down the chain would have already wrapped the Throwable accordingly. However, if for some reason, // the failure happened even before those interceptors could come into play, then we just wrap the throwable // here and return it as an exception throw new Exception(t); } } }
public Principal getCallerPrincipal() { AllowedMethodsInformation.checkAllowed(MethodType.GET_CALLER_PRINCIPLE); // per invocation return instance.getComponent().getCallerPrincipal(); }