Java Code Examples for javax.servlet.FilterConfig#getFilterName()
The following examples show how to use
javax.servlet.FilterConfig#getFilterName() .
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: GenericFilterBean.java From spring-analysis-note with MIT License | 6 votes |
/** * Create new FilterConfigPropertyValues. * @param config the FilterConfig we'll use to take PropertyValues from * @param requiredProperties set of property names we need, where * we can't accept default values * @throws ServletException if any required properties are missing */ public FilterConfigPropertyValues(FilterConfig config, Set<String> requiredProperties) throws ServletException { Set<String> missingProps = (!CollectionUtils.isEmpty(requiredProperties) ? new HashSet<>(requiredProperties) : null); Enumeration<String> paramNames = config.getInitParameterNames(); while (paramNames.hasMoreElements()) { String property = paramNames.nextElement(); Object value = config.getInitParameter(property); addPropertyValue(new PropertyValue(property, value)); if (missingProps != null) { missingProps.remove(property); } } // Fail if we are still missing properties. if (!CollectionUtils.isEmpty(missingProps)) { throw new ServletException( "Initialization from FilterConfig for filter '" + config.getFilterName() + "' failed; the following required properties were missing: " + StringUtils.collectionToDelimitedString(missingProps, ", ")); } }
Example 2
Source File: GenericFilterBean.java From java-technology-stack with MIT License | 6 votes |
/** * Create new FilterConfigPropertyValues. * @param config the FilterConfig we'll use to take PropertyValues from * @param requiredProperties set of property names we need, where * we can't accept default values * @throws ServletException if any required properties are missing */ public FilterConfigPropertyValues(FilterConfig config, Set<String> requiredProperties) throws ServletException { Set<String> missingProps = (!CollectionUtils.isEmpty(requiredProperties) ? new HashSet<>(requiredProperties) : null); Enumeration<String> paramNames = config.getInitParameterNames(); while (paramNames.hasMoreElements()) { String property = paramNames.nextElement(); Object value = config.getInitParameter(property); addPropertyValue(new PropertyValue(property, value)); if (missingProps != null) { missingProps.remove(property); } } // Fail if we are still missing properties. if (!CollectionUtils.isEmpty(missingProps)) { throw new ServletException( "Initialization from FilterConfig for filter '" + config.getFilterName() + "' failed; the following required properties were missing: " + StringUtils.collectionToDelimitedString(missingProps, ", ")); } }
Example 3
Source File: GenericFilterBean.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Create new FilterConfigPropertyValues. * @param config FilterConfig we'll use to take PropertyValues from * @param requiredProperties set of property names we need, where * we can't accept default values * @throws ServletException if any required properties are missing */ public FilterConfigPropertyValues(FilterConfig config, Set<String> requiredProperties) throws ServletException { Set<String> missingProps = (!CollectionUtils.isEmpty(requiredProperties) ? new HashSet<String>(requiredProperties) : null); Enumeration<String> paramNames = config.getInitParameterNames(); while (paramNames.hasMoreElements()) { String property = paramNames.nextElement(); Object value = config.getInitParameter(property); addPropertyValue(new PropertyValue(property, value)); if (missingProps != null) { missingProps.remove(property); } } // Fail if we are still missing properties. if (!CollectionUtils.isEmpty(missingProps)) { throw new ServletException( "Initialization from FilterConfig for filter '" + config.getFilterName() + "' failed; the following required properties were missing: " + StringUtils.collectionToDelimitedString(missingProps, ", ")); } }
Example 4
Source File: GenericFilterBean.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Create new FilterConfigPropertyValues. * @param config FilterConfig we'll use to take PropertyValues from * @param requiredProperties set of property names we need, where * we can't accept default values * @throws ServletException if any required properties are missing */ public FilterConfigPropertyValues(FilterConfig config, Set<String> requiredProperties) throws ServletException { Set<String> missingProps = (requiredProperties != null && !requiredProperties.isEmpty()) ? new HashSet<String>(requiredProperties) : null; Enumeration<?> en = config.getInitParameterNames(); while (en.hasMoreElements()) { String property = (String) en.nextElement(); Object value = config.getInitParameter(property); addPropertyValue(new PropertyValue(property, value)); if (missingProps != null) { missingProps.remove(property); } } // Fail if we are still missing properties. if (missingProps != null && missingProps.size() > 0) { throw new ServletException( "Initialization from FilterConfig for filter '" + config.getFilterName() + "' failed; the following required properties were missing: " + StringUtils.collectionToDelimitedString(missingProps, ", ")); } }
Example 5
Source File: RequestCacheFilterImpl.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public void init(final FilterConfig filterConfig) { final String filterName = filterConfig.getFilterName(); // Get cache name final String configurationPath = filterConfig.getInitParameter(CONFIGURATION_PATH); final String cacheName = filterConfig.getInitParameter("cacheName"); // Get Cacheonix manager final Cacheonix cacheonix; if (isBlank(configurationPath)) { cacheonix = Cacheonix.getInstance(); } else { cacheonix = Cacheonix.getInstance(configurationPath); } // Get cache if (isBlank(cacheName)) { cache = cacheonix.getCache(filterName); } else { cache = cacheonix.getCache(cacheName); } }
Example 6
Source File: GenericFilterBean.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Standard way of initializing this filter. * Map config parameters onto bean properties of this filter, and * invoke subclass initialization. * @param filterConfig the configuration for this filter * @throws ServletException if bean properties are invalid (or required * properties are missing), or if subclass initialization fails. * @see #initFilterBean */ @Override public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); if (logger.isDebugEnabled()) { logger.debug("Initializing filter '" + filterConfig.getFilterName() + "'"); } this.filterConfig = filterConfig; // Set bean properties from init parameters. try { PropertyValues pvs = new FilterConfigPropertyValues(filterConfig, this.requiredProperties); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext()); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, this.environment)); initBeanWrapper(bw); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': " + ex.getMessage(); logger.error(msg, ex); throw new NestedServletException(msg, ex); } // Let subclasses do whatever initialization they like. initFilterBean(); if (logger.isDebugEnabled()) { logger.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully"); } }
Example 7
Source File: SessFilter.java From HongsCORE with MIT License | 5 votes |
@Override public void init(FilterConfig fc) throws ServletException { String fn; fn = fc.getInitParameter("request-attr"); if (fn != null) SSRA = fn; fn = fc.getInitParameter("request-name"); if (fn != null) SSRN = fn; fn = fc.getInitParameter( "cookie-name"); if (fn != null) SSCN = fn; fn = fc.getInitParameter( "cookie-path"); if (fn != null) SSCP = fn; fn = fc.getInitParameter( "cookie-max-age"); if (fn != null) SSCX = Integer.parseInt(fn); fn = fc.getInitParameter( "record-max-age"); if (fn != null) SSRX = Integer.parseInt(fn); if (! SSCP.startsWith("/")) { SSCP = Core.BASE_HREF + "/" + SSCP; } inside = SessFilter.class.getName()+":"+fc.getFilterName()+":INSIDE"; ignore = new PasserHelper( fc.getInitParameter("ignore-urls"), fc.getInitParameter("attend-urls") ); }
Example 8
Source File: XsrfFilter.java From HongsCORE with MIT License | 5 votes |
@Override public void init(FilterConfig fc) throws ServletException { inside = XsrfFilter.class.getName()+":"+fc.getFilterName()+":INSIDE"; allows = Synt.toTerms (fc.getInitParameter("allow-hosts")); ignore = new PasserHelper( fc.getInitParameter("ignore-urls"), fc.getInitParameter("attend-urls") ); if (allows != null && allows.isEmpty()) { allows = null; } }
Example 9
Source File: PippoFilter.java From pippo with Apache License 2.0 | 5 votes |
private void initFilterPathFromWebXml(FilterConfig filterConfig) { String filterName = filterConfig.getFilterName(); FilterRegistration filterRegistration = filterConfig.getServletContext().getFilterRegistration(filterName); Collection<String> mappings = filterRegistration.getUrlPatternMappings(); int size = mappings.size(); if (size > 1) { throw new PippoRuntimeException("Expected one filter path for '{}' but found multiple", filterName); } if (size == 1) { String urlPattern = mappings.iterator().next(); initFilterPath(urlPattern); } }
Example 10
Source File: OneConfig.java From hasor with Apache License 2.0 | 4 votes |
public OneConfig(FilterConfig config, Supplier<AppContext> appContext) { this(); this.resourceName = config.getFilterName(); this.appContext = appContext; this.putConfig(config, true); }
Example 11
Source File: CorsFilter.java From oxAuth with MIT License | 4 votes |
@Override public void init(final FilterConfig filterConfig) throws ServletException { // Initialize defaults parseAndStore(DEFAULT_ALLOWED_ORIGINS, DEFAULT_ALLOWED_HTTP_METHODS, DEFAULT_ALLOWED_HTTP_HEADERS, DEFAULT_EXPOSED_HEADERS, DEFAULT_SUPPORTS_CREDENTIALS, DEFAULT_PREFLIGHT_MAXAGE, DEFAULT_DECORATE_REQUEST); AppConfiguration appConfiguration = configurationFactory.getAppConfiguration(); if (filterConfig != null) { String filterName = filterConfig.getFilterName(); CorsFilterConfig corsFilterConfig = new CorsFilterConfig(filterName, appConfiguration); String configEnabled = corsFilterConfig .getInitParameter(PARAM_CORS_ENABLED); String configAllowedOrigins = corsFilterConfig .getInitParameter(PARAM_CORS_ALLOWED_ORIGINS); String configAllowedHttpMethods = corsFilterConfig .getInitParameter(PARAM_CORS_ALLOWED_METHODS); String configAllowedHttpHeaders = corsFilterConfig .getInitParameter(PARAM_CORS_ALLOWED_HEADERS); String configExposedHeaders = corsFilterConfig .getInitParameter(PARAM_CORS_EXPOSED_HEADERS); String configSupportsCredentials = corsFilterConfig .getInitParameter(PARAM_CORS_SUPPORT_CREDENTIALS); String configPreflightMaxAge = corsFilterConfig .getInitParameter(PARAM_CORS_PREFLIGHT_MAXAGE); String configDecorateRequest = corsFilterConfig .getInitParameter(PARAM_CORS_REQUEST_DECORATE); if (configEnabled != null) { this.filterEnabled = Boolean.parseBoolean(configEnabled); } parseAndStore(configAllowedOrigins, configAllowedHttpMethods, configAllowedHttpHeaders, configExposedHeaders, configSupportsCredentials, configPreflightMaxAge, configDecorateRequest); } }