Search in sources :

Example 11 with WebModule

use of com.sun.enterprise.web.WebModule in project Payara by payara.

the class WebContainerListener method containerEvent.

public void containerEvent(ContainerEvent event) {
    if (_logger.isLoggable(Level.FINEST)) {
        _logger.log(Level.FINEST, LogFacade.CONTAINER_EVENT, event.getType() + "," + event.getContainer() + "," + event.getData());
    }
    String type = event.getType();
    try {
        WebModule wm = (WebModule) event.getContainer();
        if (beforeEvents.contains(type)) {
            preInvoke(wm);
            if (type.equals(ContainerEvent.BEFORE_CONTEXT_DESTROYED)) {
                try {
                    // must close the validator factory
                    if (validationNamingProxy != null) {
                        Object validatorFactory = validationNamingProxy.handle("java:comp/ValidatorFactory");
                        if (validatorFactory != null) {
                            ((ValidatorFactory) validatorFactory).close();
                        }
                    }
                } catch (NamingException exc) {
                    if (_logger.isLoggable(Level.WARNING)) {
                        _logger.log(Level.FINEST, LogFacade.EXCEPTION_GETTING_VALIDATOR_FACTORY, exc);
                    }
                }
            }
        } else if (afterEvents.contains(type)) {
            if (type.equals(ContainerEvent.AFTER_FILTER_DESTROYED) || type.equals(ContainerEvent.AFTER_CONTEXT_DESTROYED)) {
                preDestroy(event);
            }
            postInvoke(wm);
        } else if (ContainerEvent.PRE_DESTROY.equals(type)) {
            preInvoke(wm);
            preDestroy(event);
            postInvoke(wm);
        }
    } catch (Throwable t) {
        String msg = rb.getString(LogFacade.EXCEPTION_DURING_HANDLE_EVENT);
        msg = MessageFormat.format(msg, new Object[] { type, event.getContainer() });
        _logger.log(Level.SEVERE, msg, t);
    }
}
Also used : ValidatorFactory(javax.validation.ValidatorFactory) NamingException(javax.naming.NamingException) String(java.lang.String) WebModule(com.sun.enterprise.web.WebModule)

Example 12 with WebModule

use of com.sun.enterprise.web.WebModule in project Payara by payara.

the class WebContainerListener method preInvoke.

private void preInvoke(WebModule ctx) {
    WebModule wm = (WebModule) ctx;
    ComponentInvocation inv = new WebComponentInvocation(wm);
    invocationMgr.preInvoke(inv);
}
Also used : WebComponentInvocation(com.sun.enterprise.web.WebComponentInvocation) WebComponentInvocation(com.sun.enterprise.web.WebComponentInvocation) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) WebModule(com.sun.enterprise.web.WebModule)

Example 13 with WebModule

use of com.sun.enterprise.web.WebModule in project Payara by payara.

the class WSTCPAdapterRegistryImpl method createWSAdapter.

private TCPAdapter createWSAdapter(@NotNull final String wsPath, @NotNull final WSEndpointDescriptor wsEndpointDescriptor) throws Exception {
    if (wsEndpointDescriptor.isEJB()) {
        final EjbRuntimeEndpointInfo ejbEndPtInfo = (EjbRuntimeEndpointInfo) V3Module.getWSEjbEndpointRegistry().getEjbWebServiceEndpoint(wsEndpointDescriptor.getURI(), "POST", null);
        final AdapterInvocationInfo adapterInfo = (AdapterInvocationInfo) ejbEndPtInfo.prepareInvocation(true);
        return new Ejb109Adapter(wsEndpointDescriptor.getWSServiceName().toString(), wsPath, adapterInfo.getAdapter().getEndpoint(), new ServletFakeArtifactSet(wsEndpointDescriptor.getRequestURL(), wsEndpointDescriptor.getUrlPattern()), ejbEndPtInfo, adapterInfo);
    } else {
        final String uri = wsEndpointDescriptor.getURI();
        final Adapter adapter = JAXWSAdapterRegistry.getInstance().getAdapter(wsEndpointDescriptor.getContextRoot(), uri, uri);
        final WebModule webModule = AppServRegistry.getWebModule(wsEndpointDescriptor.getWSServiceEndpoint());
        final ComponentInvocation invocation = new WebComponentInvocation(webModule);
        return new Web109Adapter(wsEndpointDescriptor.getWSServiceName().toString(), wsPath, adapter.getEndpoint(), new ServletFakeArtifactSet(wsEndpointDescriptor.getRequestURL(), wsEndpointDescriptor.getUrlPattern()), invocation);
    }
}
Also used : WebComponentInvocation(com.sun.enterprise.web.WebComponentInvocation) EjbRuntimeEndpointInfo(org.glassfish.webservices.EjbRuntimeEndpointInfo) WebComponentInvocation(com.sun.enterprise.web.WebComponentInvocation) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) AdapterInvocationInfo(org.glassfish.webservices.AdapterInvocationInfo) TCPAdapter(com.sun.xml.ws.transport.tcp.server.TCPAdapter) Adapter(com.sun.xml.ws.api.server.Adapter) WebModule(com.sun.enterprise.web.WebModule)

Example 14 with WebModule

use of com.sun.enterprise.web.WebModule in project Payara by payara.

the class WebServiceContextImpl method isUserInRole.

public boolean isUserInRole(String role) {
    WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
    ComponentInvocation.ComponentInvocationType EJBInvocationType = ComponentInvocation.ComponentInvocationType.EJB_INVOCATION;
    InvocationManager mgr = wscImpl.getInvocationManager();
    if ((mgr != null) && (EJBInvocationType.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.getCurrentInvocation().getContainer() instanceof WebModule) {
            Principal p = getUserPrincipal();
            ret = secServ.isUserInRole((WebModule) mgr.getCurrentInvocation().getContainer(), p, servletName, role);
        }
    }
    return ret;
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationManager(org.glassfish.api.invocation.InvocationManager) EJBInvocation(org.glassfish.ejb.api.EJBInvocation) WebModule(com.sun.enterprise.web.WebModule) Principal(java.security.Principal)

Aggregations

WebModule (com.sun.enterprise.web.WebModule)14 ComponentInvocation (org.glassfish.api.invocation.ComponentInvocation)7 WebComponentInvocation (com.sun.enterprise.web.WebComponentInvocation)5 String (java.lang.String)5 AppServSecurityContext (com.sun.enterprise.security.integration.AppServSecurityContext)3 ServerContext (org.glassfish.internal.api.ServerContext)3 InjectionException (com.sun.enterprise.container.common.spi.util.InjectionException)2 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)2 ServletRequestWrapper (javax.servlet.ServletRequestWrapper)2 InvocationManager (org.glassfish.api.invocation.InvocationManager)2 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)2 ApplicationRegistry (org.glassfish.internal.data.ApplicationRegistry)2 ServletContainer (org.glassfish.jersey.servlet.ServletContainer)2 RealmInitializer (com.sun.enterprise.security.integration.RealmInitializer)1 WebApplication (com.sun.enterprise.web.WebApplication)1 WebContainer (com.sun.enterprise.web.WebContainer)1 Adapter (com.sun.xml.ws.api.server.Adapter)1 TCPAdapter (com.sun.xml.ws.transport.tcp.server.TCPAdapter)1 RestEndpointModel (fish.payara.appserver.rest.endpoints.RestEndpointModel)1 URI (java.net.URI)1