use of com.sun.jersey.spi.container.servlet.ServletContainer in project nuxeo-filesystem-connectors by nuxeo.
the class WebDavServerFeature method setUpTomcat.
protected void setUpTomcat() throws Exception {
tomcat = new Tomcat();
// for tmp dir
tomcat.setBaseDir(".");
tomcat.setHostname(HOST);
tomcat.setPort(PORT);
ProtocolHandler p = tomcat.getConnector().getProtocolHandler();
AbstractEndpoint<?> endpoint = (AbstractEndpoint<?>) getFieldValue(p, "endpoint");
// vital for clean shutdown
endpoint.setMaxKeepAliveRequests(1);
File docBase = new File(".");
Context context = tomcat.addContext(CONTEXT, docBase.getAbsolutePath());
Application app = new org.nuxeo.ecm.webdav.Application();
ApplicationAdapter conf = new ApplicationAdapter(app);
conf.getFeatures().put(ResourceConfig.FEATURE_MATCH_MATRIX_PARAMS, Boolean.TRUE);
String servletName = "testServlet";
Servlet servlet = new ServletContainer(conf);
tomcat.addServlet(CONTEXT, servletName, servlet);
context.addServletMappingDecoded("/*", servletName);
addFilter(context, servletName, "RequestContextFilter", new RequestContextFilter());
addFilter(context, servletName, "SessionCleanupFilter", new SessionCleanupFilter());
addFilter(context, servletName, "NuxeoAuthenticationFilter", new NuxeoAuthenticationFilter());
addFilter(context, servletName, "WebEngineFilter", new WebEngineFilter());
tomcat.start();
}
use of com.sun.jersey.spi.container.servlet.ServletContainer in project SSM by Intel-bigdata.
the class SmartZeppelinServer method setupRestApiContextHandler.
private void setupRestApiContextHandler(WebAppContext webApp) throws Exception {
webApp.setSessionHandler(new SessionHandler());
// There are two sets of rest api: Zeppelin's and SSM's. They have different path.
ResourceConfig smartConfig = new ApplicationAdapter(new SmartRestApp());
ServletHolder smartServletHolder = new ServletHolder(new ServletContainer(smartConfig));
webApp.addServlet(smartServletHolder, SMART_PATH_SPEC);
ResourceConfig zeppelinConfig = new ApplicationAdapter(new ZeppelinRestApp());
ServletHolder zeppelinServletHolder = new ServletHolder(new ServletContainer(zeppelinConfig));
webApp.addServlet(zeppelinServletHolder, ZEPPELIN_PATH_SPEC);
String shiroIniPath = zconf.getShiroPath();
if (!StringUtils.isBlank(shiroIniPath)) {
webApp.setInitParameter("shiroConfigLocations", new File(shiroIniPath).toURI().toString());
SecurityUtils.initSecurityManager(shiroIniPath);
webApp.addFilter(ShiroFilter.class, ZEPPELIN_PATH_SPEC, EnumSet.allOf(DispatcherType.class));
// To make shiro configuration (authentication, etc.) take effect for smart rest api as well.
webApp.addFilter(ShiroFilter.class, SMART_PATH_SPEC, EnumSet.allOf(DispatcherType.class));
webApp.addEventListener(new EnvironmentLoaderListener());
}
}
use of com.sun.jersey.spi.container.servlet.ServletContainer in project zookeeper by apache.
the class RestMain method createJerseyAdapter.
private ServletAdapter createJerseyAdapter(Endpoint e) {
ServletAdapter jersey = new ServletAdapter();
jersey.setServletInstance(new ServletContainer());
jersey.addInitParameter("com.sun.jersey.config.property.packages", "org.apache.zookeeper.server.jersey.resources");
jersey.setContextPath(e.getContext());
Credentials c = Credentials.join(e.getCredentials(), cfg.getCredentials());
if (!c.isEmpty()) {
jersey.addFilter(new HTTPBasicAuth(c), e.getContext() + "-basic-auth", null);
}
return jersey;
}
use of com.sun.jersey.spi.container.servlet.ServletContainer in project hive by apache.
the class Main method runServer.
public Server runServer(int port) throws Exception {
// Authenticate using keytab
if (UserGroupInformation.isSecurityEnabled()) {
String serverPrincipal = SecurityUtil.getServerPrincipal(conf.kerberosPrincipal(), "0.0.0.0");
UserGroupInformation.loginUserFromKeytab(serverPrincipal, conf.kerberosKeytab());
}
// Create the Jetty server. If jetty conf file exists, use that to create server
// to have more control.
Server server = null;
if (StringUtils.isEmpty(conf.jettyConfiguration())) {
server = new Server(port);
} else {
FileInputStream jettyConf = new FileInputStream(conf.jettyConfiguration());
XmlConfiguration configuration = new XmlConfiguration(jettyConf);
server = (Server) configuration.configure();
}
ServletContextHandler root = new ServletContextHandler(server, "/");
// Add the Auth filter
FilterHolder fHolder = makeAuthFilter();
EnumSet<DispatcherType> dispatches = EnumSet.of(DispatcherType.REQUEST);
/*
* We add filters for each of the URIs supported by templeton.
* If we added the entire sub-structure using '/*', the mapreduce
* notification cannot give the callback to templeton in secure mode.
* This is because mapreduce does not use secure credentials for
* callbacks. So jetty would fail the request as unauthorized.
*/
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/ddl/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/pig/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/hive/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/sqoop/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/queue/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/jobs/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/mapreduce/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/status/*", dispatches);
root.addFilter(fHolder, "/" + SERVLET_PATH + "/v1/version/*", dispatches);
if (conf.getBoolean(AppConfig.XSRF_FILTER_ENABLED, false)) {
root.addFilter(makeXSRFFilter(), "/" + SERVLET_PATH + "/*", dispatches);
LOG.debug("XSRF filter enabled");
} else {
LOG.warn("XSRF filter disabled");
}
root.addFilter(makeFrameOptionFilter(), "/" + SERVLET_PATH + "/*", dispatches);
// Connect Jersey
ServletHolder h = new ServletHolder(new ServletContainer(makeJerseyConfig()));
root.addServlet(h, "/" + SERVLET_PATH + "/*");
// Add any redirects
addRedirects(server);
// Set handling for low resource conditions.
final LowResourceMonitor low = new LowResourceMonitor(server);
low.setLowResourcesIdleTimeout(10000);
server.addBean(low);
server.addConnector(createChannelConnector());
// Start the server
server.start();
this.server = server;
return server;
}
use of com.sun.jersey.spi.container.servlet.ServletContainer in project neo4j by neo4j.
the class JaxRsServletHolderFactory method create.
public ServletHolder create(Collection<InjectableProvider<?>> defaultInjectables, boolean wadlEnabled) {
Collection<InjectableProvider<?>> injectableProviders = mergeInjectables(defaultInjectables, injectables);
ServletContainer container = new NeoServletContainer(injectableProviders);
ServletHolder servletHolder = new ServletHolder(container);
servletHolder.setInitParameter(ResourceConfig.FEATURE_DISABLE_WADL, String.valueOf(!wadlEnabled));
configure(servletHolder, toCommaSeparatedList(items));
servletHolder.setInitParameter(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS, AllowAjaxFilter.class.getName());
servletHolder.setInitParameter(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS, getRequestFilterConfig());
return servletHolder;
}
Aggregations