org.eclipse.jetty.servlet.FilterMapping Java Examples

The following examples show how to use org.eclipse.jetty.servlet.FilterMapping. 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 6 votes vote down vote up
@Override
public void addFilter(String name, String classname,
    Map<String, String> parameters) {

  FilterHolder filterHolder = getFilterHolder(name, classname, parameters);
  FilterMapping fmap =
      getFilterMapping(name, new String[] {"*.html", "*.jsp"});
  defineFilter(webAppContext, filterHolder, fmap);
  LOG.info("Added filter {} (class={}) to context {}", name, classname,
          webAppContext.getDisplayName());
  fmap = getFilterMapping(name, new String[] {"/*"});
  for (Map.Entry<ServletContextHandler, Boolean> e
      : defaultContexts.entrySet()) {
    if (e.getValue()) {
      ServletContextHandler ctx = e.getKey();
      defineFilter(ctx, filterHolder, fmap);
      LOG.info("Added filter {} (class={}) to context {}", name, classname,
              ctx.getDisplayName());
    }
  }
  filterNames.add(name);
}
 
Example #2
Source File: HttpServer2.java    From knox with Apache License 2.0 6 votes vote down vote up
@Override
public void addFilter(String name, String classname,
                      Map<String, String> parameters) {

  FilterHolder filterHolder = getFilterHolder(name, classname, parameters);
  final String[] USER_FACING_URLS = { "*.html", "*.jsp" };
  FilterMapping fmap = getFilterMapping(name, USER_FACING_URLS);
  defineFilter(webAppContext, filterHolder, fmap);
  LOG.info(
      "Added filter " + name + " (class=" + classname + ") to context "
          + webAppContext.getDisplayName());
  final String[] ALL_URLS = { "/*" };
  fmap = getFilterMapping(name, ALL_URLS);
  for (Map.Entry<ServletContextHandler, Boolean> e
      : defaultContexts.entrySet()) {
    if (e.getValue()) {
      ServletContextHandler ctx = e.getKey();
      defineFilter(ctx, filterHolder, fmap);
      LOG.info("Added filter " + name + " (class=" + classname
                   + ") to context " + ctx.getDisplayName());
    }
  }
  filterNames.add(name);
}
 
Example #3
Source File: HttpServer2.java    From knox with Apache License 2.0 6 votes vote down vote up
@Override
public void addFilter(String name, String classname,
                      Map<String, String> parameters) {

  FilterHolder filterHolder = getFilterHolder(name, classname, parameters);
  final String[] USER_FACING_URLS = { "*.html", "*.jsp" };
  FilterMapping fmap = getFilterMapping(name, USER_FACING_URLS);
  defineFilter(webAppContext, filterHolder, fmap);
  LOG.info(
      "Added filter " + name + " (class=" + classname + ") to context "
          + webAppContext.getDisplayName());
  final String[] ALL_URLS = { "/*" };
  fmap = getFilterMapping(name, ALL_URLS);
  for (Map.Entry<ServletContextHandler, Boolean> e
      : defaultContexts.entrySet()) {
    if (e.getValue()) {
      ServletContextHandler ctx = e.getKey();
      defineFilter(ctx, filterHolder, fmap);
      LOG.info("Added filter " + name + " (class=" + classname
                   + ") to context " + ctx.getDisplayName());
    }
  }
  filterNames.add(name);
}
 
Example #4
Source File: HttpServer.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Add an internal servlet in the server, specifying whether or not to
 * protect with Kerberos authentication.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param requireAuth Require Kerberos authenticate to access servlet
 */
void addInternalServlet(String name, String pathSpec,
    Class<? extends HttpServlet> clazz, boolean requireAuthz) {
  ServletHolder holder = new ServletHolder(clazz);
  if (name != null) {
    holder.setName(name);
  }
  if (authenticationEnabled && requireAuthz) {
    FilterHolder filter = new FilterHolder(AdminAuthorizedFilter.class);
    filter.setName(AdminAuthorizedFilter.class.getSimpleName());
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setDispatches(FilterMapping.ALL);
    fmap.setFilterName(AdminAuthorizedFilter.class.getSimpleName());
    webAppContext.getServletHandler().addFilter(filter, fmap);
  }
  webAppContext.addServlet(holder, pathSpec);
}
 
Example #5
Source File: HttpServer2.java    From knox with Apache License 2.0 5 votes vote down vote up
/**
 * Add an internal servlet in the server, specifying whether or not to
 * protect with Kerberos authentication.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param requireAuth Require Kerberos authenticate to access servlet
 */
