public void beforePreInvoke(ComponentInvocationType invType, ComponentInvocation prevInv, ComponentInvocation newInv) throws InvocationException { if (invType == ComponentInvocationType.SERVLET_INVOCATION) { Object cont = newInv.getContainer(); if (cont instanceof ContainerBase) { Realm realm = ((ContainerBase) cont).getRealm(); if (realm instanceof RealmAdapter) { ((RealmAdapter) realm).preSetRunAsIdentity(newInv); } } } }
public void afterPostInvoke(ComponentInvocationType invType, ComponentInvocation prevInv, ComponentInvocation curInv) throws InvocationException { if (invType == ComponentInvocationType.SERVLET_INVOCATION) { Object cont = curInv.getContainer(); if (cont instanceof ContainerBase) { Realm realm = ((ContainerBase) cont).getRealm(); if (realm instanceof RealmAdapter) { ((RealmAdapter) realm).postSetRunAsIdentity(curInv); } } } } };
public Collection<URI> getResources(ServletContext context) { ServiceLocator defaultServices = (ServiceLocator)context.getAttribute( HABITAT_ATTRIBUTE); invokeMgr = defaultServices.getService(InvocationManager.class); ComponentInvocation inv = invokeMgr.getCurrentInvocation(); WebModule webModule = (WebModule)inv.getContainer(); WebBundleDescriptor wdesc = webModule.getWebBundleDescriptor(); List<URI> list = new ArrayList<URI>(1); if (!wdesc.hasExtensionProperty(WeldDeployer.WELD_EXTENSION)) { return list; } // Don't use Util.getCurrentLoader(). This config resource should // be available from the same classloader that loaded this instance. // Doing so allows us to be more OSGi friendly. ClassLoader loader = this.getClass().getClassLoader(); URL resource = loader.getResource(SERVICES_FACES_CONFIG); if (resource != null) { try { list.add(resource.toURI()); } catch (URISyntaxException ex) { if (logger.isLoggable(Level.SEVERE)) { logger.log(Level.SEVERE, CDILoggerInfo.SEVERE_ERROR_CREATING_URI_FOR_FACES_CONFIG_XML, new Object [] {resource.toExternalForm(), ex}); } } } return list; }
public EntityManager lookupExtendedEntityManager(EntityManagerFactory emf) { EntityManager em = null; ComponentInvocation inv = invMgr.getCurrentInvocation(); if( (inv != null) && (inv.getInvocationType() == ComponentInvocation.ComponentInvocationType.EJB_INVOCATION )) { Object obj = inv.getContainer(); if (obj instanceof JavaEEContainer) { em = ((JavaEEContainer) obj).lookupExtendedEntityManager(emf); } } return em; }
ComponentInvocation ci = invMgr.getCurrentInvocation(); if (ci != null) { Object cc = ci.getContainer(); if (cc instanceof JavaEEContainer) { extendedEntityManager = ((JavaEEContainer) cc).lookupExtendedEntityManager(
ComponentInvocation ci = invMgr.getCurrentInvocation(); if (ci != null) { Object cc = ci.getContainer(); if (cc instanceof JavaEEContainer) { extendedEntityManager = ((JavaEEContainer) cc).lookupExtendedEntityManager(
public boolean isUserInRole(String role) { WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance(); InvocationManager mgr = wscImpl.getInvocationManager(); if (ComponentInvocation.ComponentInvocationType.EJB_INVOCATION.equals(mgr.getCurrentInvocation().getInvocationType())) { EJBInvocation inv = (EJBInvocation)mgr.getCurrentInvocation(); boolean res = inv.isCallerInRole(role); return res; } // This is a servlet endpoint boolean ret = this.jaxwsContextDelegate.isUserInRole(role); //handling for webservice with WS-Security if (!ret && secServ != null) { if (mgr != null && mgr.getCurrentInvocation() != null) { if (mgr.getCurrentInvocation().getContainer() instanceof WebModule) { Principal p = getUserPrincipal(); ret = secServ.isUserInRole((WebModule)mgr.getCurrentInvocation().getContainer(), p, servletName, role); } } } return ret; }