當前位置: 首頁>>代碼示例>>Java>>正文


Java FilterConfig.getInitParameterNames方法代碼示例

本文整理匯總了Java中javax.servlet.FilterConfig.getInitParameterNames方法的典型用法代碼示例。如果您正苦於以下問題:Java FilterConfig.getInitParameterNames方法的具體用法?Java FilterConfig.getInitParameterNames怎麽用?Java FilterConfig.getInitParameterNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.FilterConfig的用法示例。


在下文中一共展示了FilterConfig.getInitParameterNames方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import javax.servlet.FilterConfig; //導入方法依賴的package包/類
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
	this.cfg = filterConfig;
	this.ctx = filterConfig.getServletContext();
	final TreeMap<String, Limit> limits = new TreeMap<String, Limit>();
	final Enumeration<String> e = filterConfig.getInitParameterNames();
	final int ipMaxSize = getIntConfigParam("ipMaxSize", DEFAULT_IPMAXSIZE);
	while (e.hasMoreElements()) {
		final String key = e.nextElement();
		if (!key.isEmpty() && (key.charAt(0) == '/')) {
			final String uri = key;
			final String value = filterConfig.getInitParameter(key);
			final String[] conf = value.split(":"); // 0=concurrent-limit, 1=ip-time-limit-millis
			final int concurrent = (conf.length > 0 ? Integer.parseInt(conf[0]) : 0);
			final long timeByIP = (conf.length > 1 ? Long.parseLong(conf[1]) : 0);
			final Limit limit = new Limit(timeByIP, ipMaxSize, concurrent);
			filterConfig.getServletContext().log("uri=" + uri + " limit=[" + limit + "]");
			limits.put(uri, limit);
		}
	}
	this.limits = limits;
}
 
開發者ID:ggrandes,項目名稱:concurrentlimit-servlet-filter,代碼行數:23,代碼來源:ConcurrentLimitFilter.java

示例2: getProxyuserConfiguration

import javax.servlet.FilterConfig; //導入方法依賴的package包/類
/**
 * Returns the proxyuser configuration. All returned properties must start
 * with <code>proxyuser.</code>'
 * <p/>
 * Subclasses may override this method if the proxyuser configuration is 
 * read from other place than the filter init parameters.
 *
 * @param filterConfig filter configuration object
 * @return the proxyuser configuration properties.
 * @throws ServletException thrown if the configuration could not be created.
 */