public void addInternalServlet(String name, String pathSpec,
                               Class<? extends HttpServlet> clazz, boolean requireAuth) {
  ServletHolder holder = new ServletHolder(clazz);
  if (name != null) {
    holder.setName(name);
  }
  // Jetty doesn't like the same path spec mapping to different servlets, so
  // if there's already a mapping for this pathSpec, remove it and assume that
  // the newest one is the one we want
  final ServletMapping[] servletMappings =
      webAppContext.getServletHandler().getServletMappings();
  for (ServletMapping servletMapping : servletMappings) {
    if (servletMapping.containsPathSpec(pathSpec)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Found existing " + servletMapping.getServletName() +
                      " servlet at path " + pathSpec + "; will replace mapping" +
                      " with " + holder.getName() + " servlet");
      }
      ServletMapping[] newServletMappings =
          ArrayUtil.removeFromArray(servletMappings, servletMapping);
      webAppContext.getServletHandler()
          .setServletMappings(newServletMappings);
      break;
    }
  }
  webAppContext.addServlet(holder, pathSpec);

  if(requireAuth && UserGroupInformation.isSecurityEnabled()) {
    LOG.info("Adding Kerberos (SPNEGO) filter to " + name);
    ServletHandler handler = webAppContext.getServletHandler();
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(SPNEGO_FILTER);
    fmap.setDispatches(FilterMapping.ALL);
    handler.addFilterMapping(fmap);
  }
}
 
Example #6
Source File: WebMappingsRenderer.java    From dropwizard-guicey with MIT License 5 votes vote down vote up
private TreeNode renderFilter(final FilterMapping mapping,
                              final FilterHolder holder,
                              final TreeNode root) throws Exception {
    // required only guice filter
    TreeNode last = null;
    boolean first = true;
    final boolean servletMapping = mapping.getPathSpecs() == null || mapping.getPathSpecs().length == 0;
    for (String path : servletMapping ? mapping.getServletNames() : mapping.getPathSpecs()) {
        // indicate multiple urls or servlets mapping
        String type = IDEM;
        String async = "";
        String stopped = "";
        String dispatches = "";
        String name = "";
        if (first) {
            type = RenderUtils.renderClassLine(Class.forName(holder.getClassName()));
            if (holder.isStopped()) {
                stopped = STOPPED;
            }
            if (holder.isAsyncSupported()) {
                async = ASYNC;
            }
            dispatches = mapping.getDispatcherTypes().toString();
            name = mapping.getFilterName();
        }
        last = root.child("filter     %-20s %-7s %-70s %-10s    %-15s %s",
                servletMapping ? "" : path, async, type, stopped, dispatches, name);
        first = false;
    }
    return last;
}
 
Example #7
Source File: WebMappingsRenderer.java    From dropwizard-guicey with MIT License 5 votes vote down vote up
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private Multimap<String, FilterReference> renderContextFilters(final MappingsConfig config,
                                                               final MutableServletContextHandler handler,
                                                               final TreeNode root) throws Exception {
    final Multimap<String, FilterReference> servletFilters = LinkedHashMultimap.create();
    for (FilterMapping mapping : handler.getServletHandler().getFilterMappings()) {
        final FilterHolder holder = handler.getServletHandler().getFilter(mapping.getFilterName());
        // single filter instance used for both contexts and so the name is also the same
        final boolean isGuiceFilter = mapping.getFilterName().equals(GuiceWebModule.GUICE_FILTER);
        if ((isGuiceFilter && !config.isGuiceMappings())
                || !isAllowed(holder.getClassName(), config)) {
            continue;
        }
        if (mapping.getServletNames() != null && mapping.getServletNames().length > 0) {
            // filters targeting exact servlet are only remembered to be shown below target servlet
            for (String servlet : mapping.getServletNames()) {
                servletFilters.put(servlet, new FilterReference(mapping, holder));
            }
        } else {
            final TreeNode filter = renderFilter(mapping, holder, root);
            if (isGuiceFilter) {
                renderGuiceWeb(filter);
            }
        }
    }
    return servletFilters;
}
 
Example #8
Source File: HttpServer2.java    From knox with Apache License 2.0 5 votes vote down vote up
/**
 * Add the path spec to the filter path mapping.
 * @param pathSpec The path spec
 * @param webAppCtx The WebApplicationContext to add to
 */
protected void addFilterPathMapping(String pathSpec,
                                    ServletContextHandler webAppCtx) {
  ServletHandler handler = webAppCtx.getServletHandler();
  for(String name : filterNames) {
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(name);
    fmap.setDispatches(FilterMapping.ALL);
    handler.addFilterMapping(fmap);
  }
}
 
