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.ambraproject.web.DummySSOFilter.java
public void init(final FilterConfig filterConfig) throws ServletException { // get params defined in web.xml casUrl = filterConfig.getInitParameter("casUrl"); ssoUrl = filterConfig.getInitParameter("ssoUrl"); wrap = "true".equalsIgnoreCase(filterConfig.getInitParameter("wrapRequest")); // look up any overrides in the ambra configuration Configuration configuration = ConfigurationStore.getInstance().getConfiguration(); String casBaseUrl = configuration.getString("ambra.services.cas.url.base"); if (casBaseUrl != null) casUrl = casBaseUrl;/*from www . j a va 2 s . c om*/ // final defaults if (ssoUrl == null) ssoUrl = "/dummy/"; enabled = configuration.getBoolean(DUMMY_SSO_CONFIG_KEY, false); if (enabled) log.info("dummy sso enabled"); else log.info("dummy sso disabled (use -D" + DUMMY_SSO_CONFIG_KEY + "=true to enable)"); }
From source file:com.paladin.mvc.URLMappingFilter.java
@Override public void init(FilterConfig cfg) throws ServletException { this.context = cfg.getServletContext(); // ? /*from w w w . j a v a2s . com*/ this.PATH_PREFIX = cfg.getInitParameter("template-path-prefix"); if (this.PATH_PREFIX == null) this.PATH_PREFIX = "/WEB-INF/templates"; else if (this.PATH_PREFIX.endsWith("/")) this.PATH_PREFIX = this.PATH_PREFIX.substring(0, this.PATH_PREFIX.length() - 1); // ? URL ??? /img/*** String ignores = cfg.getInitParameter("ignore"); if (ignores != null) for (String ig : StringUtils.split(ignores, ',')) ignoreURIs.add(ig.trim()); // ? URL ?? ? ? *.jpg ignores = cfg.getInitParameter("ignoreExts"); if (ignores != null) for (String ig : StringUtils.split(ignores, ',')) ignoreExts.add('.' + ig.trim()); // ?? String tmp = cfg.getInitParameter("domain"); if (StringUtils.isNotBlank(tmp)) rootDomain = tmp; // ?? ? ? @SuppressWarnings("unchecked") Enumeration<String> names = cfg.getInitParameterNames(); while (names.hasMoreElements()) { String name = names.nextElement(); String v = cfg.getInitParameter(name); if (v.endsWith("/")) v = v.substring(0, v.length() - 1); if ("ignore".equalsIgnoreCase(name) || "ignoreExts".equalsIgnoreCase(name)) continue; if ("default".equalsIgnoreCase(name)) default_base = PATH_PREFIX + v; else other_base.put(name, PATH_PREFIX + v); } }
From source file:com.app.framework.web.MultipartFilter.java
/** * Configure the 'maxFileSize' parameter. * * @throws ServletException If 'maxFileSize' parameter value is not numeric. * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) */// w w w . j a v a2 s . co m public void init(FilterConfig filterConfig) throws ServletException { // Configure maxFileSize. String maxFileSize = filterConfig.getInitParameter("maxFileSize"); if (maxFileSize != null) { if (!maxFileSize.matches("^\\d+$")) { throw new ServletException("MultipartFilter 'maxFileSize' is not numeric."); } this.maxFileSize = Long.parseLong(maxFileSize); } }
From source file:edu.indiana.d2i.htrc.security.JWTServletFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { // TokenVerifierConfiguration should be HOCON file stored in somewhere in the file system. String filterConfigFile = filterConfig.getInitParameter(PARAM_FILTER_CONFIG); if (filterConfigFile == null) { log.warn(// www.ja v a 2s.c om "No configuration was specified for JWTServletFilter. Using default " + DEFAULT_JWTFILTER_CONF); filterConfigFile = DEFAULT_JWTFILTER_CONF; } URL configUrl; try { if (filterConfigFile.contains(":/")) { configUrl = new URL(filterConfigFile); } else if (!filterConfigFile.startsWith("/")) { ServletContext servletContext = filterConfig.getServletContext(); configUrl = servletContext.getResource(filterConfigFile); } else { configUrl = new File(filterConfigFile).toURI().toURL(); } } catch (MalformedURLException e) { throw new ServletException("Could not load JWTFilter configuration from: " + filterConfigFile, e); } JWTServletFilterConfiguration configuration = new JWTServletFilterConfiguration(configUrl); try { this.tokenVerifier = new TokenVerifier(configuration.getTokenVerifierConfiguration()); } catch (InvalidAlgorithmParameterException e) { throw new ServletException("Could not initialize token verifier.", e); } // We map following JWT claims to HTRC specific request headers by default claimToHeaderMappings.put("email", "htrc-user-email"); claimToHeaderMappings.put("sub", "htrc-user-id"); claimToHeaderMappings.put("iss", "htrc-token-issuer"); // Any extra claim mappings are loaded from configuration file claimToHeaderMappings.putAll(configuration.getClaimMappings()); }
From source file:com.mirantis.cachemod.filter.CacheConfiguration.java
private Object initClass(FilterConfig config, String classInitParam, Class interfaceClass) { String className = config.getInitParameter(classInitParam); if (className != null) { try {//from w w w . j av a2 s .c o m ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { classLoader = this.getClass().getClassLoader(); } Class clazz = classLoader.loadClass(className); if (!interfaceClass.isAssignableFrom(clazz)) { log.error("CacheFilter: Specified class '" + className + "' does not implement" + interfaceClass.getName()); return null; } else { return clazz.newInstance(); } } catch (ClassNotFoundException e) { log.error("CacheFilter: Class '" + className + "' not found.", e); } catch (InstantiationException e) { log.error("CacheFilter: Class '" + className + "' could not be instantiated because it is not a concrete class.", e); } catch (IllegalAccessException e) { log.error("CacheFilter: Class '" + className + "' could not be instantiated because it is not public.", e); } } return null; }
From source file:com.scooterframework.web.controller.ScooterRequestFilter.java
/** * Place this filter into service.// w w w .j a v a 2 s . co m * * @param filterConfig The filter configuration object */ public void init(FilterConfig filterConfig) throws ServletException { this.excludedPaths = filterConfig.getInitParameter("excluded_paths"); this.encoding = filterConfig.getInitParameter("encoding"); otherInit(); }
From source file:de.jaxenter.eesummit.caroline.gui.filter.LogFilter.java
@Override public void init(FilterConfig config) throws ServletException { dropUrls = new ArrayList<String>(); int idx = 0;//from ww w . ja v a2 s. c o m String dropUrlParam; while ((dropUrlParam = config.getInitParameter("dropurl." + idx)) != null) { logger.info("adding dropUrl " + idx + ": " + dropUrlParam); dropUrls.add(dropUrlParam); idx++; } String ndcParam = config.getInitParameter("ndc"); ndcEnabled = false; if (ndcParam != null) { logger.info("NDC enabled: " + ndcParam); ndcEnabled = true; ndcSession = ndcParam.indexOf("session") != -1; ndcAddress = ndcParam.indexOf("address") != -1; } }
From source file:org.nuxeo.ecm.webengine.gwt.dev.NuxeoLauncher.java
protected NuxeoApp createApplication(FilterConfig config) throws ServletException { URL cfg = getConfiguration(); String homeParam = config.getInitParameter("home"); String hostParam = config.getInitParameter("host"); String portParam = config.getInitParameter("port"); String profileParam = config.getInitParameter("profile"); String updatePolicy = config.getInitParameter("updatePolicy"); String offline = config.getInitParameter("offline"); String isolated = config.getInitParameter("isolated"); boolean isIsolated = Boolean.parseBoolean(isolated); String redirectPrefix = config.getInitParameter("redirectPrefix"); String redirectTrace = config.getInitParameter("redirectTrace"); String redirectTraceContent = config.getInitParameter("redirectTraceContent"); File home = null;//from w w w . j a va 2 s . co m String host = hostParam == null ? "localhost" : null; int port = portParam == null ? 8081 : Integer.parseInt(portParam); String profile = profileParam == null ? NuxeoApp.CORE_SERVER_541_SNAPSHOT : profileParam; if (homeParam == null) { String userDir = System.getProperty("user.home"); String sep = userDir.endsWith("/") ? "" : "/"; home = new File(userDir + sep + ".nxserver-gwt"); } else { homeParam = StringUtils.expandVars(homeParam, System.getProperties()); home = new File(homeParam); } // start redirect service redirect = new RedirectService(host, port); if (redirectPrefix != null) { redirect.setRedirectPrefix(redirectPrefix); } if (redirectTrace != null && Boolean.parseBoolean(redirectTrace)) { redirect.setTrace(true); } if (redirectTraceContent != null && Boolean.parseBoolean(redirectTraceContent)) { redirect.setTrace(true); redirect.setTraceContent(true); } System.out.println("+---------------------------------------------------------"); System.out.println("| Nuxeo Server Profile: " + (profile == null ? "custom" : profile)); System.out.println("| Home Directory: " + home); System.out.println("| HTTP server at: " + host + ":" + port); System.out.println("| Use cache: " + useCache() + "; Snapshot update policy: " + updatePolicy + "; offline: " + offline); System.out.println("+---------------------------------------------------------\n"); NuxeoApp.setHttpServerAddress(host, port); try { MyNuxeoApp app = new MyNuxeoApp(home, null, isIsolated); if (updatePolicy != null) { app.setUpdatePolicy(updatePolicy); } if (offline != null) { app.setOffline(Boolean.parseBoolean(offline)); } if (cfg == null) { app.build(profile, useCache()); } else { app.build(cfg, useCache()); } System.setProperty("java.naming.factory.initial", "org.nuxeo.runtime.jtajca.NamingContextFactory"); System.setProperty("java.naming.factory.url.pkgs", "org.nuxeo.runtime.jtajca"); app.start(); return app; } catch (Exception e) { throw new ServletException(e); } }
From source file:org.vosao.filter.SiteFilter.java
@Override public void init(FilterConfig config) { skipURLs = new ArrayList<String>(); for (String url : SKIP_URLS) { skipURLs.add(url);// ww w. j a v a 2s . c o m } String skipURLParam = config.getInitParameter("skipURL"); if (!StringUtils.isEmpty(skipURLParam)) { String[] urls = skipURLParam.split(","); for (String url : urls) { skipURLs.add(url); } } }
From source file:com.qualogy.qafe.gwt.server.filter.CORSFilter.java
public void init(FilterConfig filterConfig) throws ServletException { Iterator<String> iterParam = params2ResponseHeaders.keySet().iterator(); while (iterParam.hasNext()) { String param = iterParam.next(); String paramValue = filterConfig.getInitParameter(param); if (StringUtils.isNotBlank(paramValue)) { String header = params2ResponseHeaders.get(param); responseHeaders.put(header, paramValue); }/* w ww . j a v a 2s . co m*/ } }