Java Code Examples for org.eclipse.jetty.servlet.FilterHolder#setClassName()

The following examples show how to use org.eclipse.jetty.servlet.FilterHolder#setClassName() . 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: HttpServer2.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
private static FilterHolder getFilterHolder(String name, String classname,
    Map<String, String> parameters) {
  FilterHolder holder = new FilterHolder();
  holder.setName(name);
  holder.setClassName(classname);
  if (parameters != null) {
    holder.setInitParameters(parameters);
  }
  return holder;
}
 
Example 2
Source File: HttpServer2.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private static FilterHolder getFilterHolder(String name, String classname,
                                            Map<String, String> parameters) {
  FilterHolder holder = new FilterHolder();
  holder.setName(name);
  holder.setClassName(classname);
  if (parameters != null) {
    holder.setInitParameters(parameters);
  }
  return holder;
}
 
Example 3
Source File: RESTServer.java    From hbase with Apache License 2.0 5 votes vote down vote up
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));
  }
}
 
Example 4
Source File: RESTServer.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void addClickjackingPreventionFilter(ServletContextHandler ctxHandler,
    Configuration conf) {
  FilterHolder holder = new FilterHolder();
  holder.setName("clickjackingprevention");
  holder.setClassName(ClickjackingPreventionFilter.class.getName());
  holder.setInitParameters(ClickjackingPreventionFilter.getDefaultParameters(conf));
  ctxHandler.addFilter(holder, PATH_SPEC_ANY, EnumSet.allOf(DispatcherType.class));
}
 
Example 5
Source File: RESTServer.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void addSecurityHeadersFilter(ServletContextHandler ctxHandler, Configuration conf) {
  FilterHolder holder = new FilterHolder();
  holder.setName("securityheaders");
  holder.setClassName(SecurityHeadersFilter.class.getName());
  holder.setInitParameters(SecurityHeadersFilter.getDefaultParameters(conf));
  ctxHandler.addFilter(holder, PATH_SPEC_ANY, EnumSet.allOf(DispatcherType.class));
}
 
Example 6
Source File: RESTServer.java    From hbase with Apache License 2.0 5 votes vote down vote up
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");
    // Hook for unit tests, this will log out any other user and mess up tests.
    if (!conf.getBoolean(SKIP_LOGIN_KEY, false)) {
      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);
}
 
Example 7
Source File: HttpServer.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 8
Source File: HttpServer2.java    From knox with Apache License 2.0 5 votes vote down vote up
private static FilterHolder getFilterHolder(String name, String classname,
                                            Map<String, String> parameters) {
  FilterHolder holder = new FilterHolder();
  holder.setName(name);
  holder.setClassName(classname);
  if (parameters != null) {
    holder.setInitParameters(parameters);
  }
  return holder;
}
 
Example 9
Source File: HttpServer2.java    From knox with Apache License 2.0 5 votes vote down vote up
private static FilterHolder getFilterHolder(String name, String classname,
                                            Map<String, String> parameters) {
  FilterHolder holder = new FilterHolder();
  holder.setName(name);
  holder.setClassName(classname);
  if (parameters != null) {
    holder.setInitParameters(parameters);
  }
  return holder;
}