Example #9
Source File: HttpServer2.java    From knox with Apache License 2.0 5 votes vote down vote up
private static FilterMapping getFilterMapping(String name, String[] urls) {
  FilterMapping fmap = new FilterMapping();
  fmap.setPathSpecs(urls);
  fmap.setDispatches(FilterMapping.ALL);
  fmap.setFilterName(name);
  return fmap;
}
 
Example #10
Source File: HttpServer2.java    From knox with Apache License 2.0 5 votes vote down vote up
@Override
public void addGlobalFilter(String name, String classname,
                            Map<String, String> parameters) {
  final String[] ALL_URLS = { "/*" };
  FilterHolder filterHolder = getFilterHolder(name, classname, parameters);
  FilterMapping fmap = getFilterMapping(name, ALL_URLS);
  defineFilter(webAppContext, filterHolder, fmap);
  for (ServletContextHandler ctx : defaultContexts.keySet()) {
    defineFilter(ctx, filterHolder, fmap);
  }
  LOG.info("Added global filter '" + name + "' (class=" + classname + ")");
}
 
Example #11
Source File: HttpServer2.java    From knox with Apache License 2.0 5 votes vote down vote up
/**
 * Add an internal servlet in the server, specifying whether or not to
 * protect with Kerberos authentication.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param requireAuth Require Kerberos authenticate to access servlet
 */
public void addInternalServlet(String name, String pathSpec,
                               Class<? extends HttpServlet> clazz, boolean requireAuth) {
  ServletHolder holder = new ServletHolder(clazz);
  if (name != null) {
    holder.setName(name);
  }
  // Jetty doesn't like the same path spec mapping to different servlets, so
  // if there's already a mapping for this pathSpec, remove it and assume that
  // the newest one is the one we want
  final ServletMapping[] servletMappings =
      webAppContext.getServletHandler().getServletMappings();
  for (ServletMapping servletMapping : servletMappings) {
    if (servletMapping.containsPathSpec(pathSpec)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Found existing " + servletMapping.getServletName() +
                      " servlet at path " + pathSpec + "; will replace mapping" +
                      " with " + holder.getName() + " servlet");
      }
      ServletMapping[] newServletMappings =
          ArrayUtil.removeFromArray(servletMappings, servletMapping);
      webAppContext.getServletHandler()
          .setServletMappings(newServletMappings);
      break;
    }
  }
  webAppContext.addServlet(holder, pathSpec);

  if(requireAuth && UserGroupInformation.isSecurityEnabled()) {
    LOG.info("Adding Kerberos (SPNEGO) filter to " + name);
    ServletHandler handler = webAppContext.getServletHandler();
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(SPNEGO_FILTER);
    fmap.setDispatches(FilterMapping.ALL);
    handler.addFilterMapping(fmap);
  }
}
 
Example #12
Source File: HttpServer2.java    From knox with Apache License 2.0 5 votes vote down vote up
/**
 * Add the path spec to the filter path mapping.
 * @param pathSpec The path spec
 * @param webAppCtx The WebApplicationContext to add to
 */
protected void addFilterPathMapping(String pathSpec,
                                    ServletContextHandler webAppCtx) {
  ServletHandler handler = webAppCtx.getServletHandler();
  for(String name : filterNames) {
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(name);
    fmap.setDispatches(FilterMapping.ALL);
    handler.addFilterMapping(fmap);
  }
}
 
Example #13
Source File: HttpServer2.java    From knox with Apache License 2.0 5 votes vote down vote up
private static FilterMapping getFilterMapping(String name, String[] urls) {
  FilterMapping fmap = new FilterMapping();
  fmap.setPathSpecs(urls);
  fmap.setDispatches(FilterMapping.ALL);
  fmap.setFilterName(name);
  return fmap;
}
 
Example #14
Source File: HttpServer2.java    From knox with Apache License 2.0 5 votes vote down vote up
@Override
public void addGlobalFilter(String name, String classname,
                            Map<String, String> parameters) {
  final String[] ALL_URLS = { "/*" };
  FilterHolder filterHolder = getFilterHolder(name, classname, parameters);
  FilterMapping fmap = getFilterMapping(name, ALL_URLS);
  defineFilter(webAppContext, filterHolder, fmap);
  for (ServletContextHandler ctx : defaultContexts.keySet()) {
    defineFilter(ctx, filterHolder, fmap);
  }
  LOG.info("Added global filter '" + name + "' (class=" + classname + ")");
}
 
Example #15
Source File: HttpServer2.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
/**
 * Add an internal servlet in the server, specifying whether or not to
 * protect with Kerberos authentication.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param requireAuth Require Kerberos authenticate to access servlet
 */
