public void init(FilterConfig filterConfig) throws ServletException { this.encoding = filterConfig.getInitParameter("encoding"); String fe = filterConfig.getInitParameter("forceEncoding"); if (StringUtils.isNotBlank(fe)) { this.forceEncoding = Boolean.parseBoolean(fe); } }
@Override public void init(FilterConfig fc) throws ServletException { log.info("DispatcherFilter starting ..."); log.info("java.version = {}", JdkUtils.JAVA_VERSION); log.info("webmvc.version = {}", WebConfig.VERSION); log.info("user.dir = {}", System.getProperty("user.dir")); log.info("java.io.tmpdir = {}", System.getProperty("java.io.tmpdir")); log.info("user.timezone = {}", System.getProperty("user.timezone")); log.info("file.encoding = {}", System.getProperty("file.encoding")); try { long ts = System.currentTimeMillis(); ServletContext sc = fc.getServletContext(); String configLocation = fc.getInitParameter("configLocation"); WebInitializer.initialize(sc, configLocation); httpEncoding = WebConfig.getHttpEncoding(); httpCache = WebConfig.isHttpCache(); router = WebConfig.getRouter(); bypassRequestUrls = WebConfig.getBypassRequestUrls(); corsRequestProcessor = WebConfig.getCORSRequestProcessor(); resultHandlerResolver = WebConfig.getResultHandlerResolver(); fileUploadResolver = WebConfig.getFileUploadResolver(); exceptionHandler = WebConfig.getExceptionHandler(); log.info("web.root = {}", WebConfig.getWebroot()); log.info("web.development = {}", WebConfig.isDevelopment()); log.info("web.upload.dir = {}", WebConfig.getUploaddir()); log.info("web.urls.router = {}", router.getClass().getName()); log.info( "web.urls.bypass = {}", (bypassRequestUrls == null) ? null : bypassRequestUrls.getClass().getName()); log.info( "web.urls.cors = {}", (corsRequestProcessor == null) ? null : corsRequestProcessor.getClass().getName()); for (Plugin plugin : WebConfig.getPlugins()) { log.info("load plugin: {}", plugin.getClass().getName()); plugin.initialize(); } for (Interceptor interceptor : WebConfig.getInterceptors()) { log.info("load interceptor: {}", interceptor.getClass().getName()); interceptor.initialize(); } log.info( "DispatcherFilter initialize successfully, Time elapsed: {} ms.", System.currentTimeMillis() - ts); } catch (Exception e) { log.error("Failed to initialize DispatcherFilter", e); log.error("*************************************"); log.error(" System.exit(1) "); log.error("*************************************"); System.exit(1); } }
private Map<String, String> filterConfigToMap(FilterConfig filterConfig) { Map<String, String> configMap = new HashMap<String, String>(); Enumeration params = filterConfig.getInitParameterNames(); while (params.hasMoreElements()) { String paramName = (String) params.nextElement(); configMap.put(paramName, filterConfig.getInitParameter(paramName)); } return configMap; }
public void init(FilterConfig config) throws ServletException { this.config = config; this.encoding = config.getServletContext().getInitParameter("encoding"); String[] list = config.getServletContext().getInitParameter("decorators").split(","); this.decorators = DecoratorRepository.initialize(list, config.getServletContext()); String matchPattern = config.getInitParameter("match-pattern"); pattern = Pattern.compile(matchPattern); }
public void init(FilterConfig filterConfig) throws ServletException { final String expiresOffsetString = filterConfig.getInitParameter(EXPIRES_OFFSET_YEARS_PARAMETER_NAME); if (expiresOffsetString != null) { expiresOffsetYears = Integer.parseInt(expiresOffsetString); } final String userAgentExcludeRegexpString = filterConfig.getInitParameter(USER_AGENT_EXCLUDE_REGEXP_PARAMETER_NAME); if (userAgentExcludeRegexpString != null) { userAgentExclude = Pattern.compile(userAgentExcludeRegexpString); } }
public void init(FilterConfig config) throws ServletException { this.context = config.getServletContext(); // get input and output dirs this.inDirName = config.getInitParameter(P_INPUT_DIRNAME); if (this.inDirName == null) this.inDirName = DEFAULT_INPUT_DIRNAME; this.outDirName = config.getInitParameter(P_OUTPUT_DIRNAME); if (this.outDirName == null) this.outDirName = DEFAULT_OUTPUT_DIRNAME; if (ZimbraLog.webclient.isDebugEnabled()) { ZimbraLog.webclient.debug("### indir: " + this.inDirName); ZimbraLog.webclient.debug("### outdir: " + this.outDirName); } }
@Override public void init(FilterConfig filterConfig) throws ServletException { provider = OAuthUtils.initiateServletContext( filterConfig.getServletContext(), OAUTH_RS_PROVIDER_CLASS, OAuth2RSProvider.class); super.init(filterConfig); }
/** {@inheritDoc} */ @Override public void init(final FilterConfig filterConfig) throws ServletException { servletContext = filterConfig.getServletContext(); templateEngine = new TemplateEngine(); templateEngine.setTemplateResolver(createTemplateResolver()); templateEngine.setDialect(new WuicDialect()); }
/** * init * * @param config FilterConfig * @throws ServletException */ public void init(FilterConfig config) throws ServletException { String startLog = config.getInitParameter("startLog"); if (!StrUtil.isEmpty(startLog)) { if (startLog.equalsIgnoreCase("TRUE")) { isStartLog = true; } } }
public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; String configFile = System.getProperty("jboss.server.config.dir") + "/picketlink.xml"; if (new File(configFile).exists()) this.configFile = configFile; this.servletContext = filterConfig.getServletContext(); processConfiguration(filterConfig); }
public void init(FilterConfig filterConfig) throws ServletException { super.init(filterConfig); String excludedExtensionsParam = filterConfig.getInitParameter("excludedExtensions"); if (excludedExtensionsParam != null) { StringTokenizer tokenizer = new StringTokenizer(excludedExtensionsParam, ",", false); while (tokenizer.hasMoreTokens()) { excludedExtensions.add(tokenizer.nextToken().trim()); } } }
@Override public void init(FilterConfig filterConfig) throws ServletException { final ServletContext servletContext = filterConfig.getServletContext(); final ServicePorts ports = ServletContextHelper.getInstance(servletContext).getServerPorts(); config = new FilterConfigHelper(filterConfig).getFilterConfig(DEFAULT_CONFIG); LOG.info("Initializing filter using config " + config); handlerFactory = new VersioningHandlerFactory(ports); configurationManager = ServletContextHelper.getInstance(filterConfig.getServletContext()) .getPowerApiContext() .configurationService(); configurationManager.subscribeTo("system-model.cfg.xml", handlerFactory, SystemModel.class); URL xsdURL = getClass().getResource("/META-INF/schema/config/versioning-configuration.xsd"); configurationManager.subscribeTo( config, xsdURL, handlerFactory, ServiceVersionMappingList.class); }
@Override public void init(FilterConfig filterConfig) throws ServletException { super.init(filterConfig); int reloadTime = readInt(filterConfig.getInitParameter(INIT_PARAM_RELOAD_TIME), 0); this.resetTime = readInt(filterConfig.getInitParameter(INIT_PARAM_RESET_TIME), resetTime); lastResetTime = new Date().getTime(); if (cache == null) // fixme: checking for letting the unit test happy but nothing. cache = buildCache(reloadTime); LOGGER.debug( "Cache Filter initialized with: {}:{},\n{}:{}", INIT_PARAM_RELOAD_TIME, String.valueOf(reloadTime), INIT_PARAM_RESET_TIME, String.valueOf(resetTime)); }
public void init(FilterConfig filterConfig) { this.config = filterConfig; this.encoding = config.getInitParameter("encoding"); if (encoding == null || encoding.length() == 0) { encoding = "GBK"; } expiresMap = new HashMap(); Enumeration names = config.getInitParameterNames(); while (names.hasMoreElements()) { String paramName = (String) names.nextElement(); if (!"encoding".equals(paramName)) { String paramValue = config.getInitParameter(paramName); try { Integer expires = Integer.valueOf(config.getInitParameter(paramName)); expiresMap.put(paramName, expires); } catch (Exception ex) { // LogUtil.logError( "Filter."+paramValue+"="+paramValue); } } } }
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { String userAddy = request.getRemoteHost(); filterConf.getServletContext().log("Vistor User IP: " + userAddy); /* // Get the IP address of client machine. String ipAddress = request.getRemoteAddr(); // Log the IP address and current timestamp. System.out.println("IP "+ ipAddress + ", Time " + new Date().toString()); */ chain.doFilter(request, response); }
protected void handleHostIncludeExcludesIfNeeded(@Nonnull FilterConfig filterConfig) { final String includeHosts = filterConfig.getInitParameter(INCLUDES_HOSTS); final String excludeHosts = filterConfig.getInitParameter(EXCLUDES_HOSTS); if (!isEmpty(includeHosts) || !isEmpty(excludeHosts)) { final ServletHealthInterceptor originalInterceptor = getInterceptor(); final AllowedHostsServletHealthInterceptor newInterceptor = new AllowedHostsServletHealthInterceptor(); newInterceptor.setIncludesPattern(includeHosts); newInterceptor.setExcludesPattern(excludeHosts); setInterceptor( originalInterceptor != null ? new CombinedServletHealthInterceptor(originalInterceptor, newInterceptor) : newInterceptor); } }
/* (non-Javadoc) * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) */ @Override public void init(FilterConfig filterConfig) throws ServletException { super.init(filterConfig); int compressionMinSize = readInt( filterConfig.getInitParameter(INIT_PARAM_COMPRESSION_THRESHOLD), this.compressionThreshold); long decompressMaxBytesPerSecond = readLong( filterConfig.getInitParameter(INIT_PARAM_DECOMPRESS_MAX_BYTES_PER_SECOND), this.decompressionRate); long maxDecompressedRequestSize = readLong( filterConfig.getInitParameter(INIT_PARAM_MAX_DECOMPRESSED_REQUEST_SIZE_IN_BYTES), this.maxDecompressedRequestSizeInBytes); if (compressionMinSize > 0) { // priority given to configured value this.compressionThreshold = compressionMinSize; } if (decompressMaxBytesPerSecond > 0) { // priority given to configured value this.decompressionRate = decompressMaxBytesPerSecond; } if (maxDecompressedRequestSize > 0) { // priority given to configured value this.maxDecompressedRequestSizeInBytes = maxDecompressedRequestSize; } LOGGER.trace( "Filter initialized with: {}:{},\n{}:{}\n{}:{}", INIT_PARAM_COMPRESSION_THRESHOLD, String.valueOf(this.compressionThreshold), INIT_PARAM_DECOMPRESS_MAX_BYTES_PER_SECOND, String.valueOf(this.decompressionRate), INIT_PARAM_MAX_DECOMPRESSED_REQUEST_SIZE_IN_BYTES, String.valueOf(this.maxDecompressedRequestSizeInBytes)); }
/** * Place this filter into service. * * @param filterConfig The filter configuration object */ public void init(FilterConfig filterConfig) throws ServletException { if (filterConfig == null) { throw new IllegalArgumentException("FilterConfig must not be null."); } this.context = filterConfig.getServletContext(); final boolean templateCaching = getBooleanInit(filterConfig, PARAM_TEMPLATE_CACHING, true); this.filterConfig = filterConfig; try { pool = new TemplatesPool(templateCaching); } catch (Exception e) { final String message = "Could not initialize XSLT transformers pool."; logger.error(message, e); throw new ServletException(message, e); } }
public void init(FilterConfig config) throws ServletException { Log log = LogFactory.getLog(this.getClass()); log.info("PsqStoreConfigFilter: init(config) called"); String path = ""; try { URL pathUrl = config.getServletContext().getResource("/"); path = new File(config.getServletContext().getRealPath("/")).getAbsolutePath(); log.info(" protocol=" + pathUrl.getProtocol()); log.info(" path=" + path); } catch (Exception ex) { ex.printStackTrace(); } if (config.getInitParameter("derby-home") != null) { String myHome = config.getInitParameter("derby-home"); if (!myHome.startsWith("/")) { myHome = path + File.separator + myHome; } log.info("derby-home(final)=" + myHome); System.setProperty("xpsq.derby.home", myHome); if (PsqContext.getStore("derby") != null) { PsqContext.getStore("derby").initialize(); } } if (config.getInitParameter("bdb-home") != null) { String myHome = config.getInitParameter("bdb-home"); if (!myHome.startsWith("/")) { myHome = path + File.separator + myHome; } log.info("bdb-home(final)=" + myHome); System.setProperty("xpsq.bdb.home", myHome); if (PsqContext.getStore("bdb") != null) { PsqContext.getStore("bdb").initialize(); } } }
public void init(FilterConfig filterConfig) throws ServletException { WebApplicationContext springContext = WebApplicationContextUtils.getWebApplicationContext(filterConfig.getServletContext()); GrailsApplication grailsApplication = springContext.getBean(GrailsApplication.class); if (grailsApplication.equals(null)) { throw new IllegalStateException("grailsApplication not found in context"); } Map map = grailsApplication.getFlatConfig(); Object o = map.get("rundeck.security.authorization.preauthenticated.enabled"); enabled = Boolean.parseBoolean(o.toString()); rolesAttribute = (String) map.get("rundeck.security.authorization.preauthenticated.attributeName"); rolesHeader = (String) map.get("rundeck.security.authorization.preauthenticated.userRolesHeader"); userNameHeader = (String) map.get("rundeck.security.authorization.preauthenticated.userNameHeader"); }
private void processResponse( ServletRequest request, PerformanceFilterResponse response, final long startTime) { final int elapsedTime = (int) (System.currentTimeMillis() - startTime); final String outputDirectory = filterConfig .getServletContext() .getInitParameter("org.kuali.kra.perftest.REPORT_DIRECTORY"); final HttpSample httpSample = new HttpSample( (HttpServletRequest) request, response, outputDirectory, startTime, elapsedTime); Thread t = new Thread( new Runnable() { public void run() { logSample(httpSample, outputDirectory); } }); t.start(); }
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; // prepare the request no matter what - this ensures that the proper character encoding // is used before invoking the mapper (see WW-9127) DispatcherUtils du = DispatcherUtils.getInstance(); du.prepare(request, response); ServletContext servletContext = filterConfig.getServletContext(); try { request = du.wrapRequest(request, servletContext); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; LOG.error(message, e); throw new ServletException(message, e); } try { Integer count = (Integer) request.getAttribute(COUNTER); if (count == null) { count = new Integer(1); } else { count = new Integer(count.intValue() + 1); } request.setAttribute(COUNTER, count); chain.doFilter(request, response); } finally { int counterVal = ((Integer) request.getAttribute(COUNTER)).intValue(); counterVal -= 1; request.setAttribute(COUNTER, new Integer(counterVal)); cleanUp(request); } }
@Override public void init(@Nonnull FilterConfig filterConfig) throws ServletException { final String mapping = filterConfig.getInitParameter(MAPPING_INIT_ATTRIBUTE); if (mapping != null) { setMapping(mapping); } final String registryRef = filterConfig.getInitParameter(REGISTRY_REF_INIT_ATTRIBUTE); if (!isEmpty(registryRef)) { setRegistry(getBeanFor(filterConfig.getServletContext(), registryRef, JmxRegistry.class)); } final String interceptor = filterConfig.getInitParameter(INTERCEPTOR_INIT_ATTRIBUTE); if (!isEmpty(interceptor)) { setInterceptor(loadInterceptor(interceptor)); } final String interceptorRef = filterConfig.getInitParameter(INTERCEPTOR_REF_INIT_ATTRIBUTE); if (!isEmpty(interceptorRef)) { setInterceptor( getBeanFor( filterConfig.getServletContext(), interceptorRef, ServletHealthInterceptor.class)); } handleHostIncludeExcludesIfNeeded(filterConfig); init(); }
@Override public void init(FilterConfig conf) throws ServletException { if ("false".equalsIgnoreCase(conf.getInitParameter("gzip"))) { enableGZip = false; } }
protected void processConfiguration(FilterConfig filterConfig) { InputStream is; if (isNullOrEmpty(this.configFile)) { is = servletContext.getResourceAsStream(CONFIG_FILE_LOCATION); } else { try { is = new FileInputStream(this.configFile); } catch (FileNotFoundException e) { throw logger.samlIDPConfigurationError(e); } } PicketLinkType picketLinkType; String configurationProviderName = filterConfig.getInitParameter(CONFIGURATION_PROVIDER); if (configurationProviderName != null) { try { Class<?> clazz = SecurityActions.loadClass(getClass(), configurationProviderName); if (clazz == null) { throw new ClassNotFoundException(ErrorCodes.CLASS_NOT_LOADED + configurationProviderName); } this.configProvider = (SAMLConfigurationProvider) clazz.newInstance(); } catch (Exception e) { throw new RuntimeException( "Could not create configuration provider [" + configurationProviderName + "].", e); } } try { // Work on the IDP Configuration if (configProvider != null) { try { if (is == null) { // Try the older version is = servletContext.getResourceAsStream( GeneralConstants.DEPRECATED_CONFIG_FILE_LOCATION); // Additionally parse the deprecated config file if (is != null && configProvider instanceof AbstractSAMLConfigurationProvider) { ((AbstractSAMLConfigurationProvider) configProvider).setConfigFile(is); } } else { // Additionally parse the consolidated config file if (is != null && configProvider instanceof AbstractSAMLConfigurationProvider) { ((AbstractSAMLConfigurationProvider) configProvider).setConsolidatedConfigFile(is); } } picketLinkType = configProvider.getPicketLinkConfiguration(); picketLinkType.setIdpOrSP(configProvider.getSPConfiguration()); } catch (ProcessingException e) { throw logger.samlSPConfigurationError(e); } catch (ParsingException e) { throw logger.samlSPConfigurationError(e); } } else { if (is != null) { try { picketLinkType = ConfigurationUtil.getConfiguration(is); } catch (ParsingException e) { logger.trace(e); throw logger.samlSPConfigurationError(e); } } else { is = servletContext.getResourceAsStream(GeneralConstants.DEPRECATED_CONFIG_FILE_LOCATION); if (is == null) { throw logger.configurationFileMissing(configFile); } picketLinkType = new PicketLinkType(); picketLinkType.setIdpOrSP(ConfigurationUtil.getSPConfiguration(is)); } } // Close the InputStream as we no longer need it if (is != null) { try { is.close(); } catch (IOException e) { // ignore } } Boolean enableAudit = picketLinkType.isEnableAudit(); // See if we have the system property enabled if (!enableAudit) { String sysProp = SecurityActions.getSystemProperty(GeneralConstants.AUDIT_ENABLE, "NULL"); if (!"NULL".equals(sysProp)) { enableAudit = Boolean.parseBoolean(sysProp); } } if (enableAudit) { if (auditHelper == null) { String securityDomainName = PicketLinkAuditHelper.getSecurityDomainName(servletContext); auditHelper = new PicketLinkAuditHelper(securityDomainName); } } SPType spConfiguration = (SPType) picketLinkType.getIdpOrSP(); processIdPMetadata(spConfiguration); this.serviceURL = spConfiguration.getServiceURL(); this.canonicalizationMethod = spConfiguration.getCanonicalizationMethod(); this.picketLinkConfiguration = picketLinkType; this.issuerID = filterConfig.getInitParameter(ISSUER_ID); this.characterEncoding = filterConfig.getInitParameter(CHARACTER_ENCODING); this.samlHandlerChainClass = filterConfig.getInitParameter(SAML_HANDLER_CHAIN_CLASS); logger.samlSPSettingCanonicalizationMethod(canonicalizationMethod); XMLSignatureUtil.setCanonicalizationMethodType(canonicalizationMethod); try { this.initKeyProvider(); this.initializeHandlerChain(picketLinkType); } catch (Exception e) { throw new RuntimeException(e); } logger.trace("Identity Provider URL=" + getConfiguration().getIdentityURL()); } catch (Exception e) { throw new RuntimeException(e); } }
public void init(FilterConfig filterConfig) throws ServletException { this.inputFactory = XMLInputFactory.newInstance(); this.outputFactory = XMLOutputFactory.newInstance(); this.servletContext = filterConfig.getServletContext(); }
@Override public void init(FilterConfig fc) throws ServletException { Calendar c = new GregorianCalendar(); nextReportingHour = c.get(Calendar.HOUR_OF_DAY) + 1; String t = fc.getInitParameter("maxTotalSimultaneousRequests"); if (t != null) try { maxTotalSimultaneousRequests = Integer.parseInt(t); } catch (NumberFormatException e) { log.error("Bad value for parameter 'maxTotalSimultaneousRequests': '" + t + "'"); log.error("Using the default value of 10 instead"); } // t=fc.getInitParameter("maxSimultaneousRequests"); // if(t!=null) // try { // maxSimultaneousRequests=Integer.parseInt(t); // } // catch(Exception e) { // log.error("Bad value for parameter 'maxSimultaneousRequests': '"+t+"'"); // log.error("Using the default value of 3 instead"); // } contactInfo = fc.getInitParameter("contactInfo"); if (log.isDebugEnabled()) log.debug("contactInfo=" + contactInfo); addressInHeader = fc.getInitParameter("addressInHeader"); if (log.isDebugEnabled()) log.debug("addressInHeader=" + addressInHeader); String eA = fc.getInitParameter("equivalentAddresses"); if (eA != null) { // comma/blank/tab separated list of shortAddr=shortAddr // e.g. 157.55.33=157.55.32, 157.55.34=157.55.32, 157.55.35=157.55.32, 157.55.36=157.55.32, // 157.55.37=157.55.32 // or 157.55.*=157.55.0 // or 69.171.224-255=69.171.224 String first, pair, second; StringTokenizer findPairs = new StringTokenizer(eA, ",\t "); StringTokenizer findValues; while (findPairs.hasMoreTokens()) { pair = findPairs.nextToken(); findValues = new StringTokenizer(pair, "="); first = findValues.nextToken(); second = findValues.nextToken(); if (first.endsWith(".*")) { first = first.substring(0, first.indexOf(".*")); for (int i = 0; i < 256; i++) equivalentAddresses.put(first + "." + i, second); } else if (first.contains("-")) { int offset = first.lastIndexOf('.'); String base = first.substring(0, offset); String rest = first.substring(offset + 1); StringTokenizer range = new StringTokenizer(rest, "-"); int start = Integer.parseInt(range.nextToken()); int end = Integer.parseInt(range.nextToken()); for (int i = start; i < end; i++) { System.out.println( "adding " + base + "." + i + "=" + second + " to the equivalence table"); equivalentAddresses.put(base + "." + i, second); } } else equivalentAddresses.put(first, second); } } String iA = fc.getInitParameter("ignorableAddresses"); if (iA != null) { StringTokenizer st = new StringTokenizer(iA, ", "); while (st.hasMoreTokens()) ignorableAddresses.add(st.nextToken()); } }
private void initializeReloadCommandParamName(FilterConfig filterConfig) { reloadCommandParamName = filterConfig.getInitParameter(RELOAD_COMMAND_PARAM_NAME_CONFIG_NAME); if (reloadCommandParamName == null) reloadCommandParamName = DEFAULT_RELOAD_COMMAND_PARAM_NAME_VALUE; }
/** * This method initializes filter with parameter of encoding. * * @param fConfig */ public void init(FilterConfig fConfig) throws ServletException { code = fConfig.getInitParameter("encoding"); }
@Override public void init(FilterConfig filterConfig) throws ServletException { encoding = filterConfig.getInitParameter("encoding"); }