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:org.seasar.teeda.extension.filter.MultipartFormDataFilter.java
protected int getSizeParameter(final FilterConfig filterConfig, final String parameterName, final int defaultValue) { String param = filterConfig.getInitParameter(parameterName); if (StringUtil.isEmpty(param)) { return defaultValue; }/* w ww . j a va 2 s. co m*/ param = param.toLowerCase(); int factor = 1; String number = param; if (param.endsWith("g")) { factor = 1024 * 1024 * 1024; number = param.substring(0, param.length() - 1); } else if (param.endsWith("m")) { factor = 1024 * 1024; number = param.substring(0, param.length() - 1); } else if (param.endsWith("k")) { factor = 1024; number = param.substring(0, param.length() - 1); } return Integer.parseInt(number) * factor; }
From source file:org.kuali.rice.krad.web.filter.SetResponseBufferSizeFilter.java
/** * Initializes this Filter with the required parameter, bufferSize. * //from w ww.j a v a2 s . c o m * @throws ServletException if the bufferSize parameter is missing or does not contain an integer. * @see Filter#init */ public void init(FilterConfig filterConfig) throws ServletException { log = LogFactory.getLog(SetResponseBufferSizeFilter.class); String bufferSizeParam = filterConfig.getInitParameter("bufferSize"); if (log.isDebugEnabled()) { log.debug("bufferSizeParam=" + bufferSizeParam); } if (bufferSizeParam == null) { throw new ServletException("bufferSize parameter is required"); } try { bufferSize = Integer.parseInt(bufferSizeParam); } catch (NumberFormatException e) { throw new ServletException("bufferSize parameter is not an integer", e); } log.info("Filter initialized. Response buffer size is " + bufferSize); }
From source file:cn.bc.web.filter.SetCharacterEncodingFilter.java
/** * Place this filter into service./* w w w . j a v a2s .c o m*/ * * @param filterConfig The filter configuration object */ public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; this.encoding = filterConfig.getInitParameter("encoding"); String value = filterConfig.getInitParameter("ignore"); if (value == null) this.ignore = true; else if (value.equalsIgnoreCase("true")) this.ignore = true; else if (value.equalsIgnoreCase("yes")) this.ignore = true; else this.ignore = false; }
From source file:org.gwtwidgets.server.filters.ResponseHeaderFilter.java
public void init(FilterConfig conf) throws ServletException { int size = getSize(conf.getInitParameterNames()); if (conf.getInitParameter(URL_PATTERN) != null) { size--;//from w w w . ja v a 2 s . com setupMatcher(conf.getInitParameter(URL_PATTERN)); } headers = new String[size]; values = new String[size]; if (size == 0) { logger.warn("Instantiated ResponseHeaderFilter without header mappings"); return; } logger.debug("ResponseHeaderFilter header mappings:"); Enumeration<String> e = conf.getInitParameterNames(); for (int i = 0; i < size;) { String header = e.nextElement().toString(); if (URL_PATTERN.equals(header)) continue; headers[i] = header; values[i] = conf.getInitParameter(headers[i]); if ("".equals(values[i])) values[i] = null; logger.debug(headers[i] + " = " + values[i]); i++; } }
From source file:org.jasig.web.filter.SimpleCorsFilter.java
/** * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) *///from www . j a va 2s.c om @Override public void init(FilterConfig filterConfig) { String value = filterConfig.getInitParameter("allowOrigin"); if (!StringUtils.isEmpty(value)) { this.allowOrigin = value; } value = filterConfig.getInitParameter("allowMethod"); if (!StringUtils.isEmpty(value)) { this.allowMethod = value; } value = filterConfig.getInitParameter("maxAge"); if (!StringUtils.isEmpty(value)) { this.maxAge = value; } value = filterConfig.getInitParameter("allowHeaders"); if (!StringUtils.isEmpty(value)) { this.allowHeaders = value; } }
From source file:edu.vt.middleware.servlet.filter.ClientCertFilter.java
/** * Initialize this filter./*from w w w .j av a 2s . c o m*/ * * @param config <code>FilterConfig</code> */ public void init(final FilterConfig config) { this.requireCert = Boolean.valueOf(config.getInitParameter(REQUIRE_CERT)).booleanValue(); if (LOG.isDebugEnabled()) { LOG.debug("requireCert = " + this.requireCert); } final String issuerDn = config.getInitParameter(ISSUER_DN); if (issuerDn != null) { this.issuerDnPattern = Pattern.compile(issuerDn); } final String subjectDn = config.getInitParameter(SUBJECT_DN); if (subjectDn != null) { this.subjectDnPattern = Pattern.compile(subjectDn); } }
From source file:org.addsimplicity.anicetus.web.TelemetryServletFilter.java
public void init(FilterConfig config) throws ServletException { m_servletContext = config.getServletContext(); m_sessionContextName = config.getInitParameter("SessionContextName"); if (m_sessionContextName == null) { m_sessionContextName = "sessionContext"; }/*from www.j a v a 2 s . c om*/ }
From source file:com.dcs.controller.filter.SecurityServlet.java
@Override public void init(FilterConfig config) throws ServletException { {/*from w w w.j a v a 2 s . com*/ String exclusions = config.getInitParameter(PARAM_NAME_EXCLUSIONS); if (exclusions != null && exclusions.trim().length() != 0) { excludesPattern = new HashSet<String>(Arrays.asList(exclusions.split("\\s*,\\s*"))); } } { this.contextPath = getContextPath(config.getServletContext()); } }
From source file:org.apache.hadoop.gateway.hdfs.dispatch.WebHdfsHaHttpClientDispatch.java
@Override public void init(FilterConfig filterConfig) throws ServletException { resourceRole = filterConfig.getInitParameter(RESOURCE_ROLE_ATTRIBUTE); LOG.initializingForResourceRole(resourceRole); haProvider = HaServletContextListener.getHaProvider(filterConfig.getServletContext()); HaServiceConfig serviceConfig = haProvider.getHaDescriptor().getServiceConfig(resourceRole); maxFailoverAttempts = serviceConfig.getMaxFailoverAttempts(); failoverSleep = serviceConfig.getFailoverSleep(); maxRetryAttempts = serviceConfig.getMaxRetryAttempts(); retrySleep = serviceConfig.getRetrySleep(); }
From source file:org.aklimuk.cas.rest.authenti.CasRestAuthenticationFilter.java
protected void initInternal(final FilterConfig filterConfig) throws ServletException { if (!isIgnoreInitConfiguration()) { super.initInternal(filterConfig); casRestLoginUrl = filterConfig.getInitParameter("casRestLoginUrl"); }/*from w w w . ja v a 2 s. c o m*/ }