private static Key getPublicKey(String certificatePath, FilterConfig filterConfig) throws ServletException { Certificate certificate = null; InputStream is = null; try { if (certificatePath != null) certificatePath = certificatePath.replace('\\', '/'); certificatePath = getCertificatePath(certificatePath); File certFile = new File(certificatePath); if (certFile.isAbsolute()) is = new FileInputStream(certificatePath); else is = filterConfig.getServletContext().getResourceAsStream(EMBEDDED_CERT_LOC); BufferedInputStream bufferedInputStream = new BufferedInputStream(is); CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); while (bufferedInputStream.available() > 0) { certificate = certificateFactory.generateCertificate(bufferedInputStream); } } catch (FileNotFoundException fnfe) { throw new ServletException("File not found " + certificatePath); } catch (Throwable t) { throw new ServletException("Error while retrieving public key from certificate"); } finally { if (is != null) { try { is.close(); } catch (Exception e) { // Ignore exception silently here } } } return certificate.getPublicKey(); }
/** @see javax.servlet.Filter#init(javax.servlet.FilterConfig) */ public void init(FilterConfig filterConfig) throws ServletException { tempdir = (File) filterConfig.getServletContext().getAttribute("javax.servlet.context.tempdir"); _deleteFiles = "true".equals(filterConfig.getInitParameter("deleteFiles")); String fileOutputBuffer = filterConfig.getInitParameter("fileOutputBuffer"); if (fileOutputBuffer != null) _fileOutputBuffer = Integer.parseInt(fileOutputBuffer); _context = filterConfig.getServletContext(); }
public void init(FilterConfig config) throws ServletException { this.config = config; String value = null; try { value = config.getInitParameter("debug"); this.debug = Integer.parseInt(value); } catch (Throwable localThrowable) { } try { value = config.getInitParameter("expires"); if (StringUtil.isEmpty(value)) { value = "0"; } this.expires = Long.valueOf(value); } catch (NumberFormatException e) { this.expires = null; config .getServletContext() .log("Invalid format for expires initParam; expected integer (seconds)"); } catch (Throwable localThrowable1) { } if (this.debug > 0) config .getServletContext() .log("SSIFilter.init() SSI invoker started with 'debug'=" + this.debug); }
@Override public void init(FilterConfig fc) { super.init(fc); this.filterConfig = fc; containerTweaks = new ContainerTweaks(); Config config = new Config(fc); // DefaultFactory defaultFactory = new DefaultFactory(config); Grails5535Factory defaultFactory = new Grails5535Factory(config); // TODO revert once Sitemesh bug is fixed fc.getServletContext().setAttribute(FACTORY_SERVLET_CONTEXT_ATTRIBUTE, defaultFactory); defaultFactory.refresh(); FactoryHolder.setFactory(defaultFactory); contentProcessor = new PageParser2ContentProcessor(defaultFactory); decoratorMapper = defaultFactory.getDecoratorMapper(); applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(fc.getServletContext()); layoutViewResolver = WebUtils.lookupViewResolver(applicationContext); final GrailsApplication grailsApplication = GrailsWebUtil.lookupApplication(fc.getServletContext()); String encoding = (String) grailsApplication.getFlatConfig().get(CONFIG_OPTION_GSP_ENCODING); if (encoding != null) { defaultEncoding = encoding; } Map<String, PersistenceContextInterceptor> interceptors = applicationContext.getBeansOfType(PersistenceContextInterceptor.class); if (!interceptors.isEmpty()) { persistenceInterceptor = interceptors.values().iterator().next(); } }
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); }
/** * Processes a single redirection rule that matched the request URI. If this method returns true, * the request should be considered handled. * * @param request: HttpServletRequest object for this request. * @param response: HttpServletResponse object for this request. * @param rule: The rule that matched the request URI. * @param targetURL: The preprocessed target URL. * @return true if the rule action has been recognised, false otherwise. If the rule action has * been recognised but the handling fails, an exception will be thrown. * @throws ServletException * @throws IOException */ protected boolean processRule( HttpServletRequest request, HttpServletResponse response, RedirectRule rule, String targetURL) throws ServletException, IOException { String finalURL = getFinalURL(request, response, rule, targetURL); if (rule instanceof RedirectAction) { RedirectAction redirectRule = (RedirectAction) rule; if (redirectRule.cache != null) { response.addHeader("Cache-Control", redirectRule.cache); } if (redirectRule.permanent == true) { response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response.addHeader("Location", finalURL); } else { response.sendRedirect(finalURL); } if (logRedirects == true) { filterConfig .getServletContext() .log( filterName + ": " + "Redirected '" + getRequestURI(request) + "' to '" + finalURL + "'"); } return true; } else if (rule instanceof ForwardAction) { RequestDispatcher reqDisp = request.getRequestDispatcher(targetURL); reqDisp.forward(request, response); if (logRedirects == true) { filterConfig .getServletContext() .log( filterName + ": " + "Forwarded '" + getRequestURI(request) + "' to '" + targetURL + "'"); } return true; } return false; }
public void init(FilterConfig config) throws ServletException { String access = config.getInitParameter("jspDirectAccess"); if (StringUtil.isNotBlank(access)) { jspDirectAccess = Boolean.valueOf(access); } String routesPath = config.getInitParameter("routes"); if (StringUtil.isNotEmpty(routesPath)) { String realRoutesPath = config.getServletContext().getRealPath(routesPath); if (realRoutesPath != null) { routes = new File(realRoutesPath); } InputStream routesStream = config.getServletContext().getResourceAsStream(routesPath); try { Routes.load(routesStream); } finally { InputStreamUtil.close(routesStream); } lastLoaded = System.currentTimeMillis(); } String interval = config.getInitParameter("checkInterval"); if (StringUtil.isNotEmpty(interval)) { checkInterval = LongConversionUtil.toLong(interval); } if (checkInterval == null || checkInterval < 0) { checkInterval = -1L; } String contextSensitiveParam = config.getInitParameter("contextSensitive"); if (StringUtil.isNotBlank(contextSensitiveParam)) { contextSensitive = Boolean.valueOf(contextSensitiveParam); } if (contextSensitive) { try { Method getContextPath = ReflectionUtil.getMethod(ServletContext.class, "getContextPath"); UrlRewriter.contextPath = (String) MethodUtil.invoke(getContextPath, config.getServletContext(), null); } catch (NoSuchMethodRuntimeException e) { UrlRewriter.contextPath = config.getServletContext().getServletContextName(); } } requestUriHeader = config.getInitParameter("requestUriHeader"); String fallThroughParam = config.getInitParameter("fallThrough"); if (StringUtil.isNotBlank(fallThroughParam)) { fallThrough = Boolean.valueOf(fallThroughParam); } }
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) { int max_priority = __DEFAULT_MAX_PRIORITY; if (filterConfig.getInitParameter(MAX_PRIORITY_INIT_PARAM) != null) max_priority = Integer.parseInt(filterConfig.getInitParameter(MAX_PRIORITY_INIT_PARAM)); _queues = new Queue[max_priority + 1]; _listeners = new AsyncListener[_queues.length]; for (int p = 0; p < _queues.length; ++p) { _queues[p] = new ConcurrentLinkedQueue<>(); _listeners[p] = new QoSAsyncListener(p); } int maxRequests = __DEFAULT_PASSES; if (filterConfig.getInitParameter(MAX_REQUESTS_INIT_PARAM) != null) maxRequests = Integer.parseInt(filterConfig.getInitParameter(MAX_REQUESTS_INIT_PARAM)); _passes = new Semaphore(maxRequests, true); _maxRequests = maxRequests; long wait = __DEFAULT_WAIT_MS; if (filterConfig.getInitParameter(MAX_WAIT_INIT_PARAM) != null) wait = Integer.parseInt(filterConfig.getInitParameter(MAX_WAIT_INIT_PARAM)); _waitMs = wait; long suspend = __DEFAULT_TIMEOUT_MS; if (filterConfig.getInitParameter(SUSPEND_INIT_PARAM) != null) suspend = Integer.parseInt(filterConfig.getInitParameter(SUSPEND_INIT_PARAM)); _suspendMs = suspend; ServletContext context = filterConfig.getServletContext(); if (context != null && Boolean.parseBoolean(filterConfig.getInitParameter(MANAGED_ATTR_INIT_PARAM))) context.setAttribute(filterConfig.getFilterName(), this); }
@Before public void setUp() throws Exception { Context.set(Context.standaloneContext()); MockitoAnnotations.initMocks(this); when(mockUriLocatorFactory.getInstance(Mockito.anyString())).thenReturn(mockUriLocator); when(mockUriLocator.locate(Mockito.anyString())).thenReturn(WroUtil.EMPTY_STREAM); when(mockUriLocatorFactory.locate(Mockito.anyString())).thenReturn(WroUtil.EMPTY_STREAM); when(mockRequest.getAttribute(Mockito.anyString())).thenReturn(null); when(mockManagerFactory.create()).thenReturn(new BaseWroManagerFactory().create()); when(mockFilterConfig.getServletContext()).thenReturn(mockServletContext); when(mockResponse.getOutputStream()) .thenReturn(new DelegatingServletOutputStream(new ByteArrayOutputStream())); victim = new WroFilter() { @Override protected void onRuntimeException( final RuntimeException e, final HttpServletResponse response, final FilterChain chain) { throw e; } }; victim.setWroManagerFactory(mockManagerFactory); // victim.init(mockFilterConfig); }
@Override public void init(FilterConfig filterConfig) throws ServletException { provider = OAuthUtils.initiateServletContext( filterConfig.getServletContext(), OAUTH_RS_PROVIDER_CLASS, OAuth2RSProvider.class); super.init(filterConfig); }
/** * Initialises the Relocation Servlet. * * <p>This servlet accepts the following init parameters: * * <ul> * <li><code>config</code> path to the URI relocation mapping XML file (eg. * '/config/relocation.xml') * </ul> * * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig) * @param config The filter configuration. */ @Override public void init(FilterConfig config) { // get the WEB-INF directory ServletContext context = config.getServletContext(); File contextPath = new File(context.getRealPath("/")); File webinfPath = new File(contextPath, "WEB-INF"); String mapping = config.getInitParameter("config"); // Mapping not specified if (mapping == null) { LOGGER.warn("Missing 'config' init-parameter - filter will have no effect"); return; } // The mapping file does not exist File mappingFile = new File(webinfPath, mapping); if (!mappingFile.exists()) { LOGGER.warn( "'config' init-parameter points to non existing file {} - filter will have no effect", mappingFile.getAbsolutePath()); } // Store the mapping file this._mappingFile = mappingFile; }
/** * Initialize this filter. * * @param config <code>FilterConfig</code> */ public void init(final FilterConfig config) { this.context = config.getServletContext(); this.requireAttribute = Boolean.valueOf(config.getInitParameter(REQUIRE_ATTRIBUTE)).booleanValue(); if (LOG.isDebugEnabled()) { LOG.debug("requireAttribute = " + this.requireAttribute); } final Enumeration<?> e = config.getInitParameterNames(); while (e.hasMoreElements()) { final String name = (String) e.nextElement(); if (!name.equals(REQUIRE_ATTRIBUTE)) { final String value = config.getInitParameter(name); if (LOG.isDebugEnabled()) { LOG.debug("Loaded attribute name:value " + name + ":" + value); } final StringTokenizer st = new StringTokenizer(name); final String attrName = st.nextToken(); final String attrValue = st.nextToken(); this.attributes.put(attrName, Pattern.compile(attrValue)); this.redirects.put(attrName, value); if (LOG.isDebugEnabled()) { LOG.debug( "Stored attribute " + attrName + " for pattern " + attrValue + " with redirect of " + value); } } } }
@Override public void init(FilterConfig filterConfig) throws ServletException { WebApplicationContext ctx = getRequiredWebApplicationContext(filterConfig.getServletContext()); this.configurationRepository = ctx.getBean(ConfigurationRepository.class); this.users = ctx.getBean(Users.class); this.sessionHandler = ctx.getBean(SessionHandler.class); }
public void init(FilterConfig filterConfig) throws ServletException { boolean jetty_7_or_greater = "org.eclipse.jetty.servlet".equals(filterConfig.getClass().getPackage().getName()); _context = filterConfig.getServletContext(); String param = filterConfig.getInitParameter("debug"); _debug = param != null && Boolean.parseBoolean(param); if (_debug) __debug = true; param = filterConfig.getInitParameter("jetty6"); if (param == null) param = filterConfig.getInitParameter("partial"); if (param != null) _jetty6 = Boolean.parseBoolean(param); else _jetty6 = ContinuationSupport.__jetty6 && !jetty_7_or_greater; param = filterConfig.getInitParameter("faux"); if (param != null) _faux = Boolean.parseBoolean(param); else _faux = !(jetty_7_or_greater || _jetty6 || _context.getMajorVersion() >= 3); _filtered = _faux || _jetty6; if (_debug) _context.log( "ContinuationFilter " + " jetty=" + jetty_7_or_greater + " jetty6=" + _jetty6 + " faux=" + _faux + " filtered=" + _filtered + " servlet3=" + ContinuationSupport.__servlet3); _initialized = true; }
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (debug) { log("AdminFilter:doFilter()"); } boolean nastavi = true; HttpSession sesija = ((HttpServletRequest) request).getSession(false); if (sesija == null) { nastavi = false; } else { if (sesija.getAttribute("korisnik") == null) { nastavi = false; } else if (sesija.getAttribute("tipKorisnika") == null) { nastavi = false; } else if (!sesija.getAttribute("tipKorisnika").equals("admin")) { nastavi = false; } } if (!nastavi) { RequestDispatcher rd = filterConfig.getServletContext().getRequestDispatcher("/faces/prijava.xhtml"); rd.forward(request, response); } else { chain.doFilter(request, response); } }
/** * Standard way of initializing this filter. Map config parameters onto bean properties of this * filter, and invoke subclass initialization. * * @param filterConfig the configuration for this filter * @throws ServletException if bean properties are invalid (or required properties are missing), * or if subclass initialization fails. * @see #initFilterBean */ public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); if (logger.isDebugEnabled()) { logger.debug("Initializing filter '" + filterConfig.getFilterName() + "'"); } this.filterConfig = filterConfig; // Set bean properties from init parameters. try { PropertyValues pvs = new FilterConfigPropertyValues(filterConfig, this.requiredProperties); BeanWrapper bw = new BeanWrapperImpl(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext()); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader)); initBeanWrapper(bw); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': " + ex.getMessage(); logger.error(msg, ex); throw new NestedServletException(msg, ex); } // Let subclasses do whatever initialization they like. initFilterBean(); if (logger.isDebugEnabled()) { logger.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully"); } }
@Override public void init(FilterConfig filterConfig) throws ServletException { WebApplicationContext webApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext( filterConfig.getServletContext()); menuCache = (MenuCache) webApplicationContext.getBean("menuCache"); }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { try { boolean authorized = false; if (request instanceof HttpServletRequest) { HttpSession session = ((HttpServletRequest) request).getSession(false); if (session != null) { User activeUser = (User) session.getAttribute("activeUser"); String requestAction = ((HttpServletRequest) request).getParameter("action"); // avoid vicious circle :) if ((activeUser != null) || "login.do".equalsIgnoreCase(requestAction)) { authorized = true; } } } if (authorized) { filterChain.doFilter(request, response); } else { filterConfig .getServletContext() .getRequestDispatcher("/auth/login.jsp") .forward(request, response); } } catch (IOException io) { System.out.println("IOException raised in AuthenticationFilter"); } catch (ServletException se) { System.out.println("ServletException raised in AuthenticationFilter"); } }
private void initCaches(FilterConfig filterConfig) { ArtifactorySystemProperties properties = ((ArtifactoryHome) filterConfig.getServletContext().getAttribute(ArtifactoryHome.SERVLET_CTX_ATTR)) .getArtifactoryProperties(); ConstantValues idleTimeSecsProp = ConstantValues.securityAuthenticationCacheIdleTimeSecs; long cacheIdleSecs = properties.getLongProperty(idleTimeSecsProp); ConstantValues initSizeProp = ConstantValues.securityAuthenticationCacheInitSize; long initSize = properties.getLongProperty(initSizeProp); nonUiAuthCache = CacheBuilder.newBuilder() .softValues() .initialCapacity((int) initSize) .expireAfterWrite(cacheIdleSecs, TimeUnit.SECONDS) .<AuthCacheKey, Authentication>build() .asMap(); userChangedCache = CacheBuilder.newBuilder() .softValues() .initialCapacity((int) initSize) .expireAfterWrite(cacheIdleSecs, TimeUnit.SECONDS) .<String, AuthenticationCache>build() .asMap(); SecurityService securityService = context.beanForType(SecurityService.class); securityService.addListener(this); }
/** {@inheritDoc} */ @Override public void init(final FilterConfig filterConfig) throws ServletException { servletContext = filterConfig.getServletContext(); templateEngine = new TemplateEngine(); templateEngine.setTemplateResolver(createTemplateResolver()); templateEngine.setDialect(new WuicDialect()); }
@Override public void init(FilterConfig filterConfig) throws ServletException { super.init(filterConfig); bundlesManager = createBundleManager(filterConfig.getServletContext(), staplerStrategy); readFilterConfigParameters( filterConfig, this, "enabled", "stripHtml", "resetOnStart", "useGzip", "cacheMaxAge"); String staplerStrategyName = filterConfig.getInitParameter("strategy"); if (staplerStrategyName != null) { if (staplerStrategyName.equalsIgnoreCase("ACTION_MANAGED")) { staplerStrategy = Strategy.ACTION_MANAGED; } } readFilterConfigParameters( filterConfig, bundlesManager, "bundleFolder", "downloadLocal", "localAddressAndPort", "localFilesEncoding", "notFoundExceptionEnabled", "sortResources", "staplerPath"); if (resetOnStart) { bundlesManager.reset(); } }
/** * Looks up and returns a repository bound in the servlet context of the given filter. * * @return repository from servlet context * @throws RepositoryException if the repository is not available */ public Repository getRepository() throws RepositoryException { String name = config.getInitParameter(Repository.class.getName()); if (name == null) { name = Repository.class.getName(); } ServletContext context = config.getServletContext(); Object repository = context.getAttribute(name); if (repository instanceof Repository) { return (Repository) repository; } else if (repository != null) { throw new RepositoryException( "Invalid repository: Attribute " + name + " in servlet context " + context.getServletContextName() + " is an instance of " + repository.getClass().getName()); } else { throw new RepositoryException( "Repository not found: Attribute " + name + " does not exist in servlet context " + context.getServletContextName()); } }
@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); } }
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); }
/** * Get the servlet context for the servlet or filter, depending on how this class is registered. * * @return the servlet context for the servlet or filter. */ @Override public ServletContext getServletContext() { if (filterConfig != null) { return filterConfig.getServletContext(); } return super.getServletContext(); }
@Before public void setUp() throws Exception { filter = new WroFilter(); config = Mockito.mock(FilterConfig.class); final ServletContext servletContext = Mockito.mock(ServletContext.class); Mockito.when(config.getServletContext()).thenReturn(servletContext); filter.init(config); }
public Enumeration<String> getInitParameterNames() { Set<String> result = Sets.newLinkedHashSet(); result.addAll(Collections.list(filterConfig.getInitParameterNames())); result.addAll(Collections.list(filterConfig.getServletContext().getInitParameterNames())); return Iterators.asEnumeration(result.iterator()); }
@Override public void init(FilterConfig filterConfig) throws ServletException { WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(filterConfig.getServletContext()); this.userManagementService = context.getBean(UserManagementService.class); this.employeeManagementService = context.getBean(EmployeeManagementService.class); this.objectMapper = context.getBean(ObjectMapper.class); }
public String getInitParameter(String name) { String result = filterConfig.getInitParameter(name); if (result == null) { result = filterConfig.getServletContext().getInitParameter(name); } return result; }