List of usage examples for javax.servlet FilterConfig getInitParameterNames
public Enumeration<String> getInitParameterNames();
Enumeration
of String
objects, or an empty Enumeration
if the filter has no initialization parameters. From source file:info.magnolia.cms.util.ServletUtil.java
/** * Returns the init parameters for a {@link javax.servlet.FilterConfig} object as a Map, preserving the order in which they are exposed * by the {@link javax.servlet.FilterConfig} object. *///from w w w .j a va 2 s . c om public static LinkedHashMap<String, String> initParametersToMap(FilterConfig config) { LinkedHashMap<String, String> initParameters = new LinkedHashMap<String, String>(); Enumeration parameterNames = config.getInitParameterNames(); while (parameterNames.hasMoreElements()) { String parameterName = (String) parameterNames.nextElement(); initParameters.put(parameterName, config.getInitParameter(parameterName)); } return initParameters; }
From source file:CacheFilter.java
public void init(FilterConfig config) { Enumeration<?> names = config.getInitParameterNames(); ArrayList<String[]> tmp = new ArrayList<String[]>(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); String value = config.getInitParameter(name); String[] pair = { name, value }; tmp.add(pair);/*w w w.j av a 2 s. c om*/ } replyHeaders = new String[tmp.size()][2]; tmp.toArray(replyHeaders); }
From source file:io.dropwizard.hystrix.path.tracker.filters.impl.PathTrackerFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { key = filterConfig.getInitParameter("commandKey"); log.info("Setting up PathTrackerFilter, with key:{}" + filterConfig.getInitParameterNames()); }
From source file:org.beanfuse.security.monitor.SecurityFilter.java
public void init(FilterConfig cfg) throws ServletException { Enumeration en = cfg.getInitParameterNames(); while (en.hasMoreElements()) { String property = (String) en.nextElement(); Object value = cfg.getInitParameter(property); try {/*from w w w. j a va 2 s .com*/ PropertyUtils.setProperty(this, property, value); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } } // ???? if (StringUtils.isEmpty(resourceExtractorClassName)) { resourceExtractorClassName = SimpleResourceExtractor.class.getName(); } try { resourceExtractor = (ResourceExtractor) Class.forName(resourceExtractorClassName).newInstance(); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } if (StringUtils.isEmpty(expiredPath)) { expiredPath = loginFailPath; } freeResources.add(resourceExtractor.extract(loginFailPath)); freeResources.add(resourceExtractor.extract(expiredPath)); freeResources.add(resourceExtractor.extract(noAuthorityPath)); logger.info("Filter {} configured successfully with free resources {}", cfg.getFilterName(), freeResources); }
From source file:net.big_oh.common.web.filters.ipaddress.IPAddressFilter.java
@SuppressWarnings(value = "unchecked") private void initIPAddressFilteringRules(FilterConfig filterConfig) { Enumeration<String> filterInitParamNames = filterConfig.getInitParameterNames(); while (filterInitParamNames.hasMoreElements()) { String initParamName = filterInitParamNames.nextElement(); String initParamValue = filterConfig.getInitParameter(initParamName); if (initParamName.indexOf(".") != -1) { IPAddressFilterRule newFilterRuleFromFilterConfigParam = instantiateIPAddressFilterRule( initParamName, initParamValue); if (newFilterRuleFromFilterConfigParam != null) { registerFilterRuleWithFilter(newFilterRuleFromFilterConfigParam); }//from ww w . jav a 2 s . com } else { logger.warn("Ignoring filter init parameter '" + initParamName + "' because it doesn't seem to be the name of a Class."); } } }
From source file:com.jaspersoft.jasperserver.war.StaticFilesCacheControlFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { Enumeration<String> paramNames = filterConfig.getInitParameterNames(); while (paramNames != null && paramNames.hasMoreElements()) { String paramName = paramNames.nextElement(); String value = filterConfig.getInitParameter(paramName); if (URL_ENDS_WITH.equals(paramName)) { if (value != null && value.length() > 0) { String[] types = value.split(" "); for (int i = 0; i < types.length; i++) { if (types[i].length() > 0) { urlSuffixes.add(types[i].toLowerCase()); log.debug("URL suffix added : " + types[i]); }/*w w w.j a v a2s. c om*/ } } } else if (URL_STARTS_WITH.equals(paramName)) { if (value != null && value.length() > 0) { String[] types = value.split(" "); for (int i = 0; i < types.length; i++) { if (types[i].length() > 0) { urlPrefixes.add(types[i].toLowerCase()); log.debug("URL prefix added : " + types[i]); } } } } else if (EXCLUDE_PAGE_FROM_CACHE_REGEX.equals(paramName)) { if (value == null) continue; String[] regexStrs = value.split(" "); exclusionRegexSet.addAll(Arrays.asList(regexStrs)); log.debug("Added " + exclusionRegexSet.size() + " cache exclusion regex."); } else if (EXPIRES_AFTER_ACCESS_IN_SECS.equals(paramName)) { try { expiresInSecs = Integer.parseInt(value); log.debug("Expires in seconds set : " + expiresInSecs); } catch (Exception ex) { log.error(EXPIRES_AFTER_ACCESS_IN_SECS + " should be a non-negative integer", ex); } } else { log.warn("Unknown parameter, ignoring : " + paramName); } } }
From source file:edu.vt.middleware.servlet.filter.RequestMethodFilter.java
/** * Initialize this filter.//from ww w .ja v a2s . co m * * @param config <code>FilterConfig</code> */ public void init(final FilterConfig config) { final Enumeration<?> e = config.getInitParameterNames(); while (e.hasMoreElements()) { final String name = (String) e.nextElement(); final String value = config.getInitParameter(name); final StringTokenizer st = new StringTokenizer(name); final String methodName = st.nextToken(); Object[] args = null; Class<?>[] params = null; if (st.countTokens() > 0) { args = new Object[st.countTokens()]; params = new Class[st.countTokens()]; int i = 0; while (st.hasMoreTokens()) { final String token = st.nextToken(); args[i] = token; params[i++] = token.getClass(); } } try { this.servletMethods.put(methodName, ServletRequest.class.getMethod(methodName, params)); if (LOG.isDebugEnabled()) { LOG.debug("Found method " + methodName + " for ServletRequest"); } } catch (NoSuchMethodException ex) { if (LOG.isDebugEnabled()) { LOG.debug("Could not find method " + methodName + " for ServletRequest"); } } try { this.httpServletMethods.put(methodName, HttpServletRequest.class.getMethod(methodName, params)); if (LOG.isDebugEnabled()) { LOG.debug("Found method " + methodName + " for HttpServletRequest"); } } catch (NoSuchMethodException ex) { if (LOG.isDebugEnabled()) { LOG.debug("Could not find method " + methodName + " for HttpServletRequest"); } } this.arguments.put(methodName, args); this.patterns.put(methodName, Pattern.compile(value)); if (LOG.isDebugEnabled()) { if (this.arguments.get(methodName) != null) { if (LOG.isDebugEnabled()) { LOG.debug("Stored method name = " + methodName + ", pattern = " + value + " with these arguments " + Arrays.asList((Object[]) this.arguments.get(methodName))); } } else { if (LOG.isDebugEnabled()) { LOG.debug("Stored method name = " + methodName + ", pattern = " + value + " with no arguments"); } } } } }
From source file:org.xmlactions.web.PagerFilter.java
@SuppressWarnings("unchecked") public void init(FilterConfig filterConfig) throws ServletException { logger.debug("PagerFilter.init"); this.filterConfig = filterConfig; try {//from w ww . ja v a 2 s . co m } catch (Exception ex) { logger.error(ex.getMessage(), ex); } Enumeration<String> enumeration = filterConfig.getInitParameterNames(); while (enumeration.hasMoreElements()) { String key = enumeration.nextElement(); String value = filterConfig.getInitParameter(key); mapRequestParams.put(key, value); } }
From source file:org.hifivault.geo.location.filters.GeoLocationFilter.java
public void init(FilterConfig filterConfig) throws ServletException { BeanFactory beanFactory = WebApplicationContextUtils .getRequiredWebApplicationContext(filterConfig.getServletContext()); manager = (GeoLocationManager) beanFactory.getBean("geoLocationManager"); Enumeration<String> names = filterConfig.getInitParameterNames(); while (names.hasMoreElements()) { String key = names.nextElement(); String value = filterConfig.getInitParameter(key); if (value != null && value.length() > 0) { override.put(key.toUpperCase(), value.toUpperCase()); }/* w w w . j ava 2 s . c o m*/ } }
From source file:com.nn.cfw.web.security.CustomCsrfPreventionFilter.java
@SuppressWarnings("unchecked") private boolean contains(FilterConfig filterConfig, String parameterName) { if (filterConfig == null) { return false; }//from w w w.jav a2 s .c om Enumeration<String> paramNames = filterConfig.getInitParameterNames(); while (paramNames.hasMoreElements()) { if (StringUtils.equals(paramNames.nextElement(), parameterName)) { return true; } } return false; }