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:nl.b3p.commons.security.aselect.ASelectAuthorizationFilter.java
/** * Hulpfunctie om een FilterConfig object om te zetten naar Properties *///w w w . j a va 2 s. co m private Properties filterConfigToProperties(FilterConfig c) { Properties result = new Properties(); Enumeration params = c.getInitParameterNames(); while (params.hasMoreElements()) { String name = (String) params.nextElement(); result.setProperty(name, c.getInitParameter(name)); } return result; }
From source file:org.ajax4jsf.webapp.BaseFilter.java
/** * Initialize the filter.//from ww w . jav a 2s .c o m */ public void init(FilterConfig config) throws ServletException { if (log.isDebugEnabled()) { log.debug("Init ajax4jsf filter with nane: " + config.getFilterName()); Enumeration<String> parameterNames = config.getInitParameterNames(); StringBuffer parameters = new StringBuffer("Init parameters :\n"); while (parameterNames.hasMoreElements()) { String name = parameterNames.nextElement(); parameters.append(name).append(" : '").append(config.getInitParameter(name)).append('\n'); } log.debug(parameters); // log.debug("Stack Trace", new Exception()); } // Save config filterConfig = config; setFunction((String) nz(filterConfig.getInitParameter(FUNCTION_NAME_PARAMETER), getFunction())); setAttributesNames(filterConfig.getInitParameter(ABSOLUTE_TAGS_PARAMETER)); xmlFilter.init(config); if ("true".equalsIgnoreCase(filterConfig.getInitParameter(REWRITEID_PARAMETER))) { this.setRewriteid(true); } resourceService = new InternetResourceService(); // Caching initialization. resourceService.init(filterConfig); eventsManager = new PollEventsManager(); eventsManager.init(filterConfig.getServletContext()); String param = filterConfig.getInitParameter("createTempFiles"); if (param != null) { this.createTempFiles = Boolean.parseBoolean(param); } else { this.createTempFiles = true; } param = filterConfig.getInitParameter("maxRequestSize"); if (param != null) { this.maxRequestSize = Integer.parseInt(param); } }
From source file:org.ambraproject.cas.client.filter.CASFilterWrapper.java
/** * @see javax.servlet.Servlet//from ww w . j ava 2 s . c om */ public void init(final FilterConfig filterConfig) throws ServletException { final Map<String, String> params = new HashMap<String, String>(6); final InitParamProvider initParamProvider = new InitParamProvider() { public Enumeration<?> getInitParameterNames() { return filterConfig.getInitParameterNames(); } public String getInitParameter(final String key) { return filterConfig.getInitParameter(key); } }; ConfigWrapperUtil.copyInitParams(initParamProvider, params); final Configuration configuration = ConfigurationStore.getInstance().getConfiguration(); final String ambraServerHost = configuration.getString("ambra.platform.host"); final String casProxyValidateUrl = configuration.getString("ambra.services.cas.url.proxy-validate"); final String casLoginUrl = configuration.getString("ambra.services.cas.url.login"); ConfigWrapperUtil.setInitParamValue(CASFilter.LOGIN_INIT_PARAM, casLoginUrl, initParamProvider, params); ConfigWrapperUtil.setInitParamValue(CASFilter.VALIDATE_INIT_PARAM, casProxyValidateUrl, initParamProvider, params); ConfigWrapperUtil.setInitParamValue(CASFilter.SERVERNAME_INIT_PARAM, ambraServerHost, initParamProvider, params); final FilterConfig customFilterConfig = new ConfigWrapper(filterConfig, params); super.init(customFilterConfig); }
From source file:org.apache.atlas.web.filters.AtlasAuthenticationFilter.java
@Override protected Properties getConfiguration(String configPrefix, FilterConfig filterConfig) throws ServletException { Configuration configuration;//from ww w . j a v a 2 s .com try { configuration = ApplicationProperties.get(); } catch (Exception e) { throw new ServletException(e); } Properties config = new Properties(); String kerberosAuthEnabled = configuration != null ? configuration.getString("atlas.authentication.method.kerberos") : null; // getString may return null, and would like to log the nature of the default setting String authMethod = ""; if (kerberosAuthEnabled == null || kerberosAuthEnabled.equalsIgnoreCase("false")) { LOG.info("No authentication method configured. Defaulting to simple authentication"); authMethod = "simple"; } else if (kerberosAuthEnabled.equalsIgnoreCase("true")) { authMethod = "kerberos"; } if (configuration.getString("atlas.authentication.method.kerberos.name.rules") != null) { config.put("kerberos.name.rules", configuration.getString("atlas.authentication.method.kerberos.name.rules")); } if (configuration.getString("atlas.authentication.method.kerberos.keytab") != null) { config.put("kerberos.keytab", configuration.getString("atlas.authentication.method.kerberos.keytab")); } if (configuration.getString("atlas.authentication.method.kerberos.principal") != null) { config.put("kerberos.principal", configuration.getString("atlas.authentication.method.kerberos.principal")); } config.put(AuthenticationFilter.AUTH_TYPE, authMethod); config.put(AuthenticationFilter.COOKIE_PATH, "/"); // add any config passed in as init parameters Enumeration<String> enumeration = filterConfig.getInitParameterNames(); while (enumeration.hasMoreElements()) { String name = enumeration.nextElement(); config.put(name, filterConfig.getInitParameter(name)); } //Resolve _HOST into bind address String bindAddress = configuration.getString(SecurityProperties.BIND_ADDRESS); if (bindAddress == null) { LOG.info("No host name configured. Defaulting to local host name."); try { bindAddress = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { throw new ServletException("Unable to obtain host name", e); } } String principal = config.getProperty(KerberosAuthenticationHandler.PRINCIPAL); if (principal != null) { try { principal = SecurityUtil.getServerPrincipal(principal, bindAddress); } catch (IOException ex) { throw new RuntimeException("Could not resolve Kerberos principal name: " + ex.toString(), ex); } config.put(KerberosAuthenticationHandler.PRINCIPAL, principal); } LOG.debug(" AuthenticationFilterConfig: {}", config); supportKeyTabBrowserLogin = configuration .getBoolean("atlas.authentication.method.kerberos.support.keytab.browser.login", false); String agents = configuration.getString(AtlasCSRFPreventionFilter.BROWSER_USER_AGENT_PARAM, AtlasCSRFPreventionFilter.BROWSER_USER_AGENTS_DEFAULT); if (agents == null) { agents = AtlasCSRFPreventionFilter.BROWSER_USER_AGENTS_DEFAULT; } parseBrowserUserAgents(agents); return config; }
From source file:org.apache.hadoop.security.authentication.server.AuthenticationFilter.java
/** * 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}./* w w w.j a v a 2 s. c o m*/ * <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; }
From source file:org.apache.ranger.security.web.filter.RangerKrbFilter.java
/** * 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}.// w w w. j a v a2 s.c o m * <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(); if (filterConfig != null) { Enumeration<?> names = filterConfig.getInitParameterNames(); if (names != null) { while (names.hasMoreElements()) { String name = (String) names.nextElement(); if (name != null && configPrefix != null && name.startsWith(configPrefix)) { String value = filterConfig.getInitParameter(name); props.put(name.substring(configPrefix.length()), value); } } } } return props; }
From source file:org.apache.struts2.dispatcher.FilterDispatcher.java
/** * Create a default {@link Dispatcher} that subclasses can override * with a custom Dispatcher, if needed.// ww w .j a va 2 s.co m * * @param filterConfig Our FilterConfig * @return Initialized Dispatcher */ protected Dispatcher createDispatcher(FilterConfig filterConfig) { Map<String, String> params = new HashMap<String, String>(); for (Enumeration e = filterConfig.getInitParameterNames(); e.hasMoreElements();) { String name = (String) e.nextElement(); String value = filterConfig.getInitParameter(name); params.put(name, value); } return new Dispatcher(filterConfig.getServletContext(), params); }
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--;// ww w . ja va 2s . c o m 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.cas.client.util.ErrorRedirectFilter.java
public void init(final FilterConfig filterConfig) throws ServletException { this.defaultErrorRedirectPage = filterConfig.getInitParameter("defaultErrorRedirectPage"); final Enumeration enumeration = filterConfig.getInitParameterNames(); while (enumeration.hasMoreElements()) { final String className = (String) enumeration.nextElement(); try {/*from w w w . j a v a2 s .c om*/ if (!className.equals("defaultErrorRedirectPage")) { this.errors.add(new ErrorHolder(className, filterConfig.getInitParameter(className))); } } catch (final ClassNotFoundException e) { log.warn("Class [" + className + "] cannot be found in ClassLoader. Ignoring."); } } }
From source file:org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter.java
/** * Constructs a Cas20ServiceTicketValidator or a Cas20ProxyTicketValidator based on supplied parameters. * * @param filterConfig the Filter Configuration object. * @return a fully constructed TicketValidator. *///from w w w . j av a2s .c om protected final TicketValidator getTicketValidator(final FilterConfig filterConfig) { final String allowAnyProxy = getPropertyFromInitParams(filterConfig, "acceptAnyProxy", null); final String allowedProxyChains = getPropertyFromInitParams(filterConfig, "allowedProxyChains", null); // TODO ? ServletContext context = filterConfig.getServletContext(); String casServerContextName = context.getInitParameter(CAS_SERVER_NAME_CONTEXT_PARAMETER); CommonUtils.assertNotNull(casServerContextName, "casServerContextName cannot be null."); String casServerAddress = getCasServerAddress(); logger.trace(this.getClass() + ".getTicketValidator(): casServerAddress = " + casServerAddress); final String casServerUrlPrefix = casServerAddress + "/" + casServerContextName + "/"; logger.trace(this.getClass() + ".getTicketValidator(): casServerUrlPrefix = " + casServerUrlPrefix); final Cas20ServiceTicketValidator validator; if (CommonUtils.isNotBlank(allowAnyProxy) || CommonUtils.isNotBlank(allowedProxyChains)) { final Cas20ProxyTicketValidator v = new Cas20ProxyTicketValidator(casServerUrlPrefix); v.setAcceptAnyProxy(parseBoolean(allowAnyProxy)); v.setAllowedProxyChains(CommonUtils.createProxyList(allowedProxyChains)); validator = v; } else { validator = new Cas20ServiceTicketValidator(casServerUrlPrefix); } validator.setProxyCallbackPath(getPropertyFromInitParams(filterConfig, "proxyCallbackPath", null)); validator.setProxyGrantingTicketStorage(this.proxyGrantingTicketStorage); validator.setProxyRetriever(new Cas20ProxyRetriever(casServerUrlPrefix, getPropertyFromInitParams(filterConfig, "encoding", null))); validator.setRenew(parseBoolean(getPropertyFromInitParams(filterConfig, "renew", "false"))); validator.setEncoding(getPropertyFromInitParams(filterConfig, "encoding", null)); final Map additionalParameters = new HashMap(); final List params = Arrays.asList(RESERVED_INIT_PARAMS); for (final Enumeration e = filterConfig.getInitParameterNames(); e.hasMoreElements();) { final String s = (String) e.nextElement(); if (!params.contains(s)) { additionalParameters.put(s, filterConfig.getInitParameter(s)); } } validator.setCustomParameters(additionalParameters); validator.setHostnameVerifier(getHostnameVerifier(filterConfig)); return validator; }