本文整理汇总了Java中org.eclipse.jetty.servlet.FilterHolder.setName方法的典型用法代码示例。如果您正苦于以下问题:Java FilterHolder.setName方法的具体用法?Java FilterHolder.setName怎么用?Java FilterHolder.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.servlet.FilterHolder
的用法示例。
在下文中一共展示了FilterHolder.setName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loginServerPrincipal
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
private static Pair<FilterHolder, Class<? extends ServletContainer>> loginServerPrincipal(
UserProvider userProvider, Configuration conf) throws Exception {
Class<? extends ServletContainer> containerClass = ServletContainer.class;
if (userProvider.isHadoopSecurityEnabled() && userProvider.isHBaseSecurityEnabled()) {
String machineName = Strings.domainNamePointerToHostName(
DNS.getDefaultHost(conf.get(REST_DNS_INTERFACE, "default"),
conf.get(REST_DNS_NAMESERVER, "default")));
String keytabFilename = conf.get(REST_KEYTAB_FILE);
Preconditions.checkArgument(keytabFilename != null && !keytabFilename.isEmpty(),
REST_KEYTAB_FILE + " should be set if security is enabled");
String principalConfig = conf.get(REST_KERBEROS_PRINCIPAL);
Preconditions.checkArgument(principalConfig != null && !principalConfig.isEmpty(),
REST_KERBEROS_PRINCIPAL + " should be set if security is enabled");
userProvider.login(REST_KEYTAB_FILE, REST_KERBEROS_PRINCIPAL, machineName);
if (conf.get(REST_AUTHENTICATION_TYPE) != null) {
containerClass = RESTServletContainer.class;
FilterHolder authFilter = new FilterHolder();
authFilter.setClassName(AuthFilter.class.getName());
authFilter.setName("AuthenticationFilter");
return new Pair<>(authFilter,containerClass);
}
}
return new Pair<>(null, containerClass);
}
示例2: defineFilter
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
/**
* Define a filter for a context and set up default url mappings.
*/
public static void defineFilter(ServletContextHandler handler, String name,
String classname, Map<String,String> parameters, String[] urls) {
FilterHolder holder = new FilterHolder();
holder.setName(name);
holder.setClassName(classname);
if (parameters != null) {
holder.setInitParameters(parameters);
}
FilterMapping fmap = new FilterMapping();
fmap.setPathSpecs(urls);
fmap.setDispatches(FilterMapping.ALL);
fmap.setFilterName(name);
handler.getServletHandler().addFilter(holder, fmap);
}
示例3: createAndAddJettyFilter
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
public Optional<FilterHolder> createAndAddJettyFilter(ServletContextHandler handler, MappedFilter mappedFilter) {
Objects.requireNonNull(mappedFilter.getFilter());
Set<String> urlPatterns = getUrlPatterns(mappedFilter.getUrlPatterns());
if (urlPatterns.isEmpty()) {
// TODO: old Java anti-pattern is to use filters for the sake
// of their "init" method, so perhaps we do need to add unmapped
// filter after all?
LOGGER.info("Skipping unmapped filter {}", mappedFilter.getFilter().getClass().getName());
return Optional.empty();
}
FilterHolder holder = new FilterHolder(mappedFilter.getFilter());
if (mappedFilter.getName() != null) {
holder.setName(mappedFilter.getName());
}
Map<String, String> params = getParams(mappedFilter.getParams());
if (params != null) {
params.forEach((k, v) -> holder.setInitParameter(k, v));
}
EnumSet<DispatcherType> dispatches = EnumSet.of(DispatcherType.REQUEST);
urlPatterns.forEach(urlPattern -> {
if (LOGGER.isInfoEnabled()) {
String name = mappedFilter.getName() != null ? mappedFilter.getName() : "?";
LOGGER.info("Adding filter '{}' mapped to {}", name, urlPattern);
}
handler.addFilter(holder, urlPattern, dispatches);
});
return Optional.of(holder);
}
示例4: main
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(8080);
final ErrorHandler errorHandler = new ErrorHandler();
errorHandler.setServer(server);
errorHandler.setShowStacks(false);
server.addBean(errorHandler);
server.setStopAtShutdown(true);
server.setStopTimeout(30*1000l);
ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS);
handler.setClassLoader(Thread.currentThread().getContextClassLoader());
handler.setContextPath("/");
handler.setInitParameter("tapestry.app-package", "com.ckfce.tapfatjar");
FilterHolder filterHolder = new FilterHolder();
filterHolder.setHeldClass(TapestryFilter.class);
filterHolder.setName("app");
handler.addFilter(filterHolder, "/*", EnumSet.of(DispatcherType.REQUEST));
server.setHandler(handler);
server.start();
server.join();
}
示例5: run
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
@Override
public void run(HelloBrotliConfiguration configuration, Environment environment) {
final FilterHolder brotliFilterHolder = new FilterHolder(checkNotNull(new BrotliServletFilter()));
brotliFilterHolder.setName("BrotliCompressionFilter");
brotliFilterHolder.setInitParameter(BrotliServletFilter.BROTLI_COMPRESSION_PARAMETER_QUALITY, "5");
// brotliFilterHolder.setInitParameter(BrotliServletFilter.BROTLI_COMPRESSION_PARAMETER_MODE, "GENERIC");
// brotliFilterHolder.setInitParameter(BrotliServletFilter.BROTLI_COMPRESSION_PARAMETER_LGBLOCK, "0");
// brotliFilterHolder.setInitParameter(BrotliServletFilter.BROTLI_COMPRESSION_PARAMETER_LGWIN, "22");
environment.getApplicationContext().getServletHandler().addFilter(brotliFilterHolder);
brotliFilterHolder.getRegistration().addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");
environment.jersey().register(new HelloBrotliResource());
}
示例6: run
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
@Override
public void run(TestServerConfiguration configuration, Environment environment) {
final FilterHolder brotliFilterHolder = new FilterHolder(checkNotNull(new BrotliServletFilter()));
brotliFilterHolder.setName("BrotliCompressionFilter");
environment.getApplicationContext().getServletHandler().addFilter(brotliFilterHolder);
brotliFilterHolder.getRegistration().addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");
}
示例7: addCSRFFilter
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
static void addCSRFFilter(ServletContextHandler ctxHandler, Configuration conf) {
restCSRFEnabled = conf.getBoolean(REST_CSRF_ENABLED_KEY, REST_CSRF_ENABLED_DEFAULT);
if (restCSRFEnabled) {
Map<String, String> restCsrfParams = RestCsrfPreventionFilter
.getFilterParams(conf, "hbase.rest-csrf.");
FilterHolder holder = new FilterHolder();
holder.setName("csrf");
holder.setClassName(RestCsrfPreventionFilter.class.getName());
holder.setInitParameters(restCsrfParams);
ctxHandler.addFilter(holder, PATH_SPEC_ANY, EnumSet.allOf(DispatcherType.class));
}
}
示例8: createRestJerseyFilterHolder
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
private static FilterHolder createRestJerseyFilterHolder() {
FilterHolder filterHolder = new FilterHolder();
filterHolder.setName("Jersey REST");
filterHolder.setClassName("com.sun.jersey.spi.container.servlet.ServletContainer");
filterHolder.getInitParameters().put("com.sun.jersey.config.property.packages", "net.nitram509.controller net.nitram509.gateways.controller net.nitram509.page.managegateways");
filterHolder.getInitParameters().put("com.sun.jersey.config.feature.FilterForwardOn404", "true"); // allow static resources
return filterHolder;
}
示例9: main
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
applicationContext.register(WebConfig.class);
applicationContext.setDisplayName("Brainbox");
ServletHolder servletHolder = new ServletHolder("brainbox",
new DispatcherServlet(applicationContext));
ServletContextHandler servletContext = new ServletContextHandler(null,
"/", true, false);
servletContext.addEventListener(new ContextLoaderListener(
applicationContext));
servletContext.addServlet(servletHolder, "/*");
// Spring Security
FilterHolder filterHolder = new FilterHolder(
DelegatingFilterProxy.class);
filterHolder.setName("springSecurityFilterChain");
servletContext.addFilter(filterHolder, "/*",
EnumSet.allOf(DispatcherType.class));
// Server
int port = 9999;
Server server = new Server(port);
server.setHandler(servletContext);
server.start();
server.join();
}
示例10: start
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
public void start(Herder herder) {
log.info("Starting REST server");
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.register(new JacksonJsonProvider());
resourceConfig.register(RootResource.class);
resourceConfig.register(new ConnectorsResource(herder));
resourceConfig.register(new ConnectorPluginsResource(herder));
resourceConfig.register(ConnectExceptionMapper.class);
ServletContainer servletContainer = new ServletContainer(resourceConfig);
ServletHolder servletHolder = new ServletHolder(servletContainer);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
context.addServlet(servletHolder, "/*");
String allowedOrigins = config.getString(WorkerConfig.ACCESS_CONTROL_ALLOW_ORIGIN_CONFIG);
if (allowedOrigins != null && !allowedOrigins.trim().isEmpty()) {
FilterHolder filterHolder = new FilterHolder(new CrossOriginFilter());
filterHolder.setName("cross-origin");
filterHolder.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, allowedOrigins);
String allowedMethods = config.getString(WorkerConfig.ACCESS_CONTROL_ALLOW_METHODS_CONFIG);
if (allowedMethods != null && !allowedOrigins.trim().isEmpty()) {
filterHolder.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, allowedMethods);
}
context.addFilter(filterHolder, "/*", EnumSet.of(DispatcherType.REQUEST));
}
RequestLogHandler requestLogHandler = new RequestLogHandler();
Slf4jRequestLog requestLog = new Slf4jRequestLog();
requestLog.setLoggerName(RestServer.class.getCanonicalName());
requestLog.setLogLatency(true);
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[]{context, new DefaultHandler(), requestLogHandler});
/* Needed for graceful shutdown as per `setStopTimeout` documentation */
StatisticsHandler statsHandler = new StatisticsHandler();
statsHandler.setHandler(handlers);
jettyServer.setHandler(statsHandler);
jettyServer.setStopTimeout(GRACEFUL_SHUTDOWN_TIMEOUT_MS);
jettyServer.setStopAtShutdown(true);
try {
jettyServer.start();
} catch (Exception e) {
throw new ConnectException("Unable to start REST server", e);
}
log.info("REST server listening at " + jettyServer.getURI() + ", advertising URL " + advertisedUrl());
}
示例11: main
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
/**
* Run the Wikipedia application.
*
* @param args command line arguments
* @throws Exception if the server fails to start or crashes
*/
public static void main(String[] args) throws Exception {
int port = 9998;
Server server = new Server(port);
ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
servletContextHandler.addEventListener(new MetricServletContextListener());
servletContextHandler.addEventListener(new HealthCheckServletContextListener());
servletContextHandler.setContextPath("/");
servletContextHandler.setResourceBase("src/main/webapp");
//Activate codahale metrics
FilterHolder instrumentedFilterHolder = new FilterHolder(InstrumentedFilter.class);
instrumentedFilterHolder.setName("instrumentedFilter");
instrumentedFilterHolder.setAsyncSupported(true);
servletContextHandler.addFilter(instrumentedFilterHolder, "/*", EnumSet.noneOf(DispatcherType.class));
// Static resource handler
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setResourceBase("src/main/webapp");
// Add the handlers to the server
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resourceHandler, servletContextHandler });
server.setHandler(handlers);
ServletHolder servletHolder = servletContextHandler.addServlet(ServletContainer.class, "/v1/*");
servletHolder.setInitOrder(1);
servletHolder.setInitParameter(
"javax.ws.rs.Application",
"com.yahoo.bard.webservice.application.ResourceConfig");
servletHolder.setInitParameter(
"jersey.config.server.provider.packages",
"com.yahoo.bard.webservice.web.endpoints");
servletContextHandler.addServlet(AdminServlet.class, "/*");
server.start();
markDimensionCacheHealthy(port);
}
示例12: main
import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
/**
* Run a generic setup which mirrors all information from druid into fili configuration.
*
* @param args Command line arguments.
*
* @throws Exception if the server fails to start or crashes.
*/
public static void main(String[] args) throws Exception {
int port = SYSTEM_CONFIG.getIntProperty(FILI_PORT);
Server server = new Server(port);
ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
servletContextHandler.addEventListener(new MetricServletContextListener());
servletContextHandler.addEventListener(new HealthCheckServletContextListener());
servletContextHandler.setContextPath("/");
servletContextHandler.setResourceBase("src/main/webapp");
//Activate codahale metrics
FilterHolder instrumentedFilterHolder = new FilterHolder(InstrumentedFilter.class);
instrumentedFilterHolder.setName("instrumentedFilter");
instrumentedFilterHolder.setAsyncSupported(true);
servletContextHandler.addFilter(instrumentedFilterHolder, "/*", EnumSet.noneOf(DispatcherType.class));
// Static resource handler
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setResourceBase("src/main/webapp");
// Add the handlers to the server
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] {resourceHandler, servletContextHandler});
server.setHandler(handlers);
ServletHolder servletHolder = servletContextHandler.addServlet(ServletContainer.class, "/v1/*");
servletHolder.setInitOrder(1);
servletHolder.setInitParameter(
"javax.ws.rs.Application",
"com.yahoo.bard.webservice.application.ResourceConfig"
);
servletHolder.setInitParameter(
"jersey.config.server.provider.packages",
"com.yahoo.bard.webservice.web.endpoints"
);
servletContextHandler.addServlet(AdminServlet.class, "/*");
server.start();
}