org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters Java Examples
The following examples show how to use
org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmbeddedKeycloakConfig.java From spring-security-oauth with MIT License | 6 votes |
@Bean ServletRegistrationBean<HttpServlet30Dispatcher> keycloakJaxRsApplication( KeycloakServerProperties keycloakServerProperties, DataSource dataSource) throws Exception { mockJndiEnvironment(dataSource); EmbeddedKeycloakApplication.keycloakServerProperties = keycloakServerProperties; ServletRegistrationBean<HttpServlet30Dispatcher> servlet = new ServletRegistrationBean<>( new HttpServlet30Dispatcher()); servlet.addInitParameter("javax.ws.rs.Application", EmbeddedKeycloakApplication.class.getName()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, keycloakServerProperties.getContextPath()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_USE_CONTAINER_FORM_PARAMS, "true"); servlet.addUrlMappings(keycloakServerProperties.getContextPath() + "/*"); servlet.setLoadOnStartup(1); servlet.setAsyncSupported(true); return servlet; }
Example #2
Source File: EmbeddedKeycloakConfig.java From spring-security-oauth with MIT License | 6 votes |
@Bean ServletRegistrationBean<HttpServlet30Dispatcher> keycloakJaxRsApplication(KeycloakServerProperties keycloakServerProperties, DataSource dataSource) throws Exception { mockJndiEnvironment(dataSource); EmbeddedKeycloakApplication.keycloakServerProperties = keycloakServerProperties; ServletRegistrationBean<HttpServlet30Dispatcher> servlet = new ServletRegistrationBean<>(new HttpServlet30Dispatcher()); servlet.addInitParameter("javax.ws.rs.Application", EmbeddedKeycloakApplication.class.getName()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, keycloakServerProperties.getContextPath()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_USE_CONTAINER_FORM_PARAMS, "true"); servlet.addUrlMappings(keycloakServerProperties.getContextPath() + "/*"); servlet.setLoadOnStartup(1); servlet.setAsyncSupported(true); return servlet; }
Example #3
Source File: EmbeddedKeycloakConfig.java From spring-security-oauth with MIT License | 6 votes |
@Bean ServletRegistrationBean<HttpServlet30Dispatcher> keycloakJaxRsApplication( KeycloakServerProperties keycloakServerProperties, DataSource dataSource) throws Exception { mockJndiEnvironment(dataSource); EmbeddedKeycloakApplication.keycloakServerProperties = keycloakServerProperties; ServletRegistrationBean<HttpServlet30Dispatcher> servlet = new ServletRegistrationBean<>( new HttpServlet30Dispatcher()); servlet.addInitParameter("javax.ws.rs.Application", EmbeddedKeycloakApplication.class.getName()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, keycloakServerProperties.getContextPath()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_USE_CONTAINER_FORM_PARAMS, "true"); servlet.addUrlMappings(keycloakServerProperties.getContextPath() + "/*"); servlet.setLoadOnStartup(1); servlet.setAsyncSupported(true); return servlet; }
Example #4
Source File: EmbeddedKeycloakConfig.java From spring-boot-keycloak-server-example with Apache License 2.0 | 6 votes |
@Bean ServletRegistrationBean<HttpServlet30Dispatcher> keycloakJaxRsApplication(SpringBootConfigProvider configProvider) { //FIXME: hack to propagate Spring Boot Properties to Keycloak Application EmbeddedKeycloakApplication.keycloakProperties = keycloakProperties; //FIXME: hack to propagate Spring Boot Properties to Keycloak Application EmbeddedKeycloakApplication.customProperties = customProperties; //FIXME: hack to propagate Spring Boot ConfigProvider to Keycloak Application EmbeddedKeycloakApplication.configProvider = configProvider; ServletRegistrationBean<HttpServlet30Dispatcher> servlet = new ServletRegistrationBean<>(new HttpServlet30Dispatcher()); servlet.addInitParameter("javax.ws.rs.Application", EmbeddedKeycloakApplication.class.getName()); String keycloakContextPath = customProperties.getServer().getContextPath(); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, keycloakContextPath); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_USE_CONTAINER_FORM_PARAMS, "true"); servlet.addUrlMappings(keycloakContextPath + "/*"); servlet.setLoadOnStartup(1); servlet.setAsyncSupported(true); return servlet; }
Example #5
Source File: Demo.java From resteasy-examples with Apache License 2.0 | 6 votes |
public static UndertowJaxrsServer buildServer() { UndertowJaxrsServer server; System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager"); try { LogManager.getLogManager().readConfiguration(Main.class.getClassLoader().getResourceAsStream("logging.jboss.properties")); } catch (IOException e) { e.printStackTrace(); } server = new UndertowJaxrsServer().start(); ResteasyDeployment deployment = new ResteasyDeploymentImpl(); deployment.setApplicationClass(TracingApp.class.getName()); DeploymentInfo di = server.undertowDeployment(deployment); di.setClassLoader(TracingApp.class.getClassLoader()); di.setContextPath(""); di.setDeploymentName("Resteasy"); di.getServlets().get("ResteasyServlet").addInitParam(ResteasyContextParameters.RESTEASY_TRACING_TYPE, ResteasyContextParameters.RESTEASY_TRACING_TYPE_ALL) .addInitParam(ResteasyContextParameters.RESTEASY_TRACING_THRESHOLD, ResteasyContextParameters.RESTEASY_TRACING_LEVEL_VERBOSE); server.deploy(di); return server; }
Example #6
Source File: SpringWebProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@BuildStep public void process(BeanArchiveIndexBuildItem beanArchiveIndexBuildItem, BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<ServletInitParamBuildItem> initParamProducer, BuildProducer<ResteasyDeploymentCustomizerBuildItem> deploymentCustomizerProducer) { validateControllers(beanArchiveIndexBuildItem); final IndexView index = beanArchiveIndexBuildItem.getIndex(); final Collection<AnnotationInstance> annotations = index.getAnnotations(REST_CONTROLLER_ANNOTATION); if (annotations.isEmpty()) { return; } final Set<String> classNames = new HashSet<>(); for (AnnotationInstance annotation : annotations) { classNames.add(annotation.target().asClass().toString()); } // initialize the init params that will be used in case of servlet initParamProducer.produce( new ServletInitParamBuildItem( ResteasyContextParameters.RESTEASY_SCANNED_RESOURCE_CLASSES_WITH_BUILDER, SpringResourceBuilder.class.getName() + ":" + String.join(",", classNames))); // customize the deployment that will be used in case of RESTEasy standalone deploymentCustomizerProducer.produce(new ResteasyDeploymentCustomizerBuildItem(new Consumer<ResteasyDeployment>() { @Override public void accept(ResteasyDeployment resteasyDeployment) { resteasyDeployment.getScannedResourceClassesWithBuilder().put(SpringResourceBuilder.class.getName(), new ArrayList<>(classNames)); } })); reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, false, SpringResourceBuilder.class.getName())); }
Example #7
Source File: ResteasyServerCommonProcessor.java From quarkus with Apache License 2.0 | 5 votes |
private static void registerProviders(ResteasyDeployment deployment, Map<String, String> resteasyInitParameters, BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<UnremovableBeanBuildItem> unremovableBeans, JaxrsProvidersToRegisterBuildItem jaxrsProvidersToRegisterBuildItem) { if (jaxrsProvidersToRegisterBuildItem.useBuiltIn()) { // if we find a wildcard media type, we just use the built-in providers resteasyInitParameters.put(ResteasyContextParameters.RESTEASY_USE_BUILTIN_PROVIDERS, "true"); deployment.setRegisterBuiltin(true); if (!jaxrsProvidersToRegisterBuildItem.getContributedProviders().isEmpty()) { deployment.getProviderClasses().addAll(jaxrsProvidersToRegisterBuildItem.getContributedProviders()); resteasyInitParameters.put(ResteasyContextParameters.RESTEASY_PROVIDERS, String.join(",", jaxrsProvidersToRegisterBuildItem.getContributedProviders())); } } else { deployment.setRegisterBuiltin(false); deployment.getProviderClasses().addAll(jaxrsProvidersToRegisterBuildItem.getProviders()); resteasyInitParameters.put(ResteasyContextParameters.RESTEASY_USE_BUILTIN_PROVIDERS, "false"); resteasyInitParameters.put(ResteasyContextParameters.RESTEASY_PROVIDERS, String.join(",", jaxrsProvidersToRegisterBuildItem.getProviders())); } // register the providers for reflection for (String providerToRegister : jaxrsProvidersToRegisterBuildItem.getProviders()) { reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, providerToRegister)); } // special case: our config providers reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, ServletConfigSource.class, ServletContextConfigSource.class, FilterConfigSource.class)); // Providers that are also beans are unremovable unremovableBeans.produce(new UnremovableBeanBuildItem( b -> jaxrsProvidersToRegisterBuildItem.getProviders().contains(b.getBeanClass().toString()))); }
Example #8
Source File: BasicQueryTest.java From resteasy-examples with Apache License 2.0 | 5 votes |
@Test public void basicTest() { Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://localhost:8081/type"); assertEquals(ResteasyContextParameters.RESTEASY_TRACING_TYPE_ALL, target.request().get(String.class)); target = client.target("http://localhost:8081/level"); assertEquals(ResteasyContextParameters.RESTEASY_TRACING_LEVEL_VERBOSE, target.request().get(String.class)); target = client.target("http://localhost:8081/logger"); assertEquals(RESTEasyTracingLogger.class.getName(), target.request().get(String.class)); client.close(); }
Example #9
Source File: KeycloakOnUndertow.java From keycloak with Apache License 2.0 | 5 votes |
private DeploymentInfo createAuthServerDeploymentInfo() { ResteasyDeployment deployment = new ResteasyDeployment(); deployment.setApplicationClass(KeycloakApplication.class.getName()); // RESTEASY-2034 deployment.setProperty(ResteasyContextParameters.RESTEASY_DISABLE_HTML_SANITIZER, true); DeploymentInfo di = undertow.undertowDeployment(deployment); di.setClassLoader(getClass().getClassLoader()); di.setContextPath("/auth"); di.setDeploymentName("Keycloak"); if (configuration.getKeycloakConfigPropertyOverridesMap() != null) { try { di.addInitParameter(JsonConfigProviderFactory.SERVER_CONTEXT_CONFIG_PROPERTY_OVERRIDES, JsonSerialization.writeValueAsString(configuration.getKeycloakConfigPropertyOverridesMap())); } catch (IOException ex) { throw new RuntimeException(ex); } } di.setDefaultServletConfig(new DefaultServletConfig(true)); di.addWelcomePage("theme/keycloak/welcome/resources/index.html"); FilterInfo filter = Servlets.filter("SessionFilter", TestKeycloakSessionServletFilter.class); di.addFilter(filter); di.addFilterUrlMapping("SessionFilter", "/*", DispatcherType.REQUEST); filter.setAsyncSupported(true); return di; }
Example #10
Source File: QuarkusFilter.java From keycloak with Apache License 2.0 | 4 votes |
public QuarkusFilter() { //TODO: a temporary hack for https://github.com/quarkusio/quarkus/issues/9647, we need to disable the sanitizer to avoid // escaping text/html responses from the server Resteasy.getContextData(ResteasyDeployment.class).setProperty(ResteasyContextParameters.RESTEASY_DISABLE_HTML_SANITIZER, Boolean.TRUE); }