Java Code Examples for org.eclipse.jetty.servlet.FilterMapping#setDispatches()
The following examples show how to use
org.eclipse.jetty.servlet.FilterMapping#setDispatches() .
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: HttpServer.java From hbase with Apache License 2.0 | 6 votes |
/** * 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 2
Source File: HttpServer2.java From hadoop-ozone with Apache License 2.0 | 5 votes |
/** * 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 3
Source File: HttpServer2.java From hadoop-ozone with Apache License 2.0 | 5 votes |
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 4
Source File: HttpServer2.java From hadoop-ozone with Apache License 2.0 | 5 votes |
/** * 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 5
Source File: HttpServer2.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * 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 6
Source File: HttpServer2.java From lucene-solr with Apache License 2.0 | 5 votes |
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 7
Source File: HttpServer2.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * 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 8
Source File: HttpServer.java From hbase with Apache License 2.0 | 5 votes |
/** * 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 9
Source File: HttpServer.java From hbase with Apache License 2.0 | 5 votes |
/** * 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 10
Source File: HttpServer2.java From knox with Apache License 2.0 | 5 votes |
/** * 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 11
Source File: HttpServer2.java From knox with Apache License 2.0 | 5 votes |
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 12
Source File: HttpServer2.java From knox with Apache License 2.0 | 5 votes |
/** * 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 |
/** * 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 14
Source File: HttpServer2.java From knox with Apache License 2.0 | 5 votes |
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 15
Source File: HttpServer2.java From knox with Apache License 2.0 | 5 votes |
/** * 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); } }