Java Code Examples for javax.servlet.FilterConfig#getInitParameter()
The following examples show how to use
javax.servlet.FilterConfig#getInitParameter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CSRFFilter.java From Anti-CSRF-Library with Apache License 2.0 | 6 votes |
public void init(final FilterConfig filterConfig) throws ServletException { LOG.info("The CSRFFilter is inititializing"); // Check to see if an init param has been set String configFile = filterConfig.getInitParameter(Constants.CONF_INITPARAMNAME); if(configFile == null) { configFile = "/WEB-INF/" + Constants.CONFIGNAME; LOG.info("No Filter init-param set, defaulting to loading AntiCSRF Configuration from "+configFile); } else { LOG.info("AntiCSRF Configuration init-param specified. Configuration file set to "+configFile); } InputStream inputStream = filterConfig.getServletContext().getResourceAsStream(configFile); ConfigUtil.loadConfig(inputStream); this.filterConfig = filterConfig; }
Example 2
Source File: AtlasAuthenticationFilter.java From incubator-atlas with Apache License 2.0 | 6 votes |
@Override public void initializeSecretProvider(FilterConfig filterConfig) throws ServletException { LOG.debug("AtlasAuthenticationFilter :: initializeSecretProvider {}", filterConfig); secretProvider = (SignerSecretProvider) filterConfig.getServletContext(). getAttribute(AuthenticationFilter.SIGNER_SECRET_PROVIDER_ATTRIBUTE); if (secretProvider == null) { // As tomcat cannot specify the provider object in the configuration. // It'll go into this path String configPrefix = filterConfig.getInitParameter(CONFIG_PREFIX); configPrefix = (configPrefix != null) ? configPrefix + "." : ""; try { secretProvider = AuthenticationFilter.constructSecretProvider( filterConfig.getServletContext(), super.getConfiguration(configPrefix, filterConfig), false); this.isInitializedByTomcat = true; } catch (Exception ex) { throw new ServletException(ex); } } signer = new Signer(secretProvider); }
Example 3
Source File: CorsFilter.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public void init(final FilterConfig filterConfig) throws ServletException { // Initialize defaults parseAndStore(DEFAULT_ALLOWED_ORIGINS, DEFAULT_ALLOWED_HTTP_METHODS, DEFAULT_ALLOWED_HTTP_HEADERS, DEFAULT_EXPOSED_HEADERS, DEFAULT_SUPPORTS_CREDENTIALS, DEFAULT_PREFLIGHT_MAXAGE, DEFAULT_DECORATE_REQUEST); if (filterConfig != null) { String configAllowedOrigins = filterConfig .getInitParameter(PARAM_CORS_ALLOWED_ORIGINS); String configAllowedHttpMethods = filterConfig .getInitParameter(PARAM_CORS_ALLOWED_METHODS); String configAllowedHttpHeaders = filterConfig .getInitParameter(PARAM_CORS_ALLOWED_HEADERS); String configExposedHeaders = filterConfig .getInitParameter(PARAM_CORS_EXPOSED_HEADERS); String configSupportsCredentials = filterConfig .getInitParameter(PARAM_CORS_SUPPORT_CREDENTIALS); String configPreflightMaxAge = filterConfig .getInitParameter(PARAM_CORS_PREFLIGHT_MAXAGE); String configDecorateRequest = filterConfig .getInitParameter(PARAM_CORS_REQUEST_DECORATE); parseAndStore(configAllowedOrigins, configAllowedHttpMethods, configAllowedHttpHeaders, configExposedHeaders, configSupportsCredentials, configPreflightMaxAge, configDecorateRequest); } }
Example 4
Source File: SimonServletFilterUtils.java From javasimon with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void injectSimonPrefixIntoMonitorSource(FilterConfig filterConfig, MonitorSource<HttpServletRequest, Stopwatch> stopwatchSource) { String simonPrefix = filterConfig.getInitParameter(SimonServletFilter.INIT_PARAM_PREFIX); if (simonPrefix != null) { if (stopwatchSource instanceof HttpStopwatchSource) { HttpStopwatchSource httpStopwatchSource = (HttpStopwatchSource) stopwatchSource; httpStopwatchSource.setPrefix(simonPrefix); } else { throw new IllegalArgumentException("Prefix init param is only compatible with HttpStopwatchSource"); } } }
Example 5
Source File: HttpFilter.java From cicada with MIT License | 5 votes |
public void init(final FilterConfig config) throws ServletException { final String uriConditions = config.getInitParameter("uriConditions"); final String uriNotMatchConditions = config.getInitParameter("uriNotMatchConditions"); fillList(uriConditionRegexList, uriConditions); fillList(uriNotMatchConditionsRegexList, uriNotMatchConditions); }
Example 6
Source File: RequestContextFilter.java From logging-log4j-audit with Apache License 2.0 | 5 votes |
/** * @param filterConfig */ @Override public void init(FilterConfig filterConfig) { if (requestContextClass != null) { mappings = new RequestContextMappings(requestContextClass); } else { String requestContextClassName = filterConfig.getInitParameter("requestContextClass"); if (requestContextClassName == null) { logger.error("No RequestContext class name was provided"); throw new IllegalArgumentException("No RequestContext class name provided"); } mappings = new RequestContextMappings(requestContextClassName); } }
Example 7
Source File: ResourceFilter.java From dubbox with Apache License 2.0 | 5 votes |
public void init(FilterConfig filterConfig) throws ServletException { String config = filterConfig.getInitParameter("resources"); if (config != null && config.length() > 0) { String[] configs = Constants.COMMA_SPLIT_PATTERN.split(config); for (String c : configs) { if (c != null && c.length() > 0) { c = c.replace('\\', '/'); if (c.endsWith("/")) { c = c.substring(0, c.length() - 1); } resources.add(c); } } } }
Example 8
Source File: StaticAssetCacheFilter.java From alfresco-core with GNU Lesser General Public License v3.0 | 5 votes |
public void init(FilterConfig config) throws ServletException { String expireParam = config.getInitParameter("expires"); if (expireParam != null) { this.expire = Long.parseLong(expireParam) * DAY_S; } }
Example 9
Source File: EncodingFilter.java From hasting with MIT License | 5 votes |
@Override public void init(FilterConfig config) throws ServletException { String encoding = config.getInitParameter("encoding"); if(encoding!=null){ Charset charset = Charset.forName(encoding); if(charset==null){ throw new RuntimeException("not support encoding:"+encoding); } this.characterEncoding = encoding; } logger.info("set servlet encoding:"+this.characterEncoding); }
Example 10
Source File: CookieScopeServletFilter.java From knox with Apache License 2.0 | 4 votes |
@Override public void init( FilterConfig filterConfig ) throws ServletException { super.init( filterConfig ); gatewayPath = filterConfig.getInitParameter("gateway.path"); topologyName = filterConfig.getInitParameter("topologyName"); }
Example 11
Source File: SecurityFilter.java From sso-oauth2 with Apache License 2.0 | 4 votes |
@Override public void init(FilterConfig filterConfig) throws ServletException { ignorePattern = filterConfig.getInitParameter("ignorePattern"); }
Example 12
Source File: UrlAclFilter.java From ralasafe with MIT License | 4 votes |
public void init(FilterConfig arg0) throws ServletException { denyPage = arg0.getInitParameter("denyPage"); loginPage = arg0.getInitParameter("loginPage"); }
Example 13
Source File: SetHeaderFilter.java From quarkus-http with Apache License 2.0 | 4 votes |
@Override public void init(final FilterConfig filterConfig) throws ServletException { header = filterConfig.getInitParameter("header"); value = filterConfig.getInitParameter("value"); }
Example 14
Source File: ResponseHeaderFilter.java From sakai with Educational Community License v2.0 | 4 votes |
@SuppressWarnings("unchecked") public void init(FilterConfig filterConfig) throws ServletException { String webappName = filterConfig.getServletContext().getServletContextName(); // storing the header information in a local map for (Enumeration<String> paramNames = filterConfig.getInitParameterNames(); paramNames.hasMoreElements(); ) { String paramName = paramNames.nextElement(); String paramValue = filterConfig.getInitParameter(paramName); if (paramName != null && paramValue != null) { this.headerMap.put(paramName, paramValue); } } // adding the configured ones from sakai config ServerConfigurationService serverConfigurationService = org.sakaiproject.component.cover.ServerConfigurationService.getInstance(); if (serverConfigurationService != null) { String[] headerStrings = serverConfigurationService.getStrings("response.headers"); if (headerStrings != null) { for (String headerString : headerStrings) { if (headerString != null && ! "".equals(headerString)) { int loc = headerString.indexOf("::"); if (loc <= 0) { log.warn("Invalid header string in sakai config (must contain '::', e.g. key::value): " + headerString); continue; } String name = headerString.substring(0, loc); if (name == null || "".equals(name)) { log.warn("Invalid header string in sakai config (name must not be empty): " + headerString); continue; } String value = null; if (headerString.length() > loc+2) { value = headerString.substring(loc+2); } addHeader(name, value); if (value == null) { log.info("Removing header ("+name+") from all responses for current webapp: " + webappName); } else { log.info("Adding header ("+name+" -> "+value+") to all responses for current webapp: " + webappName); } } } } } log.info("INIT: for webapp " + webappName); }
Example 15
Source File: XssFilter.java From Lottery with GNU General Public License v2.0 | 4 votes |
public void init(FilterConfig filterConfig) throws ServletException { this.filterChar=filterConfig.getInitParameter("FilterChar"); this.replaceChar=filterConfig.getInitParameter("ReplaceChar"); this.splitChar=filterConfig.getInitParameter("SplitChar"); this.filterConfig = filterConfig; }
Example 16
Source File: SingleSignOutFilter.java From MaxKey with Apache License 2.0 | 4 votes |
public void init(FilterConfig config) throws ServletException { this.singleSignOutEndpoint=config.getInitParameter("singleSignOutEndpoint"); log.debug(" init."); }
Example 17
Source File: RequestLoggingFilter.java From lastaflute with Apache License 2.0 | 4 votes |
protected void setupSubRequestUrlPatternUrlPattern(FilterConfig filterConfig) { final String pattern = filterConfig.getInitParameter("subRequestUrlPattern"); if (pattern != null && pattern.trim().length() > 0) { this.subRequestUrlPattern = Pattern.compile(pattern); } }
Example 18
Source File: AuthenticationFilter.java From apiman with Apache License 2.0 | 4 votes |
/** * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) */ @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(); } }
Example 19
Source File: AWSXRayServletFilter.java From aws-xray-sdk-java with Apache License 2.0 | 4 votes |
/** * * * @param config * the filter configuration. There are various init-params which may be passed on initialization. The values in init-params * will create segment naming strategies which override those passed in constructors. * * <ul> * * <li> * <b>fixedName</b> A String value used as the fixedName parameter for a created * {@link com.amazonaws.xray.strategy.FixedSegmentNamingStrategy}. Used only if the {@code dynamicNamingFallbackName} * init-param is not set. * </li> * * <li> * <b>dynamicNamingFallbackName</b> A String value used as the fallbackName parameter for a created * {@link com.amazonaws.xray.strategy.DynamicSegmentNamingStrategy}. * </li> * * <li> * <b>dynamicNamingRecognizedHosts</b> A String value used as the recognizedHosts parameter for a created * {@link com.amazonaws.xray.strategy.DynamicSegmentNamingStrategy}. * </li> * * </ul> * * @throws ServletException * when a segment naming strategy is not provided in constructor arguments nor in init-params. */ @Override public void init(FilterConfig config) throws ServletException { String fixedName = config.getInitParameter("fixedName"); String dynamicNamingFallbackName = config.getInitParameter("dynamicNamingFallbackName"); String dynamicNamingRecognizedHosts = config.getInitParameter("dynamicNamingRecognizedHosts"); if (StringValidator.isNotNullOrBlank(dynamicNamingFallbackName)) { if (StringValidator.isNotNullOrBlank(dynamicNamingRecognizedHosts)) { segmentNamingStrategy = new DynamicSegmentNamingStrategy(dynamicNamingFallbackName, dynamicNamingRecognizedHosts); } else { segmentNamingStrategy = new DynamicSegmentNamingStrategy(dynamicNamingFallbackName); } } else if (StringValidator.isNotNullOrBlank(fixedName)) { segmentNamingStrategy = new FixedSegmentNamingStrategy(fixedName); } else if (null == segmentNamingStrategy) { throw new ServletException( "The AWSXRayServletFilter requires either a fixedName init-param or an instance of SegmentNamingStrategy. " + "Add an init-param tag to the AWSXRayServletFilter's declaration in web.xml, using param-name: 'fixedName'. " + "Alternatively, pass an instance of SegmentNamingStrategy to the AWSXRayServletFilter constructor."); } }
Example 20
Source File: AuthenticationFilter.java From hadoop with Apache License 2.0 | 3 votes |
/** * 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}. * <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; }