List of usage examples for javax.servlet FilterConfig getServletContext
public ServletContext getServletContext();
From source file:com.onehippo.gogreen.login.HstConcurrentLoginFilter.java
@SuppressWarnings("unchecked") public void init(FilterConfig filterConfig) throws ServletException { ServletContext servletContext = filterConfig.getServletContext(); usernameHttpSessionWrapperMap = (Map<String, HttpSessionWrapper>) servletContext .getAttribute(USERNAME_SESSIONID_MAP_ATTR); if (usernameHttpSessionWrapperMap == null) { usernameHttpSessionWrapperMap = Collections.synchronizedMap(new HashMap<String, HttpSessionWrapper>()); servletContext.setAttribute(USERNAME_SESSIONID_MAP_ATTR, usernameHttpSessionWrapperMap); }/*from ww w .ja v a 2s . c om*/ String[] disallowConcurrentLoginUsernamesArray = StringUtils .split(filterConfig.getInitParameter("disallowConcurrentLoginUsernames"), " ,\t\r\n"); if (disallowConcurrentLoginUsernamesArray != null && disallowConcurrentLoginUsernamesArray.length > 0) { disallowConcurrentLoginUsernames = new HashSet<String>( Arrays.asList(disallowConcurrentLoginUsernamesArray)); } log.info( "HstConcurrentLoginFilter's disallowConcurrentLoginUsernames: " + disallowConcurrentLoginUsernames); String[] allowConcurrentLoginUsernamesArray = StringUtils .split(filterConfig.getInitParameter("allowConcurrentLoginUsernames"), " ,\t\r\n"); if (allowConcurrentLoginUsernamesArray != null && allowConcurrentLoginUsernamesArray.length > 0) { allowConcurrentLoginUsernames = new HashSet<String>(Arrays.asList(allowConcurrentLoginUsernamesArray)); } earlySessionInvalidation = BooleanUtils .toBoolean(filterConfig.getInitParameter("earlySessionInvalidation")); log.info("HstConcurrentLoginFilter's allowConcurrentLoginUsernames: " + allowConcurrentLoginUsernames); }
From source file:org.ajax4jsf.webapp.ConfigurableXMLFilter.java
public void init(FilterConfig config) throws ServletException { super.init(config); ServletContext servletContext = config.getServletContext(); String parsersParameter = servletContext.getInitParameter(PARSERS_LIST_PARAMETER); if (null != parsersParameter) { configureParsers(servletContext, parsersParameter); }//from www .jav a 2 s .c om }
From source file:org.alfresco.web.app.servlet.HTTPRequestAuthenticationFilter.java
public void init(FilterConfig config) throws ServletException { // Save the context this.context = config.getServletContext(); // Setup the authentication context WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context); authComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); authenticationService = (AuthenticationService) ctx.getBean("AuthenticationService"); httpServletRequestAuthHeaderName = config.getInitParameter("httpServletRequestAuthHeaderName"); if (httpServletRequestAuthHeaderName == null) { httpServletRequestAuthHeaderName = "x-user"; }//w w w. j a va 2s . co m this.authPatternString = config.getInitParameter("authPatternString"); if (this.authPatternString != null) { try { authPattern = Pattern.compile(this.authPatternString); } catch (PatternSyntaxException e) { logger.warn("Invalid pattern: " + this.authPatternString, e); authPattern = null; } } }
From source file:com.netease.channel.security.AuthenticatorFilter.java
@Override public void init(FilterConfig arg0) throws ServletException { String temp = arg0.getInitParameter(LoginUtil.LOGIN_URL); if (!StringUtils.isEmpty(temp)) { realm = temp;/* www. ja v a2s . c o m*/ } LOG.info("Login user " + realm); String home = arg0.getServletContext().getRealPath("WEB-INF"); LOG.info("Home directory=" + home); System.setProperty("native.home", home); }
From source file:org.tsm.concharto.web.filter.LoginFilter.java
public void init(FilterConfig filterConfig) throws ServletException { // this.filterConfig = filterConfig; ServletContext ctx = filterConfig.getServletContext(); WebApplicationContext webAppContext = WebApplicationContextUtils.getWebApplicationContext(ctx); userDao = (UserDao) webAppContext.getBean("userDao"); sessionHelper = (SessionHelper) webAppContext.getBean("sessionHelper"); }
From source file:org.nuxeo.wss.servlet.BaseWSSFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { if (filterConfig != null) { // For Testing this.ctx = filterConfig.getServletContext(); }/*from ww w . ja v a2 s . c o m*/ synchronized (this.getClass()) { initHandlers(filterConfig); // simpleGetHandler = new SimpleGetHandler(); // resourcesHandler = new ResourcesHandler(); this.filterConfig = filterConfig; if (filterConfig != null) { initBackend(filterConfig); } } }
From source file:org.apache.hadoop.gateway.dispatch.DefaultHttpClientFactory.java
@Override public HttpClient createHttpClient(FilterConfig filterConfig) { HttpClientBuilder builder = null;/*from w ww. j a va2 s. com*/ GatewayConfig gatewayConfig = (GatewayConfig) filterConfig.getServletContext() .getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE); if (gatewayConfig != null && gatewayConfig.isMetricsEnabled()) { GatewayServices services = (GatewayServices) filterConfig.getServletContext() .getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE); MetricsService metricsService = services.getService(GatewayServices.METRICS_SERVICE); builder = metricsService.getInstrumented(HttpClientBuilder.class); } else { builder = HttpClients.custom(); } if ("true".equals(System.getProperty(GatewayConfig.HADOOP_KERBEROS_SECURED))) { CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(AuthScope.ANY, new UseJaasCredentials()); Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create() .register(AuthSchemes.SPNEGO, new KnoxSpnegoAuthSchemeFactory(true)).build(); builder = builder.setDefaultAuthSchemeRegistry(authSchemeRegistry) .setDefaultCookieStore(new HadoopAuthCookieStore()) .setDefaultCredentialsProvider(credentialsProvider); } else { builder = builder.setDefaultCookieStore(new NoCookieStore()); } builder.setKeepAliveStrategy(DefaultConnectionKeepAliveStrategy.INSTANCE); builder.setConnectionReuseStrategy(DefaultConnectionReuseStrategy.INSTANCE); builder.setRedirectStrategy(new NeverRedirectStrategy()); builder.setRetryHandler(new NeverRetryHandler()); int maxConnections = getMaxConnections(filterConfig); builder.setMaxConnTotal(maxConnections); builder.setMaxConnPerRoute(maxConnections); builder.setDefaultRequestConfig(getRequestConfig(filterConfig)); HttpClient client = builder.build(); return client; }
From source file:org.apache.hadoop.gateway.identityasserter.common.filter.CommonIdentityAssertionFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { String principalMapping = filterConfig.getInitParameter(PRINCIPAL_MAPPING); if (principalMapping == null || principalMapping.isEmpty()) { principalMapping = filterConfig.getServletContext().getInitParameter(PRINCIPAL_MAPPING); }/*from ww w . ja va 2s.com*/ String groupPrincipalMapping = filterConfig.getInitParameter(GROUP_PRINCIPAL_MAPPING); if (groupPrincipalMapping == null || groupPrincipalMapping.isEmpty()) { groupPrincipalMapping = filterConfig.getServletContext().getInitParameter(GROUP_PRINCIPAL_MAPPING); } if (principalMapping != null && !principalMapping.isEmpty() || groupPrincipalMapping != null && !groupPrincipalMapping.isEmpty()) { try { mapper.loadMappingTable(principalMapping, groupPrincipalMapping); } catch (PrincipalMappingException e) { throw new ServletException("Unable to load principal mapping table.", e); } } }
From source file:com.hp.security.jauth.core.filter.AuthFilter.java
public void init(FilterConfig filterConfig) throws ServletException { //init components this.servletContext = filterConfig.getServletContext(); context = (WebApplicationContext) servletContext .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); authService = context.getBean(AuthService.class); exceptionUtil = context.getBean(ExceptionUtil.class); systemInit = context.getBean(SystemInit.class); try {/*from w w w.ja v a2s .c om*/ authHook = context.getBean(AuthHook.class); } catch (NoSuchBeanDefinitionException e) { log.info("no authHook find."); } try { systemInit.userValidationHook = context.getBean(UserValidationHook.class); } catch (NoSuchBeanDefinitionException e) { log.info("no userValidationHook find."); } try { systemInit.soapHook = context.getBean(SoapHook.class); } catch (NoSuchBeanDefinitionException e) { log.info("no SOAP Hook find."); } }
From source file:org.alfresco.repo.webdav.auth.HTTPRequestAuthenticationFilter.java
/** * Initialize the filter/*from w ww . jav a 2s .co m*/ * * @param config * FitlerConfig * @exception ServletException */ public void init(FilterConfig config) throws ServletException { // Save the context m_context = config.getServletContext(); // Setup the authentication context WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(m_context); ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); setNodeService(serviceRegistry.getNodeService()); setAuthenticationService(serviceRegistry.getAuthenticationService()); setTransactionService(serviceRegistry.getTransactionService()); setPersonService((PersonService) ctx.getBean("PersonService")); // transactional and permission-checked m_authComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); httpServletRequestAuthHeaderName = config.getInitParameter("httpServletRequestAuthHeaderName"); if (httpServletRequestAuthHeaderName == null) { httpServletRequestAuthHeaderName = "x-user"; } this.m_authPatternString = config.getInitParameter("authPatternString"); if (this.m_authPatternString != null) { try { m_authPattern = Pattern.compile(this.m_authPatternString); } catch (PatternSyntaxException e) { logger.warn("Invalid pattern: " + this.m_authPatternString, e); m_authPattern = null; } } }