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:fr.gouv.culture.thesaurus.util.web.VocabularyAutoloadFilter.java
/** * Retourne le rpertoire de dplacement des fichiers en fonction de la * configuration et des valeurs par dfaut. * /* ww w. j av a 2 s.c o m*/ * @param config * la configuration du filter * @param paramName * le nom du paramtre regarder. * @param defaultRelativeDir * le repertoire parent par dfaut * @param defaultRelativePath * le nom du repertoire cible par dfaut. * @return le repertoire utiliser. */ private File getMoveDirectory(FilterConfig config, String paramName, File defaultRelativeDir, String defaultRelativePath) { String path = config.getInitParameter(paramName); if (!StringUtils.isEmpty(path)) { return new File(path); } return new File(defaultRelativeDir, defaultRelativePath); }
From source file:fr.gouv.culture.thesaurus.util.web.VocabularyAutoloadFilter.java
/** * Initialisation du chargement automatique (thread "deamon"). *//* w w w .ja va 2s. co m*/ @Override public void init(FilterConfig config) throws ServletException { try { File lookupDir = new File(config.getInitParameter(LOOKUP_DIRECTORY_PARAM)); File successDir = getMoveDirectory(config, SUCCESS_DIRECTORY_PARAM, lookupDir, DEFAULT_SUCCESS_DIRECTORY); File failedDir = getMoveDirectory(config, FAILURE_DIRECTORY_PARAM, lookupDir, DEFAULT_FAILURE_DIRECTORY); VocabularyAutoload runnable = new VocabularyAutoload(lookupDir, successDir, failedDir); // Priode de scrutation du rpertoire. String refreshValue = config.getInitParameter(REFRESH_PARAM); if (StringUtils.isNotEmpty(refreshValue)) { runnable.setSleepTime(Integer.valueOf(refreshValue)); } // Email String emailTo = config.getInitParameter(EMAIL_TO_PARAM); if (StringUtils.isNotEmpty(emailTo)) { runnable.setEmailTo(emailTo); } // Nombre de scrutation max par fichier String maxRetries = config.getInitParameter(MAX_TRIES_PARAM); if (StringUtils.isNotEmpty(maxRetries)) { runnable.setMaxTriesByFile(Integer.valueOf(maxRetries)); } thread = new Thread(runnable); thread.setDaemon(true); thread.start(); log.info("Vocabulary auto load started."); } catch (Exception e) { log.error("Unable to start vocabulary auto load.", e); } }
From source file:org.apache.hadoop.yarn.server.webproxy.amfilter.AmIpFilter.java
@Override public void init(FilterConfig conf) throws ServletException { // Maintain for backwards compatibility if (conf.getInitParameter(PROXY_HOST) != null && conf.getInitParameter(PROXY_URI_BASE) != null) { proxyHosts = new String[] { conf.getInitParameter(PROXY_HOST) }; proxyUriBases = new HashMap<String, String>(1); proxyUriBases.put("dummy", conf.getInitParameter(PROXY_URI_BASE)); } else {//from ww w. ja v a2 s. co m proxyHosts = conf.getInitParameter(PROXY_HOSTS).split(PROXY_HOSTS_DELIMITER); String[] proxyUriBasesArr = conf.getInitParameter(PROXY_URI_BASES).split(PROXY_URI_BASES_DELIMITER); proxyUriBases = new HashMap<String, String>(); for (String proxyUriBase : proxyUriBasesArr) { try { URL url = new URL(proxyUriBase); proxyUriBases.put(url.getHost() + ":" + url.getPort(), proxyUriBase); } catch (MalformedURLException e) { LOG.warn(proxyUriBase + " does not appear to be a valid URL", e); } } } }
From source file:org.jasig.cas.util.AbstractConfigurationFilter.java
/** * Retrieves the property from the FilterConfig. First it checks the FilterConfig's initParameters to see if it * has a value./*w w w . jav a 2 s . c om*/ * If it does, it returns that, otherwise it retrieves the ServletContext's initParameters and returns that value if any. * <p> * Finally, it will check JNDI if all other methods fail. All the JNDI properties should be stored under either java:comp/env/cas/SHORTFILTERNAME/{propertyName} * or java:comp/env/cas/{propertyName} * <p> * Essentially the documented order is: * <ol> * <li>FilterConfig.getInitParameter</li> * <li>ServletContext.getInitParameter</li> * <li>java:comp/env/cas/SHORTFILTERNAME/{propertyName}</li> * <li>java:comp/env/cas/{propertyName}</li> * <li>Default Value</li> * </ol> * * * @param filterConfig the Filter Configuration. * @param propertyName the property to retrieve. * @param defaultValue the default value if the property is not found. * @return the property value, following the above conventions. It will always return the more specific value (i.e. * filter vs. context). */ protected final String getPropertyFromInitParams(final FilterConfig filterConfig, final String propertyName, final String defaultValue) { final String value = filterConfig.getInitParameter(propertyName); if (CommonUtils.isNotBlank(value)) { log.info("Property [" + propertyName + "] loaded from FilterConfig.getInitParameter with value [" + value + "]"); return value; } final String value2 = filterConfig.getServletContext().getInitParameter(propertyName); if (CommonUtils.isNotBlank(value2)) { log.info("Property [" + propertyName + "] loaded from ServletContext.getInitParameter with value [" + value2 + "]"); return value2; } InitialContext context; try { context = new InitialContext(); } catch (final NamingException e) { log.warn(e, e); return defaultValue; } final String shortName = this.getClass().getName() .substring(this.getClass().getName().lastIndexOf(".") + 1); final String value3 = loadFromContext(context, "java:comp/env/cas/" + shortName + "/" + propertyName); if (CommonUtils.isNotBlank(value3)) { log.info("Property [" + propertyName + "] loaded from JNDI Filter Specific Property with value [" + value3 + "]"); return value3; } final String value4 = loadFromContext(context, "java:comp/env/cas/" + propertyName); if (CommonUtils.isNotBlank(value4)) { log.info("Property [" + propertyName + "] loaded from JNDI with value [" + value4 + "]"); return value4; } log.info("Property [" + propertyName + "] not found. Using default value [" + defaultValue + "]"); return defaultValue; }
From source file:org.cruxframework.crux.core.server.crawling.CrawlingFilter.java
@Override public void init(FilterConfig config) throws ServletException { this.config = config; this.defaultSnaphot = config.getInitParameter("defaultSnaphot"); this.baseFolder = config.getInitParameter("baseFolder"); if (baseFolder != null && baseFolder.startsWith("/")) { baseFolder = baseFolder.substring(1); }/*from w ww. j a va 2 s . c o m*/ }
From source file:org.roda.wui.filter.CasApiAuthFilter.java
@Override public void init(final FilterConfig filterConfig) throws ServletException { this.casClient = new CasClient(filterConfig.getInitParameter("casServerUrlPrefix")); final String exclusionsParam = filterConfig.getInitParameter("exclusions"); if (StringUtils.isNotBlank(exclusionsParam)) { final String[] listOfExclusions = exclusionsParam.split(","); for (String exclusion : listOfExclusions) { this.exclusions.add(exclusion.trim()); }//from ww w . j av a 2 s . co m } }
From source file:com.meltmedia.cadmium.servlets.ErrorPageFilter.java
/** * Configures the ignore prefix.//from ww w .j a v a 2 s .c om */ @Override public void init(FilterConfig config) throws ServletException { if (config.getInitParameter("ignorePrefix") != null) { ignorePath = config.getInitParameter("ignorePrefix"); } }
From source file:org.apache.hadoop.security.http.CrossOriginFilter.java
private void initializeAllowedMethods(FilterConfig filterConfig) { String allowedMethodsConfig = filterConfig.getInitParameter(ALLOWED_METHODS); if (allowedMethodsConfig == null) { allowedMethodsConfig = ALLOWED_METHODS_DEFAULT; }/*from w ww .j a v a 2 s. c om*/ allowedMethods.addAll(Arrays.asList(allowedMethodsConfig.trim().split("\\s*,\\s*"))); LOG.info("Allowed Methods: " + getAllowedMethodsHeader()); }
From source file:org.apache.hadoop.security.http.CrossOriginFilter.java
private void initializeAllowedHeaders(FilterConfig filterConfig) { String allowedHeadersConfig = filterConfig.getInitParameter(ALLOWED_HEADERS); if (allowedHeadersConfig == null) { allowedHeadersConfig = ALLOWED_HEADERS_DEFAULT; }/* w ww. j a v a 2 s . c o m*/ allowedHeaders.addAll(Arrays.asList(allowedHeadersConfig.trim().split("\\s*,\\s*"))); LOG.info("Allowed Headers: " + getAllowedHeadersHeader()); }
From source file:org.apache.hadoop.security.http.CrossOriginFilter.java
private void initializeAllowedOrigins(FilterConfig filterConfig) { String allowedOriginsConfig = filterConfig.getInitParameter(ALLOWED_ORIGINS); if (allowedOriginsConfig == null) { allowedOriginsConfig = ALLOWED_ORIGINS_DEFAULT; }/* w w w.j a va 2 s .c o m*/ allowedOrigins.addAll(Arrays.asList(allowedOriginsConfig.trim().split("\\s*,\\s*"))); allowAllOrigins = allowedOrigins.contains("*"); LOG.info("Allowed Origins: " + StringUtils.join(allowedOrigins, ',')); LOG.info("Allow All Origins: " + allowAllOrigins); }