public void addInternalServlet(String name, String pathSpec,
    Class<? extends HttpServlet> clazz, boolean requireAuth) {
  ServletHolder holder = new ServletHolder(clazz);
  if (name != null) {
    holder.setName(name);
  }
  // Jetty doesn't like the same path spec mapping to different servlets, so
  // if there's already a mapping for this pathSpec, remove it and assume that
  // the newest one is the one we want
  final ServletMapping[] servletMappings =
      webAppContext.getServletHandler().getServletMappings();
  for (int i = 0; i < servletMappings.length; i++) {
    if (servletMappings[i].containsPathSpec(pathSpec)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Found existing " + servletMappings[i].getServletName() +
            " servlet at path " + pathSpec + "; will replace mapping" +
            " with " + holder.getName() + " servlet");
      }
      ServletMapping[] newServletMappings =
          ArrayUtil.removeFromArray(servletMappings, servletMappings[i]);
      webAppContext.getServletHandler()
          .setServletMappings(newServletMappings);
      break;
    }
  }
  webAppContext.addServlet(holder, pathSpec);

  if (requireAuth && UserGroupInformation.isSecurityEnabled()) {
    LOG.info("Adding Kerberos (SPNEGO) filter to {}", name);
    ServletHandler handler = webAppContext.getServletHandler();
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(SPNEGO_FILTER);
    fmap.setDispatches(FilterMapping.ALL);
    handler.addFilterMapping(fmap);
  }
}
 
Example #16
Source File: HttpServer.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Add the path spec to the filter path mapping.
 * @param pathSpec The path spec
 * @param webAppCtx The WebApplicationContext to add to
 */
protected void addFilterPathMapping(String pathSpec,
    WebAppContext webAppCtx) {
  for(String name : filterNames) {
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(name);
    fmap.setDispatches(FilterMapping.ALL);
    webAppCtx.getServletHandler().addFilterMapping(fmap);
  }
}
 
Example #17
Source File: HttpServer2.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Add the path spec to the filter path mapping.
 * @param pathSpec The path spec
 * @param webAppCtx The WebApplicationContext to add to
 */
protected void addFilterPathMapping(String pathSpec,
                                    ServletContextHandler webAppCtx) {
  ServletHandler handler = webAppCtx.getServletHandler();
  for(String name : filterNames) {
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(name);
    fmap.setDispatches(FilterMapping.ALL);
    handler.addFilterMapping(fmap);
  }
}
 
Example #18
Source File: HttpServer2.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private static FilterMapping getFilterMapping(String name, String[] urls) {
  FilterMapping fmap = new FilterMapping();
  fmap.setPathSpecs(urls);
  fmap.setDispatches(FilterMapping.ALL);
  fmap.setFilterName(name);
  return fmap;
}
 
Example #19
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 #20
Source File: HttpServer2.java    From lucene-solr 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 ctx, String name,
                                String classname, Map<String,String> parameters, String[] urls) {
  FilterHolder filterHolder = getFilterHolder(name, classname, parameters);
  FilterMapping fmap = getFilterMapping(name, urls);
  defineFilter(ctx, filterHolder, fmap);
}
 
Example #21
Source File: HttpServer2.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Override
public void addGlobalFilter(String name, String classname,
    Map<String, String> parameters) {
  FilterHolder filterHolder = getFilterHolder(name, classname, parameters);
  FilterMapping fmap = getFilterMapping(name, new String[] {"/*"});
  defineFilter(webAppContext, filterHolder, fmap);
  for (ServletContextHandler ctx : defaultContexts.keySet()) {
    defineFilter(ctx, filterHolder, fmap);
  }
  LOG.info("Added global filter '{}' (class={})", name, classname);
}
 
Example #22
Source File: HttpServer2.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void addGlobalFilter(String name, String classname,
                            Map<String, String> parameters) {
  final String[] ALL_URLS = { "/*" };
  FilterHolder filterHolder = getFilterHolder(name, classname, parameters);
  FilterMapping fmap = getFilterMapping(name, ALL_URLS);
  defineFilter(webAppContext, filterHolder, fmap);
  for (ServletContextHandler ctx : defaultContexts.keySet()) {
    defineFilter(ctx, filterHolder, fmap);
  }
  LOG.info("Added global filter {}' (class={})'", name, classname);
}
 
