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.xchain.framework.filter.UrlTranslationFilter.java
public void init(FilterConfig filterConfig) throws ServletException { servletContext = filterConfig.getServletContext(); if (filterConfig.getInitParameter(ENABLED_PARAM_NAME) != null) { this.enabled = Boolean.valueOf(filterConfig.getInitParameter(ENABLED_PARAM_NAME)).booleanValue(); }/*from w w w. j a va 2 s . co m*/ // Logger whether the filter is enabled. if (log.isDebugEnabled()) { if (this.enabled) log.debug("UrlTranslationFilter is ENABLED"); else log.debug("UrlTranslationFilter is DISABLED"); } if (enabled) { try { URL configResourceUrl = getConfigurationURL(filterConfig); if (configResourceUrl == null) { throw new Exception("Configuration file could not be found."); } loadConfiguration(configResourceUrl); } catch (Exception ex) { if (log.isWarnEnabled()) { log.warn("Failed to configure UrlTranslationFilter.", ex); } enabled = false; } } }
From source file:org.seasar.teeda.extension.filter.MultipartFormDataFilter.java
public void init(final FilterConfig filterConfig) throws ServletException { maxSize = getSizeParameter(filterConfig, "uploadMaxSize", DEFAULT_MAX_SIZE); maxFileSize = getSizeParameter(filterConfig, "uploadMaxFileSize", DEFAULT_MAX_FILE_SIZE); thresholdSize = getSizeParameter(filterConfig, "uploadThresholdSize", DEFAULT_THREASHOLD_SIZe); repositoryPath = filterConfig.getInitParameter("uploadRepositoryPath"); servletContext = filterConfig.getServletContext(); }
From source file:org.jsecurity.web.servlet.JSecurityFilter.java
protected void applyInitParams() { FilterConfig config = getFilterConfig(); String configCN = clean(config.getInitParameter(CONFIG_CLASS_NAME_INIT_PARAM_NAME)); if (configCN != null) { if (ClassUtils.isAvailable(configCN)) { this.configClassName = configCN; } else {/*from w ww . j a va 2s . co m*/ String msg = "configClassName fully qualified class name value [" + configCN + "] is not " + "available in the classpath. Please ensure you have typed it correctly and the " + "corresponding class or jar is in the classpath."; throw new ConfigurationException(msg); } } this.config = clean(config.getInitParameter(CONFIG_INIT_PARAM_NAME)); this.configUrl = clean(config.getInitParameter(CONFIG_URL_INIT_PARAM_NAME)); }
From source file:org.onehippo.forge.hst.pdf.renderer.servlet.HtmlPDFRenderingFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { Properties tidyProps = new Properties(); String param = StringUtils.trim(filterConfig.getInitParameter(TIDY_PROPS_PARAM)); if (!StringUtils.isEmpty(param)) { InputStream input = null; try {// w ww. j a va2 s .c om input = filterConfig.getServletContext().getResourceAsStream(param); tidyProps.load(input); } catch (Exception e) { log.error("Failed to parse Tidy properties from '" + param + "'.", e); } finally { IOUtils.closeQuietly(input); } } pdfRenderer = new HtmlPDFRenderer(tidyProps); param = StringUtils.trim(filterConfig.getInitParameter(CSS_URI_PARAM)); if (!StringUtils.isEmpty(param)) { String[] cssURIParams = StringUtils.split(param, ";, \t\r\n"); List<URI> cssURIList = new ArrayList<URI>(); for (String cssURIParam : cssURIParams) { if (StringUtils.startsWith(cssURIParam, "file:") || StringUtils.startsWith(cssURIParam, "http:") || StringUtils.startsWith(cssURIParam, "https:") || StringUtils.startsWith(cssURIParam, "ftp:") || StringUtils.startsWith(cssURIParam, "sftp:")) { cssURIList.add(URI.create(param)); } else { File cssFile = null; if (StringUtils.startsWith(cssURIParam, "/")) { cssFile = new File(filterConfig.getServletContext().getRealPath(cssURIParam)); } else { cssFile = new File(cssURIParam); } if (!cssFile.isFile()) { log.error("Cannot find the css file: {}", cssFile); } else { cssURIList.add(cssFile.toURI()); } } } if (!cssURIList.isEmpty()) { pdfRenderer.setCssURIs(cssURIList.toArray(new URI[cssURIList.size()])); } } param = StringUtils.trim(filterConfig.getInitParameter(BUFFER_SIZE_PARAM)); if (!StringUtils.isEmpty(param)) { pdfRenderer.setBufferSize(Math.max(512, NumberUtils.toInt(param, 4096))); } param = StringUtils.trim(filterConfig.getInitParameter(USER_AGENT_CALLBACK_CLASS_PARAM)); if (!StringUtils.isEmpty(param)) { try { Class<?> userAgentCallBackClass = Thread.currentThread().getContextClassLoader().loadClass(param); if (!UserAgentCallback.class.isAssignableFrom(userAgentCallBackClass)) { log.error("The class, '{}' is not an type of '{}'.", param, UserAgentCallback.class); } else { pdfRenderer.setUserAgentCallback((UserAgentCallback) userAgentCallBackClass.newInstance()); } } catch (Exception e) { log.error("Failed to set userAgentClassCallback object", e); } } param = StringUtils.trim(filterConfig.getInitParameter(FONT_PATHS_PARAM)); if (!StringUtils.isEmpty(param)) { String[] fontPaths = StringUtils.split(param, ";, \t\r\n"); pdfRenderer.setFontPaths(fontPaths); } }
From source file:org.artifactory.webapp.servlet.RepoFilter.java
@Override public void initLater(FilterConfig filterConfig) throws ServletException { String nonUiPathPrefixes = filterConfig.getInitParameter("nonUiPathPrefixes"); String uiPathPrefixes = filterConfig.getInitParameter("UiPathPrefixes"); List<String> nonUiPrefixes = PathUtils.delimitedListToStringList(nonUiPathPrefixes, ","); UiRequestUtils.setNonUiPathPrefixes(nonUiPrefixes); RequestUtils.setNonUiPathPrefixes(nonUiPrefixes); List<String> uiPrefixes = PathUtils.delimitedListToStringList(uiPathPrefixes, ","); uiPrefixes.add(HttpUtils.WEBAPP_URL_PATH_PREFIX); RequestUtils.setUiPathPrefixes(uiPrefixes); UiRequestUtils.setUiPathPrefixes(uiPrefixes); }
From source file:org.unitime.timetable.filter.PageAccessFilter.java
public void init(FilterConfig cfg) throws ServletException { iContext = cfg.getServletContext();// w w w . j av a 2s . co m try { Document config = (new SAXReader()) .read(cfg.getServletContext().getResource(cfg.getInitParameter("config"))); for (Iterator i = config.getRootElement().element("action-mappings").elementIterator("action"); i .hasNext();) { Element action = (Element) i.next(); String path = action.attributeValue("path"); String input = action.attributeValue("input"); if (path != null && input != null) { iPath2Tile.put(path + ".do", input); } } } catch (Exception e) { sLog.error("Unable to read config " + cfg.getInitParameter("config") + ", reason: " + e.getMessage()); } if (cfg.getInitParameter("debug-time") != null) { debugTime = Long.parseLong(cfg.getInitParameter("debug-time")); } if (cfg.getInitParameter("dump-time") != null) { dumpTime = Long.parseLong(cfg.getInitParameter("dump-time")); } if (cfg.getInitParameter("session-attributes") != null) { dumpSessionAttribues = Boolean.parseBoolean(cfg.getInitParameter("session-attributes")); } }
From source file:de.itsvs.cwtrpc.controller.CacheControlFilter.java
public void init(FilterConfig filterConfig) throws ServletException { final WebApplicationContext applicationContext; final CacheControlConfig config; final List<CacheControlUriConfig> uriConfigs; String configBeanName;//from w w w. j av a 2s . c o m configBeanName = filterConfig.getInitParameter(CONFIG_BEAN_NAME_INIT_PARAM); if (configBeanName == null) { configBeanName = CacheControlConfig.DEFAULT_BEAN_ID; } applicationContext = WebApplicationContextUtils.getWebApplicationContext(filterConfig.getServletContext()); if (log.isDebugEnabled()) { log.debug("Resolving cache control config with bean name '" + configBeanName + "' from application context"); } config = applicationContext.getBean(configBeanName, CacheControlConfig.class); setLowerCaseMatch(config.isLowerCaseMatch()); uriConfigs = new ArrayList<CacheControlUriConfig>(); if (config.isDefaultsEnabled()) { log.debug("Adding default URI configurations"); uriConfigs.addAll(createDefaultUriConfigs(config)); } uriConfigs.addAll(config.getUriConfigs()); setUriConfigs(createCacheControlUriConfigBuilder().build(uriConfigs)); }
From source file:io.apiman.common.servlet.AuthenticationFilter.java
/** * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) *//* ww w .jav a 2 s . co m*/ @Override public void init(FilterConfig config) throws ServletException { // Realm String parameter = config.getInitParameter("realm"); //$NON-NLS-1$ if (parameter != null && parameter.trim().length() > 0) { realm = parameter; } else { realm = defaultRealm(); } // Signature Required parameter = config.getInitParameter("signatureRequired"); //$NON-NLS-1$ if (parameter != null && parameter.trim().length() > 0) { signatureRequired = Boolean.parseBoolean(parameter); } else { signatureRequired = defaultSignatureRequired(); } // Keystore Path parameter = config.getInitParameter("keystorePath"); //$NON-NLS-1$ if (parameter != null && parameter.trim().length() > 0) { keystorePath = parameter; } else { keystorePath = defaultKeystorePath(); } // Keystore Password parameter = config.getInitParameter("keystorePassword"); //$NON-NLS-1$ if (parameter != null && parameter.trim().length() > 0) { keystorePassword = parameter; } else { keystorePassword = defaultKeystorePassword(); } // Key alias parameter = config.getInitParameter("keyAlias"); //$NON-NLS-1$ if (parameter != null && parameter.trim().length() > 0) { keyAlias = parameter; } else { keyAlias = defaultKeyAlias(); } // Key Password parameter = config.getInitParameter("keyPassword"); //$NON-NLS-1$ if (parameter != null && parameter.trim().length() > 0) { keyPassword = parameter; } else { keyPassword = defaultKeyPassword(); } }
From source file:org.sakaiproject.tool.section.filter.RoleFilter.java
public void init(FilterConfig filterConfig) throws ServletException { if (logger.isInfoEnabled()) logger.info("Initializing sections role filter"); ac = (ApplicationContext) filterConfig.getServletContext() .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); authnBeanName = filterConfig.getInitParameter("authnServiceBean"); authzBeanName = filterConfig.getInitParameter("authzServiceBean"); contextBeanName = filterConfig.getInitParameter("contextManagementServiceBean"); authorizationFilterConfigurationBeanName = filterConfig .getInitParameter("authorizationFilterConfigurationBean"); selectSiteRedirect = filterConfig.getInitParameter("selectSiteRedirect"); }
From source file:edu.vt.middleware.servlet.filter.RequestMethodFilter.java
/** * Initialize this filter.//from w w w . ja v a 2 s . c om * * @param config <code>FilterConfig</code> */ public void init(final FilterConfig config) { final Enumeration<?> e = config.getInitParameterNames(); while (e.hasMoreElements()) { final String name = (String) e.nextElement(); final String value = config.getInitParameter(name); final StringTokenizer st = new StringTokenizer(name); final String methodName = st.nextToken(); Object[] args = null; Class<?>[] params = null; if (st.countTokens() > 0) { args = new Object[st.countTokens()]; params = new Class[st.countTokens()]; int i = 0; while (st.hasMoreTokens()) { final String token = st.nextToken(); args[i] = token; params[i++] = token.getClass(); } } try { this.servletMethods.put(methodName, ServletRequest.class.getMethod(methodName, params)); if (LOG.isDebugEnabled()) { LOG.debug("Found method " + methodName + " for ServletRequest"); } } catch (NoSuchMethodException ex) { if (LOG.isDebugEnabled()) { LOG.debug("Could not find method " + methodName + " for ServletRequest"); } } try { this.httpServletMethods.put(methodName, HttpServletRequest.class.getMethod(methodName, params)); if (LOG.isDebugEnabled()) { LOG.debug("Found method " + methodName + " for HttpServletRequest"); } } catch (NoSuchMethodException ex) { if (LOG.isDebugEnabled()) { LOG.debug("Could not find method " + methodName + " for HttpServletRequest"); } } this.arguments.put(methodName, args); this.patterns.put(methodName, Pattern.compile(value)); if (LOG.isDebugEnabled()) { if (this.arguments.get(methodName) != null) { if (LOG.isDebugEnabled()) { LOG.debug("Stored method name = " + methodName + ", pattern = " + value + " with these arguments " + Arrays.asList((Object[]) this.arguments.get(methodName))); } } else { if (LOG.isDebugEnabled()) { LOG.debug("Stored method name = " + methodName + ", pattern = " + value + " with no arguments"); } } } } }