当前位置: 首页>>代码示例>>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;未经允许,请勿转载。