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.unitime.timetable.filter.QueryLogFilter.java
public void init(FilterConfig cfg) throws ServletException { iSaver = new Saver(); iSaver.start();/*from w w w. jav a 2 s . c o m*/ String exclude = cfg.getInitParameter("exclude"); if (exclude != null) { for (String x : exclude.split(",")) iExclude.add(x); } iGson = new GsonBuilder().create(); }
From source file:com.pliu.azuremgmtsdk.BasicFilter.java
public void init(FilterConfig config) throws ServletException { clientId = config.getInitParameter("client_id"); authority = config.getServletContext().getInitParameter("authority"); appTenant = config.getServletContext().getInitParameter("tenant"); clientSecret = config.getInitParameter("secret_key"); }
From source file:org.infoglue.deliver.applications.filters.PortalParameterFilter.java
public void init(FilterConfig filterConfig) throws ServletException { String portalEnabled = CmsPropertyHandler.getEnablePortal(); active = ((active) && (portalEnabled != null) && portalEnabled.equalsIgnoreCase("true")); this.filterConfig = filterConfig; String filterURIs = filterConfig.getInitParameter(FILTER_URIS_PARAMETER); uriMatcher = URIMatcher.compilePatterns(splitString(filterURIs, ","), false); log.info("PortalParameterFilter is active: " + active); }
From source file:com.example.webapp.filter.MultipartFilter.java
/** * Configure the 'maxFileSize' parameter. * /*from w w w .ja va 2 s .co m*/ * @throws ServletException If 'maxFileSize' parameter value is not numeric. * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) */ @Override 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:org.codeconsole.web.analytics.AnalyticsFilter.java
/** * @see Filter#init(FilterConfig)//from ww w .j a v a2 s . c om */ public void init(FilterConfig fConfig) throws ServletException { String springConfigurationParam = fConfig.getInitParameter("spring-context-location"); if (springConfigurationParam != null) { this.springConfiguration = springConfigurationParam; } ApplicationContext context = null; try { context = new ClassPathXmlApplicationContext(springConfiguration); } catch (BeanDefinitionStoreException notfound) { System.out.println("AnalyticsFilter: Could not locate context configuration: " + springConfiguration + ". Attempting to load root Web Application Context."); context = WebApplicationContextUtils.getWebApplicationContext(fConfig.getServletContext()); } System.out.println("AnalyticsFilter: Loading bean definitions."); if (context != null) { if (context.containsBean("analyticsGateway")) { analyticsGateway = context.getBean("analyticsGateway", AnalyticsGateway.class); System.out.println("AnalyticsFilter: Gateway loaded."); } else { System.out.println( "AnalyticsFilter: Could not a bean named 'analyticsGateway'. Analytics will not be sent!"); } if (context.containsBean("userDetailsResolver")) { userDetailsResolver = context.getBean("userDetailsResolver", UserDetailsResolver.class); System.out.println("AnalyticsFilter: UserDetailsResolver loaded."); } if (context.containsBean("sourceRevisionResolver")) { sourceRevisionResolver = context.getBean("sourceRevisionResolver", SourceRevisionResolver.class); System.out.println("AnalyticsFilter: SourceRevisionResolver loaded."); } } else { System.out.println("AnalyticsFilter: Could not load root Web Application Context."); } String historySize = fConfig.getInitParameter("history-size"); if (historySize != null) { this.maxHistorySize = Integer.parseInt(historySize); } String sessionAttribute = fConfig.getInitParameter("session-attribute"); if (sessionAttribute != null) { this.sessionAttributeName = sessionAttribute; } String excluded = fConfig.getInitParameter("exclude-urls"); if (excluded != null) { String[] excludes = excluded.split("[\r\n]+"); for (String exclude : excludes) { exclude = exclude.trim(); if (!exclude.isEmpty()) excludedUrlPatterns.add(Pattern.compile(exclude)); } } String excludedParms = fConfig.getInitParameter("exclude-params"); if (excludedParms != null) { String[] paramExcludes = excludedParms.split("[\r\n]+"); for (String exclude : paramExcludes) { exclude = exclude.trim(); if (!exclude.isEmpty()) excludedParamPatterns.add(Pattern.compile(exclude)); } } }
From source file:ar.sgt.resolver.filter.ResolverFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { log.debug("Initializing filter"); this.resolverConfig = (ResolverConfig) filterConfig.getServletContext() .getAttribute(ContextLoader.RESOLVER_CONFIG); this.appendBackSlash = filterConfig.getInitParameter("append_backslash") != null ? Boolean.parseBoolean(filterConfig.getInitParameter("append_backslash")) : true;//from w ww . j a v a 2 s .c o m this.filterConfig = filterConfig; if (filterConfig.getInitParameter("exclude-path") != null) { this.excludePath = new HashSet<String>( Arrays.asList(StringUtils.split(filterConfig.getInitParameter("exclude-path"), ","))); } else { this.excludePath = null; } }
From source file:org.auraframework.http.AuraContextFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { String dirConfig = filterConfig.getInitParameter("componentDir"); if (!AuraTextUtil.isNullEmptyOrWhitespace(dirConfig)) { componentDir = filterConfig.getServletContext().getRealPath("/") + dirConfig; }/*from ww w . j a v a2 s. co m*/ }
From source file:com.threewks.analytics.filter.HttpRequestResponseTrackingFilter.java
/** * <p>/*from w w w. j ava2s .c o m*/ * Get the API key to use to connect to the analytics service. The follow strategies are used (in order): * <ol> * <li>Look for a single 'apiKey' init param.</li> * <li>Look for an init param called 'environmentProperty'. Using the value of this property look for a system property with the same name. Finally, look for an init param called * '<environment>_apiKey'. Note that value of this property is case sensitive. If no system property can be found the environment is assumed to be 'dev'.</li> * </ol> * </p> * * <p> * To implement different logic to obtain the apiKey (eg: from a database) subclass this filter and override this method. * </p> * * @param config the {@link FilterConfig} to get the parameters from. * @return the API key to use to connect to the analytics service. * @throws ServletException if no API key could be obtained. */ public String getApiKey(FilterConfig config) throws ServletException { /* * Option 1 - single 'apiKey' init param */ String apiKey = config.getInitParameter(API_KEY_PARAM); if (apiKey != null) { return apiKey; } /* * Option 2 - environment specific API key combined with an environment system property. */ String environmentProperty = getMandatoryInitParam(config, ENVIRONMENT_PROPERTY); String environment = System.getProperty(environmentProperty, DEFAULT_ENVIRONMENT); return getMandatoryInitParam(config, String.format("%s_%s", environment, API_KEY_PARAM)); }
From source file:org.teiid.olingo.web.ODataFilter.java
@Override public void init(FilterConfig config) throws ServletException { // handle proxy-uri in the case of cloud environments String proxyURI = config.getInitParameter("proxy-base-uri"); //$NON-NLS-1$ if (proxyURI != null && proxyURI.startsWith("${") && proxyURI.endsWith("}")) { //$NON-NLS-1$ //$NON-NLS-2$ proxyURI = proxyURI.substring(2, proxyURI.length() - 1); proxyURI = System.getProperty(proxyURI); }//from w w w . j a v a2 s. c om if (proxyURI != null) { this.proxyBaseURI = proxyURI; } Properties props = new Properties(); Enumeration<String> names = config.getServletContext().getInitParameterNames(); while (names.hasMoreElements()) { String name = names.nextElement(); props.setProperty(name, config.getServletContext().getInitParameter(name)); } names = config.getInitParameterNames(); while (names.hasMoreElements()) { String name = names.nextElement(); props.setProperty(name, config.getInitParameter(name)); } this.initProperties = props; }
From source file:org.openmrs.module.personalhr.web.filter.PhrSecurityFilter.java
/** * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) */// www. j a v a 2 s.c o m @Override public void init(final FilterConfig config) throws ServletException { this.config = config; this.excludeURL = config.getInitParameter("excludeURL"); this.excludedURLs = this.excludeURL.split(","); this.loginForm = config.getInitParameter("loginForm"); }