protected Configuration getProxyuserConfiguration(FilterConfig filterConfig)
    throws ServletException {
  // this filter class gets the configuration from the filter configs, we are
  // creating an empty configuration and injecting the proxyuser settings in
  // it. In the initialization of the filter, the returned configuration is
  // passed to the ProxyUsers which only looks for 'proxyusers.' properties.
  Configuration conf = new Configuration(false);
  Enumeration<?> names = filterConfig.getInitParameterNames();
  while (names.hasMoreElements()) {
    String name = (String) names.nextElement();
    if (name.startsWith(PROXYUSER_PREFIX + ".")) {
      String value = filterConfig.getInitParameter(name);
      conf.set(name, value);
    }
  }
  return conf;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:29,代碼來源:DelegationTokenAuthenticationFilter.java

示例3: init

import javax.servlet.FilterConfig; //導入方法依賴的package包/類
@Override
public void init(FilterConfig filterConfig) throws ServletException {
    Enumeration<String> paramNames = filterConfig.getInitParameterNames();
    while (paramNames.hasMoreElements()) {
        String paramName = paramNames.nextElement();
        if (!IntrospectionUtils.setProperty(this, paramName,
                filterConfig.getInitParameter(paramName))) {
            String msg = sm.getString("filterbase.noSuchProperty",
                    paramName, this.getClass().getName());
            if (isConfigProblemFatal()) {
                throw new ServletException(msg);
            } else {
                getLogger().warn(msg);
            }
        }
    }    
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:18,代碼來源:FilterBase.java

示例4: FilterConfigPropertyValues

import javax.servlet.FilterConfig; //導入方法依賴的package包/類
/**
 * 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, ", "));
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:32,代碼來源:GenericFilterBean.java

示例5: getConfiguration

import javax.servlet.FilterConfig; //導入方法依賴的package包/類
@Override
protected Properties getConfiguration(String configPrefix,
    FilterConfig filterConfig) throws ServletException {
  Properties props = new Properties();
  Enumeration<?> names = filterConfig.getInitParameterNames();
  while (names.hasMoreElements()) {
    String name = (String) names.nextElement();
    if (name.startsWith(configPrefix)) {
      String value = filterConfig.getInitParameter(name);
      props.put(name.substring(configPrefix.length()), value);
    }
  }
  props.put(AuthenticationFilter.AUTH_TYPE, "simple");
  props.put(PseudoAuthenticationHandler.ANONYMOUS_ALLOWED, "false");
  return props;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:TestRMWebServicesAppsModification.java

示例6: initParamsMapFrom

import javax.servlet.FilterConfig; //導入方法依賴的package包/類
static Map<String, String> initParamsMapFrom(FilterConfig config)
{
    Map<String, String> result = new LinkedHashMap<>();
    Enumeration<String> names = config.getInitParameterNames();

    while (names.hasMoreElements())
    {
        String name = names.nextElement();

        result.put(name, config.getInitParameter(name));
    }

    return result;
}
 
開發者ID:curityio,項目名稱:oauth-filter-for-java,代碼行數:15,代碼來源:FilterHelper.java

示例7: init

import javax.servlet.FilterConfig; //導入方法依賴的package包/類
@Override
public void init(FilterConfig filterConfig) throws ServletException {
	Enumeration<String> paramNames = filterConfig.getInitParameterNames();
	while (paramNames.hasMoreElements()) {
		String paramName = paramNames.nextElement();
		if (!IntrospectionUtils.setProperty(this, paramName, filterConfig.getInitParameter(paramName))) {
			String msg = sm.getString("filterbase.noSuchProperty", paramName, this.getClass().getName());
			if (isConfigProblemFatal()) {
				throw new ServletException(msg);
			} else {
				getLogger().warn(msg);
			}
		}
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:16,代碼來源:FilterBase.java

示例8: init

import javax.servlet.FilterConfig; //導入方法依賴的package包/類
public void init(FilterConfig filterConfig) throws ServletException {
    FilterUtils.configureLogging(this.getLoggerHandlerClassName(), LOGGER);
    Enumeration initParamNames = filterConfig.getInitParameterNames();
    throwIfUnrecognizedParamName(initParamNames);
    String enableCacheControl = filterConfig.getInitParameter("enableCacheControl");
    String enableXContentTypeOptions = filterConfig.getInitParameter("enableXContentTypeOptions");
    String enableStrictTransportSecurity = filterConfig.getInitParameter("enableStrictTransportSecurity");
    String enableXFrameOptions = filterConfig.getInitParameter("enableXFrameOptions");
    String enableXSSProtection = filterConfig.getInitParameter("enableXSSProtection");

    try {
        this.enableCacheControl = FilterUtils.parseStringToBooleanDefaultingToFalse(enableCacheControl);
    } catch (Exception var13) {
        FilterUtils.logException(LOGGER, new ServletException("Error parsing parameter [enableCacheControl] with value [" + enableCacheControl + "]", var13));
    }

    try {
        this.enableXContentTypeOptions = FilterUtils.parseStringToBooleanDefaultingToFalse(enableXContentTypeOptions);
    } catch (Exception var12) {
        FilterUtils.logException(LOGGER, new ServletException("Error parsing parameter [enableXContentTypeOptions] with value [" + enableXContentTypeOptions + "]", var12));
    }

    try {
        this.enableStrictTransportSecurity = FilterUtils.parseStringToBooleanDefaultingToFalse(enableStrictTransportSecurity);
    } catch (Exception var11) {
        FilterUtils.logException(LOGGER, new ServletException("Error parsing parameter [enableStrictTransportSecurity] with value [" + enableStrictTransportSecurity + "]", var11));
    }

    try {
        this.enableXFrameOptions = FilterUtils.parseStringToBooleanDefaultingToFalse(enableXFrameOptions);
    } catch (Exception var10) {
        FilterUtils.logException(LOGGER, new ServletException("Error parsing parameter [enableXFrameOptions] with value [" + enableXFrameOptions + "]", var10));
    }

    try {
        this.enableXSSProtection = FilterUtils.parseStringToBooleanDefaultingToFalse(enableXSSProtection);
    } catch (Exception var9) {
        FilterUtils.logException(LOGGER, new ServletException("Error parsing parameter [enableXSSProtection] with value [" + enableXSSProtection + "]", var9));
    }

}
 
開發者ID:e-gov,項目名稱:TARA-Server,代碼行數:42,代碼來源:ResponseHeadersEnforcementFilter.java

示例9: getFilterInitParameters

import javax.servlet.FilterConfig; //導入方法依賴的package包/類
/**
 * Converts the web.xml filter initialisation parameters to a Java
 * properties representation. The parameter names become property keys.
 *
 * @param config The filter configuration. Must not be {@code null}.
 *
 * @return The context parameters as Java properties.
 */
private static Properties getFilterInitParameters(final FilterConfig config) {

	Properties props = new Properties();

	Enumeration en = config.getInitParameterNames();
	
	while (en.hasMoreElements()) {
		
		String key = (String)en.nextElement();
		String value = config.getInitParameter(key);
		
		props.setProperty(key, value);
	}

	return props;
}
 
開發者ID:sdcuike,項目名稱:cors-filter,代碼行數:25,代碼來源:CORSConfigurationLoader.java

示例10: getConfiguration

import javax.servlet.FilterConfig; //導入方法依賴的package包/類
/**
 * Returns the filtered configuration (only properties starting with the specified prefix). The property keys
 * are also trimmed from the prefix. The returned {@link Properties} object is used to initialized the
 * {@link AuthenticationHandler}.
 * <p>
 * This method can be overriden by subclasses to obtain the configuration from other configuration source than
 * the web.xml file.
 *
 * @param configPrefix configuration prefix to use for extracting configuration properties.
 * @param filterConfig filter configuration object
 *
 * @return the configuration to be used with the {@link AuthenticationHandler} instance.
 *
 * @throws ServletException thrown if the configuration could not be created.
 */
protected Properties getConfiguration(String configPrefix, FilterConfig filterConfig) throws ServletException {
  Properties props = new Properties();
  Enumeration<?> names = filterConfig.getInitParameterNames();
  while (names.hasMoreElements()) {
    String name = (String) names.nextElement();
    if (name.startsWith(configPrefix)) {
      String value = filterConfig.getInitParameter(name);
      props.put(name.substring(configPrefix.length()), value);
    }
  }
  return props;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:28,代碼來源:AuthenticationFilter.java


注:本文中的javax.servlet.FilterConfig.getInitParameterNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。