Search in sources :

Example 1 with RestSamlApplicationConfig

use of org.keycloak.testsuite.arquillian.jetty.saml.util.RestSamlApplicationConfig in project keycloak by keycloak.

the class JettyAppServer method addRestEasyServlet.

private void addRestEasyServlet(WebArchive archive, WebAppContext webAppContext) {
    log.debug("Starting Resteasy deployment");
    boolean addServlet = true;
    ServletHolder resteasyServlet = new ServletHolder("javax.ws.rs.core.Application", new HttpServlet30Dispatcher());
    String jaxrsApplication = getJaxRsApplication(archive);
    Set<Class<?>> pathAnnotatedClasses = getPathAnnotatedClasses(archive);
    if (jaxrsApplication != null) {
        log.debug("App has an Application.class: " + jaxrsApplication);
        resteasyServlet.setInitParameter("javax.ws.rs.Application", jaxrsApplication);
    } else if (!pathAnnotatedClasses.isEmpty()) {
        log.debug("App has @Path annotated classes: " + pathAnnotatedClasses);
        ResteasyDeployment deployment = new ResteasyDeployment();
        deployment.setApplication(new RestSamlApplicationConfig(pathAnnotatedClasses));
        webAppContext.setAttribute(ResteasyDeployment.class.getName(), deployment);
    } else {
        log.debug("An application doesn't have Application.class, nor @Path annotated classes. Skipping Resteasy initialization.");
        addServlet = false;
    }
    if (addServlet) {
        // this should be /* in general. However Jetty 9.2 (this is bug specific to this version),
        // can not merge two instances of javax.ws.rs.Application together (one from web.xml
        // and the other one added here). In 9.1 and 9.4 this works fine.
        // Once we stop supporting 9.2, this should replaced with /* and this comment should be removed.
        webAppContext.addServlet(resteasyServlet, "/");
    }
    log.debug("Finished Resteasy deployment");
}
Also used : ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) HttpServlet30Dispatcher(org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher) RestSamlApplicationConfig(org.keycloak.testsuite.arquillian.jetty.saml.util.RestSamlApplicationConfig)

Aggregations

ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1 HttpServlet30Dispatcher (org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher)1 ResteasyDeployment (org.jboss.resteasy.spi.ResteasyDeployment)1 RestSamlApplicationConfig (org.keycloak.testsuite.arquillian.jetty.saml.util.RestSamlApplicationConfig)1