Example #23
Source File: HttpServer2.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void addFilter(String name, String classname,
                      Map<String, String> parameters) {

  FilterHolder filterHolder = getFilterHolder(name, classname, parameters);
  final String[] USER_FACING_URLS = { "*.html", "*.jsp" };
  FilterMapping fmap = getFilterMapping(name, USER_FACING_URLS);
  defineFilter(webAppContext, filterHolder, fmap);
  if (LOG.isInfoEnabled()) {
    LOG.info("Added filter {} (class={}) to context {}", name, classname
        , webAppContext.getDisplayName());
  }
  final String[] ALL_URLS = { "/*" };
  fmap = getFilterMapping(name, ALL_URLS);
  for (Map.Entry<ServletContextHandler, Boolean> e
      : defaultContexts.entrySet()) {
    if (e.getValue()) {
      ServletContextHandler ctx = e.getKey();
      defineFilter(ctx, filterHolder, fmap);
      if (LOG.isInfoEnabled()) {
        LOG.info("Added filter {}  (class={}) to context {}"
            , name, classname, ctx.getDisplayName());
      }
    }
  }
  filterNames.add(name);
}
 
Example #24
Source File: HttpServer2.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Add an internal servlet in the server, specifying whether or not to
 * protect with Kerberos authentication.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param requireAuth Require Kerberos authenticate to access servlet
 */
public void addInternalServlet(String name, String pathSpec,
                               Class<? extends HttpServlet> clazz, boolean requireAuth) {
  ServletHolder holder = new ServletHolder(clazz);
  if (name != null) {
    holder.setName(name);
  }
  // Jetty doesn't like the same path spec mapping to different servlets, so
  // if there's already a mapping for this pathSpec, remove it and assume that
  // the newest one is the one we want
  final ServletMapping[] servletMappings =
      webAppContext.getServletHandler().getServletMappings();
  for (int i = 0; i < servletMappings.length; i++) {
    if (servletMappings[i].containsPathSpec(pathSpec)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Found existing {} servlet at path {}; will replace mapping with {} servlet"
            , servletMappings[i].getServletName()
            , pathSpec
            , holder.getName());
      }
      ServletMapping[] newServletMappings =
          ArrayUtil.removeFromArray(servletMappings, servletMappings[i]);
      webAppContext.getServletHandler()
          .setServletMappings(newServletMappings);
      break;
    }
  }
  webAppContext.addServlet(holder, pathSpec);

  if(requireAuth && UserGroupInformation.isSecurityEnabled()) {
    LOG.info("Adding Kerberos (SPNEGO) filter to {}", name);
    ServletHandler handler = webAppContext.getServletHandler();
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(SPNEGO_FILTER);
    fmap.setDispatches(FilterMapping.ALL);
    handler.addFilterMapping(fmap);
  }
}
 
Example #25
Source File: HttpServer2.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
/**
 * Define a filter for a context and set up default url mappings.
 */
private static void defineFilter(ServletContextHandler ctx, String name,
    String classname, Map<String, String> parameters, String[] urls) {
  FilterHolder filterHolder = getFilterHolder(name, classname, parameters);
  FilterMapping fmap = getFilterMapping(name, urls);
  defineFilter(ctx, filterHolder, fmap);
}
 
Example #26
Source File: HttpServer2.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
/**
 * Add the path spec to the filter path mapping.
 * @param pathSpec The path spec
 * @param webAppCtx The WebApplicationContext to add to
 */
private void addFilterPathMapping(String pathSpec,
    ServletContextHandler webAppCtx) {
  ServletHandler handler = webAppCtx.getServletHandler();
  for (String name : filterNames) {
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(name);
    fmap.setDispatches(FilterMapping.ALL);
    handler.addFilterMapping(fmap);
  }
}
 
Example #27
Source File: HttpServer2.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
private static FilterMapping getFilterMapping(String name, String[] urls) {
  FilterMapping fmap = new FilterMapping();
  fmap.setPathSpecs(urls);
  fmap.setDispatches(FilterMapping.ALL);
  fmap.setFilterName(name);
  return fmap;
}
 
Example #28
Source File: WebMappingsRenderer.java    From dropwizard-guicey with MIT License 4 votes vote down vote up
public FilterMapping getMapping() {
    return mapping;
}
 
Example #29
Source File: WebMappingsRenderer.java    From dropwizard-guicey with MIT License 4 votes vote down vote up
FilterReference(final FilterMapping mapping, final FilterHolder holder) {
    this.mapping = mapping;
    this.holder = holder;
}
 
Example #30
Source File: HttpServer2.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
/**
 * Define a filter for a context and set up default url mappings.
 */
private static void defineFilter(ServletContextHandler ctx,
    FilterHolder holder, FilterMapping fmap) {
  ServletHandler handler = ctx.getServletHandler();
  handler.addFilter(holder, fmap);
}