List of usage examples for javax.servlet FilterConfig getInitParameter
public String getInitParameter(String name);
String
containing the value of the named initialization parameter, or null
if the initialization parameter does not exist. From source file:jp.terasoluna.fw.web.thin.SessionLockControlFilter.java
/** * tB^T?[rXJn???ARei?o?B Rei?AFilterCX^X?Ainit?\bh 1 ?o?B<br> * FiltertB^????sv??A init ?\bh?? ?I?B init?\bh ????ARei FilterT?[rX??B<br> * <ul>/* w w w. j a v a 2 s . c o m*/ * <li>ServletException X??[?B</li> * <li>Rei`?AA?B</li> * <li>???B</li> * </ul> * @param config FilterConfigCX^X?B * @throws javax.servlet.ServletException ??X??[O?B * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) * @see jp.terasoluna.fw.web.thin.AbstractControlFilter */ public void init(FilterConfig config) throws ServletException { String interruptResponseCodeStr = config.getInitParameter(INIT_PARAM_INTERRUPT_RESPONSE_CODE); if (interruptResponseCodeStr != null) { interruptResponseCode = Integer.parseInt(interruptResponseCodeStr); } String thresholdStr = config.getInitParameter(INIT_PARAM_THRESHOLD); if (thresholdStr != null) { threshold = Integer.parseInt(thresholdStr); } if (log.isDebugEnabled()) { log.debug(INIT_PARAM_INTERRUPT_RESPONSE_CODE + " = " + interruptResponseCode + "."); if (threshold >= 0) { log.debug(INIT_PARAM_THRESHOLD + " = " + threshold + ". LimitedLock is enabled."); } else { log.debug(INIT_PARAM_THRESHOLD + " = " + threshold + ". LimitedLock is disabled. Reason: " + INIT_PARAM_THRESHOLD + " is negative number."); } } }
From source file:com.threewks.analytics.filter.HttpRequestResponseTrackingFilter.java
@Override public void init(FilterConfig config) throws ServletException { String serviceUrl = getMandatoryInitParam(config, SERVICE_URL_PARAM); String threadPoolSize = config.getInitParameter(THREAD_POOL_SIZE_PARAM); String apiKey = getApiKey(config); analytics = new AnalyticsClient(apiKey, serviceUrl); createThreadPool(threadPoolSize != null ? Integer.valueOf(threadPoolSize) : DEFAULT_THREAD_POOL_SIZE); }
From source file:com.matthewcasperson.validation.filter.ParameterValidationFilter.java
/** * Attempts to parse the XML config file. The config file is a JaxB serialisation of a * ParameterValidationDefinitionsImpl object. *///w ww.ja v a2 s . c o m @Override public void init(final FilterConfig config) throws ServletException { try { final String configFile = config.getInitParameter(CONFIG_PARAMETER_NAME); if (configFile != null) { LOGGER.log(Level.FINE, "Attempting to unmarshall " + configFile); final String configXml = IOUtils .toString(config.getServletContext().getResourceAsStream(configFile)); LOGGER.log(Level.FINE, "configXml is \n" + configXml); parameterValidationDefinitions = SERIALISATION_UTILS.readFromXML(configXml, ParameterValidationDefinitionsImpl.class); } } catch (final Exception ex) { /* * This will happen if the supplied XML is invalid. Log the error */ LOGGER.log(Level.SEVERE, ExceptionUtils.getFullStackTrace(ex)); /* * Rethrow as we don't want to proceed with invalid configuration */ throw new ServletException(ex); } }
From source file:org.sakaiproject.util.RemoteHostFilter.java
private String getParameter(FilterConfig config, String parmName) { String retval = ServerConfigurationService.getString("webservices." + parmName, null); if (retval != null) return retval; return config.getInitParameter(parmName); }
From source file:net.sf.ehcache.constructs.web.filter.Filter.java
/** * Processes initialisation parameters. These are configured in web.xml in accordance with the * Servlet specification using the following syntax: * <pre>//w w w . ja va 2s .co m * <filter> * ... * <init-param> * <param-name>blah</param-name> * <param-value>blahvalue</param-value> * </init-param> * ... * </filter> * </pre> * @throws ServletException */ protected void processInitParams(final FilterConfig config) throws ServletException { String exceptions = config.getInitParameter("exceptionsToLogDifferently"); String level = config.getInitParameter("exceptionsToLogDifferentlyLevel"); String suppressStackTracesString = config.getInitParameter("suppressStackTraces"); suppressStackTraces = Boolean.valueOf(suppressStackTracesString).booleanValue(); if (LOG.isDebugEnabled()) { LOG.debug("Suppression of stack traces enabled for " + this.getClass().getName()); } if (exceptions != null) { validateMandatoryParameters(exceptions, level); validateLevel(level); exceptionsToLogDifferentlyLevel = level; exceptionsToLogDifferently = exceptions; if (LOG.isDebugEnabled()) { LOG.debug("Different logging levels configured for " + this.getClass().getName()); } } }
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 {/* w w w.j av a 2 s.co m*/ 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:com.mtgi.analytics.servlet.BehaviorTrackingFilter.java
public void init(FilterConfig config) throws ServletException { servletContext = config.getServletContext(); WebApplicationContext context = getRequiredWebApplicationContext(servletContext); String managerName = config.getInitParameter(PARAM_MANAGER_NAME); BehaviorTrackingManager manager;/*from ww w. j a v a 2 s . c om*/ if (managerName == null) { //if there is no bean name configured, we assume there //must be exactly one such bean in the application context. Map<?, ?> managers = context.getBeansOfType(BehaviorTrackingManager.class); if (managers.isEmpty()) throw new ServletException( "Unable to find a bean of class " + BehaviorTrackingManager.class.getName() + " in the Spring application context; perhaps it has not been configured?"); if (managers.size() > 1) throw new ServletException("More than one instance of " + BehaviorTrackingManager.class.getName() + " in Spring application context; you must specify which to use with the filter parameter " + PARAM_MANAGER_NAME); manager = (BehaviorTrackingManager) managers.values().iterator().next(); } else { //lookup the specified bean name. manager = (BehaviorTrackingManager) context.getBean(managerName, BehaviorTrackingManager.class); } //see if there is an event type name configured. String eventType = config.getInitParameter(PARAM_EVENT_TYPE); //parameters included in event data String params = config.getInitParameter(PARAM_PARAMETERS_INCLUDE); String[] parameters = params == null ? null : LIST_SEPARATOR.split(params); //parameters included in event name String nameParams = config.getInitParameter(PARAM_PARAMETERS_NAME); String[] nameParameters = nameParams == null ? null : LIST_SEPARATOR.split(nameParams); delegate = new ServletRequestBehaviorTrackingAdapter(eventType, manager, parameters, nameParameters, null); //increment count of tracking filters registered in the servlet context. the filter //and alternative request listener check this attribute to make sure both are not registered at once. Integer count = (Integer) servletContext.getAttribute(ATT_FILTER_REGISTERED); servletContext.setAttribute(ATT_FILTER_REGISTERED, count == null ? 1 : count + 1); }
From source file:com.nn.cfw.web.security.CustomCsrfPreventionFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { if (contains(filterConfig, "entryPoints")) { setEntryPoints(filterConfig.getInitParameter("entryPoints")); }/*from ww w . jav a 2 s .c om*/ if (contains(filterConfig, "nonceCacheSize")) { setNonceCacheSize(Integer.valueOf(filterConfig.getInitParameter("nonceCacheSize"))); } }
From source file:org.xchain.framework.filter.UrlTranslationFilter.java
/** * Get the URL to the configuration file from the FilterConfig. * /*from w w w .j a v a2 s . co m*/ * @param filterConfig The FilterConfig to check. * * @return The URL to the configuration file. */ private URL getConfigurationURL(FilterConfig filterConfig) throws Exception { URL configResourceUrl = null; String configResourceUrlParameter = filterConfig.getInitParameter(CONFIG_RESOURCE_URL_PARAM_NAME); if (configResourceUrlParameter != null && configResourceUrlParameter.trim().length() != 0) { configResourceUrl = Thread.currentThread().getContextClassLoader() .getResource(configResourceUrlParameter); } else { throw new Exception("Configuration is not specified."); } return configResourceUrl; }
From source file:com.idega.core.cache.filter.Filter.java
private void processInitParams(final FilterConfig config) throws ServletException { String exceptions = config.getInitParameter("exceptionsToLogDifferently"); String level = config.getInitParameter("exceptionsToLogDifferentlyLevel"); String suppressStackTracesString = config.getInitParameter("suppressStackTraces"); this.suppressStackTraces = Boolean.valueOf(suppressStackTracesString).booleanValue(); if (LOG.isDebugEnabled()) { LOG.debug("Suppression of stack traces enabled for " + this.getClass().getName()); }/*from w w w. j a v a2s . com*/ if (exceptions != null) { validateMandatoryParameters(exceptions, level); validateLevel(level); this.exceptionsToLogDifferentlyLevel = level; this.exceptionsToLogDifferently = exceptions; if (LOG.isDebugEnabled()) { LOG.debug("Different logging levels configured for " + this.getClass().getName()); } } }