@Override public void init(FilterConfig filterConfig) throws ServletException { if (serverConfig == null) { EurekaServerContext serverContext = (EurekaServerContext) filterConfig.getServletContext() .getAttribute(EurekaServerContext.class.getName()); serverConfig = serverContext.getServerConfig(); } }
@Override public void init(FilterConfig config) throws ServletException { context = config.getServletContext(); defaultLoginPage = config.getInitParameter("defaultLoginPage"); String excludesProp = config.getInitParameter("excludes"); if (excludesProp != null) { StringTokenizer tokenizer = new StringTokenizer(excludesProp, ","); while (tokenizer.hasMoreTokens()) { String tok = tokenizer.nextToken().trim(); excludes.add(tok); } } }
public void init(FilterConfig c) throws ServletException { sc = c.getServletContext(); _me = this; try { while (keys.hasMoreElements()) { String key = keys.nextElement(); String value = c.getInitParameter(key); if (!Strings.isBlank(value) && !"null".equals(value)) props.put(key, c.getInitParameter(key)); String path = c.getInitParameter("config-file"); if (path != null) { InputStream ins = getClass().getClassLoader().getResourceAsStream(path); if (ins == null) ins = c.getServletContext().getResourceAsStream(path); if (ins == null) { throw new ServletException("config-file=" + path + " not found");
@Override public void init(FilterConfig filterConfig) throws ServletException { String module = filterConfig.getInitParameter("module"); CloudStackSpringContext context = (CloudStackSpringContext)filterConfig.getServletContext().getAttribute(CloudStackSpringContext.CLOUDSTACK_CONTEXT_SERVLET_KEY); if (context == null) return; ApplicationContext applicationContext = context.getApplicationContextForWeb(module); if (applicationContext != null) { AutowireCapableBeanFactory factory = applicationContext.getAutowireCapableBeanFactory(); if (factory != null) { factory.autowireBean(this); enabled = true; } } }
@Override public void init(FilterConfig filterConfig) throws ServletException { if (serverConfig == null) { EurekaServerContext serverContext = (EurekaServerContext) filterConfig.getServletContext() .getAttribute(EurekaServerContext.class.getName()); serverConfig = serverContext.getServerConfig(); } }
@Override protected void doPortalInit() throws Exception { if (_INVOKER_FILTER_CHAIN_ENABLED) { _filterChains = PortalCacheHelperUtil.getPortalCache( PortalCacheManagerNames.SINGLE_VM, _getPortalCacheName()); } ServletContext servletContext = _filterConfig.getServletContext(); InvokerFilterHelper invokerFilterHelper = (InvokerFilterHelper)servletContext.getAttribute( InvokerFilterHelper.class.getName()); if (invokerFilterHelper == null) { invokerFilterHelper = new InvokerFilterHelper(); servletContext.setAttribute( InvokerFilterHelper.class.getName(), invokerFilterHelper); invokerFilterHelper.init(_filterConfig); } _invokerFilterHelper = invokerFilterHelper; _invokerFilterHelper.addInvokerFilter(this); _dispatcher = Dispatcher.valueOf( _filterConfig.getInitParameter("dispatcher")); }
@Override public void init(FilterConfig filterConfig) throws ServletException { String uploader = filterConfig.getServletContext().getInitParameter(Constants.ContextParams.UPLOADER); if (uploader == null || uploader.equals("auto")) { PrimeEnvironment environment = new StartupPrimeEnvironment(); bypass = environment.isAtLeastJsf22(); } else if (uploader.equals("native")) { bypass = true; } else if (uploader.equals("commons")) { bypass = false; } thresholdSize = filterConfig.getInitParameter(THRESHOLD_SIZE_PARAM); uploadDir = filterConfig.getInitParameter(UPLOAD_DIRECTORY_PARAM); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("FileUploadFilter initiated successfully"); } }
@Test public void triggerWithTriggerParams() throws ServletException { // Filter init & setup ServletContext context = mock(ServletContext.class); FilterConfig filterConfig = mock(FilterConfig.class); when(filterConfig.getFilterName()).thenReturn("dummy"); when(filterConfig.getServletContext()).thenReturn(context); when(filterConfig.getInitParameterNames()).thenReturn(new StringTokenIterator("triggerParams")); when(filterConfig.getInitParameter("triggerParams")).thenReturn("foo"); DummyFilter filter = new DummyFilter(); filter.init(filterConfig); // Request/response setup HttpServletRequest request = mock(HttpServletRequest.class); when(request.getParameter("foo")).thenReturn("doit"); // Execute/Verifications assertTrue(filter.trigger(request)); }
public void init(FilterConfig config) throws ServletException { ServletContext servletContext = config.getServletContext(); contextName = servletContext.getContextPath().replaceAll("/", ""); if ("".equals(contextName)) { contextName = "root"; } System.out.printf("Filter init: %s%n", contextName); ConfigurableWebApplicationContext appctx = (ConfigurableWebApplicationContext) servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (appctx != null) { System.out.printf("ConfigurableWebApplicationContext is not null in LoggerContextFilter for: %s, this indicates a misconfiguration or load order problem%n", contextName); } }
String mode = filterConfig.getInitParameter(MODE_PARAM); if (!StringUtils.isNullOrEmpty(mode)) { System.setProperty(PippoConstants.SYSTEM_PROPERTY_PIPPO_MODE, mode); ServletContext servletContext = filterConfig.getServletContext(); if (servletContext.getAttribute(WebServer.PIPPO_APPLICATION) == null) { servletContext.setAttribute(WebServer.PIPPO_APPLICATION, application);
@Override public void init(FilterConfig config) throws ServletException { String exclusions = config.getInitParameter(PARAM_NAME_EXCLUSIONS); if (exclusions != null && exclusions.trim().length() != 0) { excludesPattern = new HashSet<String>(Arrays.asList(exclusions.split("\\s*,\\s*"))); String param = config.getInitParameter(PARAM_NAME_PRINCIPAL_SESSION_NAME); if (param != null) { param = param.trim(); String param = config.getInitParameter(PARAM_NAME_PRINCIPAL_COOKIE_NAME); if (param != null) { param = param.trim(); this.contextPath = DruidWebUtils.getContextPath(config.getServletContext()); if (webAppStat == null) { webAppStat = new WebAppStat(contextPath, this.sessionStatMaxCount);
@Test public void dontTriggerWithoutTriggerParams() throws ServletException { // Filter init & setup ServletContext context = mock(ServletContext.class); FilterConfig filterConfig = mock(FilterConfig.class); when(filterConfig.getFilterName()).thenReturn("dummy"); when(filterConfig.getServletContext()).thenReturn(context); when(filterConfig.getInitParameterNames()).thenReturn(new StringTokenIterator("triggerParams")); when(filterConfig.getInitParameter("triggerParams")).thenReturn("foo"); DummyFilter filter = new DummyFilter(); filter.init(filterConfig); // Request/response setup HttpServletRequest request = mock(HttpServletRequest.class); // Execute/Verifications assertFalse(filter.trigger(request)); }
@Override protected void initializeAuthHandler(String authHandlerClassName, FilterConfig filterConfig) throws ServletException { // A single CuratorFramework should be used for a ZK cluster. // If the ZKSignerSecretProvider has already created it, it has to // be set here... to be used by the ZKDelegationTokenSecretManager ZKDelegationTokenSecretManager.setCurator((CuratorFramework) filterConfig.getServletContext().getAttribute(ZKSignerSecretProvider. ZOOKEEPER_SIGNER_SECRET_PROVIDER_CURATOR_CLIENT_ATTRIBUTE)); super.initializeAuthHandler(authHandlerClassName, filterConfig); ZKDelegationTokenSecretManager.setCurator(null); }
@Override public Object getConfigurationValue(String name) throws ConfigurationException { Object value = config.getInitParameter(name); if (value == null) { value = config.getServletContext().getAttribute(name); } return value; } }
@SuppressWarnings("deprecation") public void init(FilterConfig filterConfig) throws ServletException { if (jfinalConfig == null) { createJFinalConfig(filterConfig.getInitParameter("configClass")); } jfinal.init(jfinalConfig, filterConfig.getServletContext()); String contextPath = filterConfig.getServletContext().getContextPath(); contextPathLength = (contextPath == null || "/".equals(contextPath) ? 0 : contextPath.length()); constants = Config.getConstants(); encoding = constants.getEncoding(); jfinalConfig.onStart(); jfinalConfig.afterJFinalStart(); handler = jfinal.getHandler(); // 开始接受请求 }
final FilterConfig filterConfig = mockFilter.getConfig(); assertTrue(null != filterConfig); assertEquals(contextName, filterConfig.getServletContext().getServletContextName()); assertEquals(filterConfig.getFilterName(), Key.get(Filter.class).toString()); assertEquals(filterConfig.getInitParameter(name), initParams.get(name));
@Override public void init(FilterConfig filterConfig) throws ServletException { super.init(filterConfig); AuthenticationHandler handler = getAuthenticationHandler(); AbstractDelegationTokenSecretManager dtSecretManager = (AbstractDelegationTokenSecretManager) filterConfig.getServletContext(). getAttribute(DELEGATION_TOKEN_SECRET_MANAGER_ATTR); if (dtSecretManager != null && handler instanceof DelegationTokenAuthenticationHandler) { DelegationTokenAuthenticationHandler dtHandler = (DelegationTokenAuthenticationHandler) getAuthenticationHandler(); dtHandler.setExternalDelegationTokenSecretManager(dtSecretManager); } if (handler instanceof PseudoAuthenticationHandler || handler instanceof PseudoDelegationTokenAuthenticationHandler) { setHandlerAuthMethod(SaslRpcServer.AuthMethod.SIMPLE); } if (handler instanceof KerberosAuthenticationHandler || handler instanceof KerberosDelegationTokenAuthenticationHandler) { setHandlerAuthMethod(SaslRpcServer.AuthMethod.KERBEROS); } // proxyuser configuration Configuration conf = getProxyuserConfiguration(filterConfig); ProxyUsers.refreshSuperUserGroupsConfiguration(conf, PROXYUSER_PREFIX); }
@Override public Object getConfigurationValue(String name) throws ConfigurationException { Object value = config.getInitParameter(name); if (value == null) { value = config.getServletContext().getAttribute(name); } return value; } }
public void init(FilterConfig filterConfig) throws ServletException { { String exclusions = filterConfig.getInitParameter(PARAM_NAME_EXCLUSIONS); if (exclusions != null && exclusions.trim().length() != 0) { excludesPattern = new HashSet<String>(Arrays.asList(exclusions.split("\\s*,\\s*"))); } } try { Config config = createConfig(filterConfig.getInitParameter(PARAM_NAME_CONFIGCLASS)); restyIniter = new RestyIniter(config, filterConfig.getServletContext()); handler = restyIniter.getHandler(); } catch (Exception e) { logger.error(e.getMessage(), e); throw new HttpException(HttpMessage.INTERNAL_SERVER_ERROR); } }
public void init(FilterConfig filterConfig) throws ServletException { Enumeration<String> paramNames = filterConfig.getInitParameterNames(); while (paramNames.hasMoreElements()) { String paramName = paramNames.nextElement(); if (!IntrospectionUtils.setProperty(this, paramName, filterConfig.getInitParameter(paramName))) { filterConfig.getServletContext().log(sm.getString("filterbase.noSuchProperty", paramName, this.getClass().getName())); } } }