use of org.jboss.resteasy.spi.ResteasyDeployment in project indy by Commonjava.
the class SwaggerGeneratorDeployment method getDeploymentInfo.
public DeploymentInfo getDeploymentInfo(final String contextRoot, Application application) {
// we have to disable the UI for this to work.
uiConfiguration.setEnabled(false);
final ResteasyDeployment deployment = new ResteasyDeployment();
deployment.setApplication(application);
deployment.setInjectorFactoryClass(CdiInjectorFactoryImpl.class.getName());
final ServletInfo resteasyServlet = Servlets.servlet("Swagger Generator Servlet", HttpServlet30Dispatcher.class).setAsyncSupported(true).setLoadOnStartup(2).addMapping("/swagger.json").addMapping("/swagger.yaml");
final BeanConfig beanConfig = new BeanConfig();
beanConfig.setResourcePackage("org.commonjava.indy");
beanConfig.setBasePath("/");
beanConfig.setLicense("ASLv2");
beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0");
beanConfig.setScan(true);
beanConfig.setVersion(versioning.getApiVersion());
final DeploymentInfo di = new DeploymentInfo().addListener(Servlets.listener(RequestScopeListener.class)).setContextPath(contextRoot).addServletContextAttribute(ResteasyDeployment.class.getName(), deployment).addServlet(resteasyServlet).setDeploymentName("Swagger Generator Deployment").setClassLoader(ClassLoader.getSystemClassLoader());
logger.info("\n\n\n\nReturning DeploymentInfo for Swagger generator\n\n\n\n");
return di;
}
use of org.jboss.resteasy.spi.ResteasyDeployment in project openremote by openremote.
the class AbstractHTTPServerProtocol method createDeployment.
protected ResteasyDeployment createDeployment(Application application) {
ResteasyDeployment resteasyDeployment = new ResteasyDeployment();
resteasyDeployment.setApplication(application);
List<String> allowedOrigins;
if (devMode) {
allowedOrigins = Collections.singletonList("*");
} else {
allowedOrigins = agent.getAllowedOrigins().map(Arrays::asList).orElse(null);
}
if (allowedOrigins != null) {
String allowedMethods = Arrays.stream(agent.getAllowedHTTPMethods().orElse(DEFAULT_ALLOWED_METHODS)).map(Enum::name).collect(Collectors.joining(","));
CorsFilter corsFilter = new CorsFilter();
corsFilter.getAllowedOrigins().addAll(allowedOrigins);
corsFilter.setAllowedMethods(allowedMethods);
resteasyDeployment.getProviders().add(corsFilter);
}
return resteasyDeployment;
}
use of org.jboss.resteasy.spi.ResteasyDeployment in project openremote by openremote.
the class AbstractHTTPServerProtocol method createDeploymentInfo.
protected DeploymentInfo createDeploymentInfo(ResteasyDeployment resteasyDeployment) {
String deploymentPath = getDeploymentPath();
String deploymentName = getDeploymentName();
boolean enableSecurity = agent.isRoleBasedSecurity().orElse(false);
if (enableSecurity) {
if (identityService == null) {
throw new RuntimeException("Role based security can only be enabled when an identity service is available");
}
}
resteasyDeployment.setSecurityEnabled(enableSecurity);
ServletInfo resteasyServlet = Servlets.servlet("ResteasyServlet", HttpServlet30Dispatcher.class).setAsyncSupported(true).setLoadOnStartup(1).addMapping("/*");
DeploymentInfo deploymentInfo = new DeploymentInfo().setDeploymentName(deploymentName).setContextPath(deploymentPath).addServletContextAttribute(ResteasyDeployment.class.getName(), resteasyDeployment).addServlet(resteasyServlet).setClassLoader(Container.class.getClassLoader());
if (enableSecurity) {
identityService.secureDeployment(deploymentInfo);
}
return deploymentInfo;
}
use of org.jboss.resteasy.spi.ResteasyDeployment in project openremote by openremote.
the class WebService method createResteasyDeployment.
protected ResteasyDeployment createResteasyDeployment(Container container, Collection<Class<?>> apiClasses, Collection<Object> apiSingletons, boolean secure) {
if (apiClasses == null && apiSingletons == null)
return null;
WebApplication webApplication = new WebApplication(container, apiClasses, apiSingletons);
ResteasyDeployment resteasyDeployment = new ResteasyDeployment();
resteasyDeployment.setApplication(webApplication);
// Custom providers (these only apply to server applications, not client calls)
resteasyDeployment.getProviders().add(new WebServiceExceptions.DefaultResteasyExceptionMapper(devMode));
resteasyDeployment.getProviders().add(new WebServiceExceptions.ForbiddenResteasyExceptionMapper(devMode));
resteasyDeployment.getProviders().add(new JacksonConfig());
resteasyDeployment.getProviders().add(new GZIPEncodingInterceptor(!container.isDevMode()));
resteasyDeployment.getActualProviderClasses().add(AlreadyGzippedWriterInterceptor.class);
resteasyDeployment.getActualProviderClasses().add(ClientErrorExceptionHandler.class);
resteasyDeployment.setSecurityEnabled(secure);
return resteasyDeployment;
}
use of org.jboss.resteasy.spi.ResteasyDeployment in project openremote by openremote.
the class WebService method createApiHandler.
protected HttpHandler createApiHandler(IdentityService identityService, ResteasyDeployment resteasyDeployment) {
if (resteasyDeployment == null)
return null;
ServletInfo restServlet = Servlets.servlet("RESTEasy Servlet", HttpServlet30Dispatcher.class).setAsyncSupported(true).setLoadOnStartup(1).addMapping("/*");
DeploymentInfo deploymentInfo = new DeploymentInfo().setDeploymentName("RESTEasy Deployment").setContextPath(API_PATH).addServletContextAttribute(ResteasyDeployment.class.getName(), resteasyDeployment).addServlet(restServlet).setClassLoader(Container.class.getClassLoader());
if (identityService != null) {
resteasyDeployment.setSecurityEnabled(true);
} else {
throw new RuntimeException("No identity service deployed, can't enable API security");
}
return addServletDeployment(identityService, deploymentInfo, resteasyDeployment.isSecurityEnabled());
}
Aggregations