Search in sources :

Example 66 with Application

use of com.sun.enterprise.deployment.Application in project Payara by payara.

the class EjbWebServiceServlet method dispatchToEjbEndpoint.

private void dispatchToEjbEndpoint(HttpServletRequest hreq, HttpServletResponse hresp, EjbRuntimeEndpointInfo ejbEndpoint) {
    EjbEndpointFacade container = ejbEndpoint.getContainer();
    ClassLoader savedClassLoader = null;
    boolean authenticated = false;
    try {
        // Set context class loader to application class loader
        savedClassLoader = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(container.getEndpointClassLoader());
        // compute realmName
        String realmName = null;
        Application app = ejbEndpoint.getEndpoint().getBundleDescriptor().getApplication();
        if (app != null) {
            realmName = app.getRealm();
        }
        if (realmName == null) {
            realmName = ejbEndpoint.getEndpoint().getRealm();
        }
        if (realmName == null) {
            // use the same logic as BasicAuthenticator
            realmName = hreq.getServerName() + ":" + hreq.getServerPort();
        }
        try {
            if (secServ != null) {
                WebServiceContextImpl context = (WebServiceContextImpl) ejbEndpoint.getWebServiceContext();
                authenticated = secServ.doSecurity(hreq, ejbEndpoint, realmName, context);
            }
        } catch (Exception e) {
            // sendAuthenticationEvents(false, hreq.getRequestURI(), null);
            LogHelper.log(logger, Level.WARNING, LogUtils.AUTH_FAILED, e, ejbEndpoint.getEndpoint().getEndpointName());
        }
        if (!authenticated) {
            hresp.setHeader("WWW-Authenticate", "Basic realm=\"" + realmName + "\"");
            hresp.sendError(HttpServletResponse.SC_UNAUTHORIZED);
            return;
        }
        // depending on the jaxrpc or jax-ws version, this will return the
        // right dispatcher.
        EjbMessageDispatcher msgDispatcher = ejbEndpoint.getMessageDispatcher();
        msgDispatcher.invoke(hreq, hresp, getServletContext(), ejbEndpoint);
    } catch (Throwable t) {
        logger.log(Level.WARNING, LogUtils.EXCEPTION_THROWN, t);
    } finally {
        // remove any security context from the thread local before returning
        if (secServ != null) {
            secServ.resetSecurityContext();
            secServ.resetPolicyContext();
        }
        // Restore context class loader
        Thread.currentThread().setContextClassLoader(savedClassLoader);
    }
}
Also used : EjbEndpointFacade(org.glassfish.ejb.api.EjbEndpointFacade) Application(com.sun.enterprise.deployment.Application) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Aggregations

Application (com.sun.enterprise.deployment.Application)66 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)17 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)10 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)10 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)10 IOException (java.io.IOException)9 File (java.io.File)8 ModuleDescriptor (org.glassfish.deployment.common.ModuleDescriptor)8 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)7 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)7 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)5 DeploymentException (org.glassfish.deployment.common.DeploymentException)5 SAXParseException (org.xml.sax.SAXParseException)5 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)4 ArrayList (java.util.ArrayList)4 WebappClassLoader (org.glassfish.web.loader.WebappClassLoader)4 OpsParams (org.glassfish.api.deployment.OpsParams)3 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)3 Applications (com.sun.enterprise.config.serverbeans.Applications)2 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)2