Java Code Examples for javax.servlet.FilterConfig

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project nuxeo-platform-login, under directory /nuxeo-platform-login-cas2/src/test/java/org/nuxeo/ecm/platform/ui/web/auth/simple/.

Source file: AbstractAuthenticator.java

  20 
vote

protected void initRequest() throws ServletException {
  naf=new NuxeoAuthenticationFilter();
  ServletContext servletContext=new MockServletContext();
  MockHttpSession session=new MockHttpSession(new MockServletContext());
  FilterConfig config=new MockFilterConfig(servletContext);
  chain=new MockFilterChain();
  naf.init(config);
  request=new MockHttpRequest(session);
  response=new MockHttpResponse();
}
 

Example 2

From project shiro, under directory /web/src/main/java/org/apache/shiro/web/config/.

Source file: IniFilterChainResolverFactory.java

  19 
vote

protected FilterChainResolver createDefaultInstance(){
  FilterConfig filterConfig=getFilterConfig();
  if (filterConfig != null) {
    return new PathMatchingFilterChainResolver(filterConfig);
  }
 else {
    return new PathMatchingFilterChainResolver();
  }
}
 

Example 3

From project jsecurity, under directory /web/src/main/java/org/apache/ki/web/servlet/.

Source file: OncePerRequestFilter.java

  18 
vote

/** 
 * Returns the name of this filter. <p/> Unless overridden by calling the  {@link #setName(String) setName(String)} method, this value defaults to thefilter name as specified by the servlet container at startup: <p/> <code>this.name =  {@link #getFilterConfig() getFilterConfig()}. {@link FilterConfig#getFilterName() getName()};</code>
 * @return the filter name, or <code>null</code> if none available
 * @see javax.servlet.GenericServlet#getServletName()
 * @see javax.servlet.FilterConfig#getFilterName()
 */
protected String getName(){
  if (this.name == null) {
    FilterConfig config=getFilterConfig();
    if (config != null) {
      this.name=config.getFilterName();
    }
  }
  return this.name;
}
 

Example 4

From project sisu-guice, under directory /extensions/servlet/test/com/google/inject/servlet/.

Source file: ContinuingRequestIntegrationTest.java

  18 
vote

public final void testRequestContinuesInOtherThread() throws ServletException, IOException, InterruptedException {
  executor=Executors.newSingleThreadExecutor();
  injector=Guice.createInjector(new ServletModule(){
    @Override protected void configureServlets(){
      serve("/*").with(ContinuingServlet.class);
      bind(ExecutorService.class).toInstance(executor);
    }
  }
);
  FilterConfig filterConfig=createMock(FilterConfig.class);
  expect(filterConfig.getServletContext()).andReturn(createMock(ServletContext.class));
  GuiceFilter guiceFilter=injector.getInstance(GuiceFilter.class);
  HttpServletRequest request=createMock(HttpServletRequest.class);
  expect(request.getRequestURI()).andReturn("/");
  expect(request.getContextPath()).andReturn("").anyTimes();
  expect(request.getMethod()).andReturn("GET");
  FilterChain filterChain=createMock(FilterChain.class);
  expect(request.getParameter(PARAM_NAME)).andReturn(PARAM_VALUE);
  replay(request,filterConfig,filterChain);
  guiceFilter.init(filterConfig);
  guiceFilter.doFilter(request,null,filterChain);
  executor.shutdown();
  executor.awaitTermination(10,TimeUnit.SECONDS);
  assertEquals(PARAM_VALUE,injector.getInstance(OffRequestCallable.class).value);
  verify(request,filterConfig,filterChain);
}
 

Example 5

From project spring-test-mvc, under directory /src/test/java/org/springframework/test/web/server/setup/.

Source file: ConditionalDelegatingFilterProxyTests.java

  18 
vote

@Test public void init() throws Exception {
  FilterConfig config=new MockFilterConfig();
  filter=new PatternMappingFilterProxy(delegate,"/");
  filter.init(config);
  assertThat(delegate.filterConfig,is(config));
}
 

Example 6

From project tempo, under directory /ui-fw/src/test/java/org/intalio/tempo/uiframework/filter/.

Source file: CASRBACFilterTest.java

  18 
vote

@BeforeSpecification public void before(){
  filter=new CASRBACFilter(){
    protected WebApplicationContext getWebApplicationState(    HttpSession session){
      return context;
    }
  }
;
  FilterConfig filterConfig=new MockFilterConfig();
  filter.init(filterConfig);
  TokenClient tokenClient=new MockTokenService("http://localhost:8080/token");
  Configuration.getInstance().setTokenClient(tokenClient);
}
 

Example 7

From project virgo.snaps, under directory /org.eclipse.virgo.snaps.core/src/main/java/org/eclipse/virgo/snaps/core/internal/webapp/container/.

Source file: FilterManager.java

  18 
vote

void init() throws ServletException {
  try {
    ManagerUtils.doWithThreadContextClassLoader(this.classLoader,new ClassLoaderCallback<Void>(){
      public Void doWithClassLoader() throws ServletException {
        for (        FilterHolder filterHolder : filters) {
          FilterConfig config=new ImmutableFilterConfig(filterHolder.getDefinition(),snapServletContext);
          try {
            filterHolder.getInstance().init(config);
          }
 catch (          ServletException se) {
            throw se;
          }
        }
        return null;
      }
    }
);
  }
 catch (  IOException e) {
    throw new ServletException("Unexpected IOException from filter init",e);
  }
}
 

Example 8

From project alfredo, under directory /alfredo/src/test/java/com/cloudera/alfredo/server/.

Source file: TestAuthenticationFilter.java

  17 
vote

public void testGetConfiguration() throws Exception {
  AuthenticationFilter filter=new AuthenticationFilter();
  FilterConfig config=Mockito.mock(FilterConfig.class);
  Mockito.when(config.getInitParameter(AuthenticationFilter.CONFIG_PREFIX)).thenReturn("");
  Mockito.when(config.getInitParameter("a")).thenReturn("A");
  Mockito.when(config.getInitParameterNames()).thenReturn(new Vector(Arrays.asList("a")).elements());
  Properties props=filter.getConfiguration("",config);
  assertEquals("A",props.getProperty("a"));
  config=Mockito.mock(FilterConfig.class);
  Mockito.when(config.getInitParameter(AuthenticationFilter.CONFIG_PREFIX)).thenReturn("foo");
  Mockito.when(config.getInitParameter("foo.a")).thenReturn("A");
  Mockito.when(config.getInitParameterNames()).thenReturn(new Vector(Arrays.asList("foo.a")).elements());
  props=filter.getConfiguration("foo.",config);
  assertEquals("A",props.getProperty("a"));
}
 

Example 9

From project flip, under directory /servlet/src/test/java/com/tacitknowledge/flip/servlet/.

Source file: FlipOverrideFilterTest.java

  17 
vote

@Test public void testInvalidPropertiesInRequest() throws IOException, ServletException {
  HttpSession session=mock(HttpSession.class);
  FilterConfig filterConfig=mock(FilterConfig.class);
  when(request.getSession()).thenReturn(session);
  when(request.getSession(anyBoolean())).thenReturn(session);
  Map<String,String[]> requestParams=new HashMap<String,String[]>();
  requestParams.put("flip.featureName",new String[]{"blahblahblah"});
  requestParams.put("featureName2",new String[]{"enabled"});
  when(request.getParameterMap()).thenReturn(requestParams);
  Map<String,FeatureDescriptor> sessionFeatureMap=new HashMap<String,FeatureDescriptor>();
  when(session.getAttribute(FlipOverrideFilter.SESSION_FEATURES_KEY)).thenReturn(sessionFeatureMap);
  filter.init(filterConfig);
  filter.doFilter(request,response,filterChain);
  assertTrue(sessionFeatureMap.isEmpty());
  assertNull(sessionFeatureMap.get("featureName"));
  assertNull(sessionFeatureMap.get("featureName2"));
}
 

Example 10

From project guice-jit-providers, under directory /extensions/servlet/test/com/google/inject/servlet/.

Source file: ContinuingRequestIntegrationTest.java

  17 
vote

public final void testRequestContinuesInOtherThread() throws ServletException, IOException, InterruptedException {
  executor=Executors.newSingleThreadExecutor();
  injector=Guice.createInjector(new ServletModule(){
    @Override protected void configureServlets(){
      serve("/*").with(ContinuingServlet.class);
      bind(ExecutorService.class).toInstance(executor);
    }
  }
);
  FilterConfig filterConfig=createMock(FilterConfig.class);
  expect(filterConfig.getServletContext()).andReturn(createMock(ServletContext.class));
  GuiceFilter guiceFilter=injector.getInstance(GuiceFilter.class);
  HttpServletRequest request=createMock(HttpServletRequest.class);
  expect(request.getRequestURI()).andReturn("/");
  expect(request.getContextPath()).andReturn("").anyTimes();
  expect(request.getMethod()).andReturn("GET");
  FilterChain filterChain=createMock(FilterChain.class);
  expect(request.getParameter(PARAM_NAME)).andReturn(PARAM_VALUE);
  replay(request,filterConfig,filterChain);
  guiceFilter.init(filterConfig);
  guiceFilter.doFilter(request,null,filterChain);
  executor.shutdown();
  executor.awaitTermination(10,TimeUnit.SECONDS);
  assertEquals(PARAM_VALUE,injector.getInstance(OffRequestCallable.class).value);
  verify(request,filterConfig,filterChain);
}
 

Example 11

From project jsf-test, under directory /stage/src/main/java/org/jboss/test/faces/staging/.

Source file: FilterContainer.java

  17 
vote

public void init(final ServletContext context) throws ServletException {
  if (!initialized) {
    filter.init(new FilterConfig(){
      public String getFilterName(){
        return name;
      }
      public String getInitParameter(      String name){
        return initParameters.get(name);
      }
      @SuppressWarnings("unchecked") public Enumeration getInitParameterNames(){
        return Collections.enumeration(initParameters.keySet());
      }
      public ServletContext getServletContext(){
        return context;
      }
    }
);
    next.init(context);
    initialized=true;
  }
}
 

Example 12

From project zen-project, under directory /zen-search/src/main/java/com/nominanuda/solr/.

Source file: SpringMvcServerEmbed.java

  17 
vote

public void init() throws ServletException {
  FilterConfig fc=new FilterConfig(){
    public String getInitParameter(    String name){
      return null;
    }
    public ServletContext getServletContext(){
      throw new UnsupportedOperationException();
    }
    @SuppressWarnings("rawtypes") public Enumeration getInitParameterNames(){
      throw new UnsupportedOperationException();
    }
    public String getFilterName(){
      throw new UnsupportedOperationException();
    }
  }
;
  solrDispatchFilter=new SolrDispatchFilter();
  solrDispatchFilter.init(fc);
  Check.illegalstate.assertFalse(SolrAware.getInstance().getCoreNames().isEmpty());
}
 

Example 13

From project hoop, under directory /hoop-server/src/main/java/com/cloudera/hoop/.

Source file: AuthFilter.java

  16 
vote

/** 
 * Returns the Alfredo configuration from Hoop's configuration. <p/> It returns all Hoop's configuration properties prefixed with <code>hoop.authentication</code>. The <code>hoop.authentication</code> prefix is removed from the returned property names.
 * @param configPrefix parameter not used.
 * @param filterConfig parameter not used.
 * @return Alfredo configuration read from Hoop's configuration.
 */
@Override protected Properties getConfiguration(String configPrefix,FilterConfig filterConfig){
  Properties props=new Properties();
  Configuration conf=HoopServer.get().getConfig();
  props.setProperty(AuthenticationFilter.COOKIE_PATH,"/");
  for (  Map.Entry<String,String> entry : conf) {
    String name=entry.getKey();
    if (name.startsWith(CONF_PREFIX)) {
      String value=conf.get(name);
      name=name.substring(CONF_PREFIX.length());
      props.setProperty(name,value);
    }
  }
  return props;
}
 

Example 14

From project molindo-wicket-utils, under directory /src/main/java/at/molindo/wicketutils/utils/.

Source file: MockUtils.java

  16 
vote

public static WicketFilter newMockFilter(final WebApplication application){
  final MockServletContext context=new MockServletContext(application,"/");
  final WicketFilter filter=new WicketFilter(){
    @Override protected IWebApplicationFactory getApplicationFactory(){
      return new IWebApplicationFactory(){
        @Override public WebApplication createApplication(        WicketFilter filter){
          return application;
        }
      }
;
    }
  }
;
  try {
    filter.init(new FilterConfig(){
      @Override public ServletContext getServletContext(){
        return context;
      }
      @Override public Enumeration<?> getInitParameterNames(){
        return null;
      }
      @Override public String getInitParameter(      String name){
        return null;
      }
      @Override public String getFilterName(){
        return "WicketMockServlet";
      }
    }
);
  }
 catch (  ServletException e) {
    throw new RuntimeException(e);
  }
  return filter;
}
 

Example 15

From project aranea, under directory /server/src/main/java/no/dusken/aranea/filter/.

Source file: PluginAwareUrlRewriteFilter.java

  15 
vote

@Override protected void loadUrlRewriter(FilterConfig filterConfig) throws ServletException {
  ServletContext context=filterConfig.getServletContext();
  InputStream inputStream=context.getResourceAsStream(DEFAULT_WEB_CONF_PATH);
  URL confUrl=null;
  try {
    confUrl=context.getResource(DEFAULT_WEB_CONF_PATH);
  }
 catch (  MalformedURLException e) {
    log.debug("Malformed url",e);
  }
  String confUrlStr=null;
  if (confUrl != null) {
    confUrlStr=confUrl.toString();
  }
  if (inputStream == null) {
    log.error("unable to find urlrewrite conf file at " + DEFAULT_WEB_CONF_PATH);
  }
 else {
    Conf conf=new PluginAwareConf(context,inputStream,DEFAULT_WEB_CONF_PATH,confUrlStr);
    checkConf(conf);
  }
}
 

Example 16

From project Carolina-Digital-Repository, under directory /fcrepo-cdr-fesl/src/main/java/edu/unc/lib/dl/security/.

Source file: ForwardedGroupsToFedoraRolesFilter.java

  15 
vote

@Override public void init(FilterConfig filterConfig) throws ServletException {
  this.header=filterConfig.getInitParameter("header");
  if (this.header == null || this.header.trim().length() == 0) {
    String msg="The parameter 'header' must be supplied with a single header name.";
    LOG.error(msg);
  }
  this.separator=filterConfig.getInitParameter("separator");
  if (this.separator == null || this.separator.trim().length() == 0) {
    String msg="The parameter 'separator' must be supplied.";
    LOG.error(msg);
  }
 else {
    this.separator=java.util.regex.Pattern.quote(this.separator);
  }
  if (this.header == null || this.separator == null) {
    throw new ServletException("Filter is missing one of the init parameters: header, separator");
  }
}
 

Example 17

From project Cours-3eme-ann-e, under directory /Java/tomcat/examples/WEB-INF/classes/compressionFilters/.

Source file: CompressionFilter.java

  15 
vote

/** 
 * Place this filter into service.
 * @param filterConfig The filter configuration object
 */
public void init(FilterConfig filterConfig){
  config=filterConfig;
  if (filterConfig != null) {
    String value=filterConfig.getInitParameter("debug");
    if (value != null) {
      debug=Integer.parseInt(value);
    }
 else {
      debug=0;
    }
    String str=filterConfig.getInitParameter("compressionThreshold");
    if (str != null) {
      compressionThreshold=Integer.parseInt(str);
      if (compressionThreshold != 0 && compressionThreshold < minThreshold) {
        if (debug > 0) {
          System.out.println("compressionThreshold should be either 0 - no compression or >= " + minThreshold);
          System.out.println("compressionThreshold set to " + minThreshold);
        }
        compressionThreshold=minThreshold;
      }
    }
 else {
      compressionThreshold=0;
    }
  }
 else {
    compressionThreshold=0;
  }
}
 

Example 18

From project crowd2-plugin, under directory /src/main/java/de/theit/jenkins/crowd/.

Source file: CrowdSecurityRealm.java

  15 
vote

/** 
 * {@inheritDoc}
 * @see hudson.security.SecurityRealm#createFilter(javax.servlet.FilterConfig)
 */
@Override public Filter createFilter(FilterConfig filterConfig){
  if (null == this.configuration) {
    initializeConfiguration();
  }
  Filter defaultFilter=super.createFilter(filterConfig);
  return new CrowdServletFilter(this,this.configuration,defaultFilter);
}
 

Example 19

From project crowd2-plugin_1, under directory /src/main/java/de/theit/hudson/crowd/.

Source file: CrowdSecurityRealm.java

  15 
vote

/** 
 * {@inheritDoc}
 * @see hudson.security.SecurityRealm#createFilter(javax.servlet.FilterConfig)
 */
@Override public Filter createFilter(FilterConfig filterConfig){
  if (null == this.configuration) {
    initializeConfiguration();
  }
  Filter defaultFilter=super.createFilter(filterConfig);
  return new CrowdServletFilter(this,this.configuration,defaultFilter);
}
 

Example 20

From project doorkeeper, under directory /core/src/main/java/net/dataforte/doorkeeper/filter/.

Source file: AuthenticatorFilter.java

  15 
vote

@Override public void init(FilterConfig filterConfig) throws ServletException {
  if (log.isInfoEnabled()) {
    log.info("Initializing AuthenticatorFilter...");
  }
  String chain=filterConfig.getInitParameter("chain");
  if (chain != null) {
    this.chain=chain;
  }
  setDoorkeeper(Doorkeeper.getInstance(filterConfig.getServletContext()));
}
 

Example 21

From project EasySOA, under directory /easysoa-registry/easysoa-registry-rest-miner/src/main/java/org/easysoa/records/filters/.

Source file: ExchangeRecordServletFilterImpl.java

  15 
vote

/** 
 * Initialize the filter
 */
public void init(FilterConfig filterConfig) throws ServletException {
  singleton=this;
  try {
    FraSCAtiServiceItf frascati=Framework.getLocalService(FraSCAtiServiceProviderItf.class).getFraSCAtiService();
    RunManager runManager=frascati.getService("handlerManager/handlerManagerServiceBaseComp/runManagerComponent","runManagerService",RunManager.class);
    runManager.addEventReceiver(new ExchangeRecordServletFilterEventReceiver());
  }
 catch (  Exception ex) {
    logger.error("Unable to register the ExchangeRecordServletFilterEventReceiver in the run manager",ex);
  }
}
 

Example 22

From project empire-db, under directory /empire-db-struts2/src/main/java/org/apache/empire/struts2/web/.

Source file: EmpireFilterDispatcher.java

  15 
vote

@Override protected Dispatcher createDispatcher(FilterConfig filterConfig){
  Map<String,String> params=new HashMap<String,String>();
  for (Enumeration<String> e=filterConfig.getInitParameterNames(); e.hasMoreElements(); ) {
    String name=e.nextElement();
    String value=filterConfig.getInitParameter(name);
    params.put(name,value);
  }
  return new EmpireStrutsDispatcher(filterConfig.getServletContext(),params);
}
 

Example 23

From project entando-core-engine, under directory /src/main/java/com/agiletec/apsadmin/system/dispatcher/.

Source file: FilterDispatcher.java

  15 
vote

@Override protected Dispatcher createDispatcher(FilterConfig filterConfig){
  Map<String,String> params=new HashMap<String,String>();
  for (Enumeration e=filterConfig.getInitParameterNames(); e.hasMoreElements(); ) {
    String name=(String)e.nextElement();
    String value=filterConfig.getInitParameter(name);
    params.put(name,value);
  }
  String struts2Config=this.getServletContext().getInitParameter(ApsAdminSystemConstants.STRUTS2_CONFIG_INIT_PARAM_NAME);
  if (null != struts2Config) {
    params.put("config",struts2Config);
  }
  return new Dispatcher(filterConfig.getServletContext(),params);
}
 

Example 24

From project gatein-sso, under directory /agent/src/main/java/org/gatein/sso/agent/filter/.

Source file: InitiateLoginFilter.java

  15 
vote

public void init(FilterConfig filterConfig) throws ServletException {
  this.ssoServerUrl=filterConfig.getInitParameter("ssoServerUrl");
  this.ssoCookieName=filterConfig.getInitParameter("ssoCookieName");
  this.loginUrl=filterConfig.getInitParameter("loginUrl");
  String casRenewTicketConfig=filterConfig.getInitParameter("casRenewTicket");
  if (casRenewTicketConfig != null) {
    this.casRenewTicket=Boolean.parseBoolean(casRenewTicketConfig);
  }
  String casServiceUrlConfig=filterConfig.getInitParameter("casServiceUrl");
  if (casServiceUrlConfig != null && casServiceUrlConfig.trim().length() > 0) {
    casServiceUrl=casServiceUrlConfig;
  }
  String maxNumberOfLoginErrorsConfig=filterConfig.getInitParameter("maxNumberOfLoginErrors");
  this.maxNumberOfLoginErrors=maxNumberOfLoginErrorsConfig == null ? DEFAULT_MAX_NUMBER_OF_LOGIN_ERRORS : Integer.parseInt(maxNumberOfLoginErrorsConfig);
  log.info("InitiateLoginFilter configuration: ssoServerUrl=" + this.ssoServerUrl + ", ssoCookieName="+ this.ssoCookieName+ ", loginUrl="+ this.loginUrl+ ", casRenewTicket="+ this.casRenewTicket+ ", casServiceUrl="+ this.casServiceUrl+ ", maxNumberOfLoginErrors="+ this.maxNumberOfLoginErrors);
}
 

Example 25

From project guj.com.br, under directory /src/br/com/caelum/guj/vraptor/filter/.

Source file: BookmarkableURIFilter.java

  15 
vote

private void createURICache(FilterConfig config) throws ServletException {
  URICache cacheFromContext=(URICache)config.getServletContext().getAttribute("URICache");
  if (cacheFromContext == null) {
    cache=new DefaultURICache();
    config.getServletContext().setAttribute("URICache",cache);
  }
 else {
    this.cache=cacheFromContext;
  }
}
 

Example 26

From project harmony, under directory /harmony.common.serviceinterface/src/main/java/org/opennaas/extensions/idb/serviceinterface/utils/.

Source file: CommonServletFilter.java

  15 
vote

@Override public void init(final FilterConfig arg0) throws ServletException {
  try {
    final Class<?> filterClass=Class.forName(Config.getString("databinding","secure.filter"));
    this.servletFiler=(Filter)filterClass.newInstance();
    this.servletFiler.init(arg0);
    PhLogger.getLogger().info("Security Filter successfully loaded");
  }
 catch (  final ClassNotFoundException e) {
    PhLogger.getLogger().info("No Security Filter available");
  }
catch (  final Exception e) {
    PhLogger.getLogger().error("Could not create Servlet Filter: " + e.getMessage(),e);
  }
}
 

Example 27

From project Hesperid, under directory /server/src/main/java/ch/astina/hesperid/installer/web/services/.

Source file: TapestryDelayedFilter.java

  15 
vote

/** 
 * Initializes the filter using the  {@link TapestryAppInitializer}. The application name is the capitalization of the filter name (as specified in web.xml).
 */
public final void init(FilterConfig filterConfig) throws ServletException {
  config=filterConfig;
  ServletContext context=config.getServletContext();
  String filterName=config.getFilterName();
  SymbolProvider scprovider=new ServletContextSymbolProvider(context);
  Map<String,String> configuration=new HashMap<String,String>();
  configuration.put(InternalConstants.DISABLE_DEFAULT_MODULES_PARAM,"true");
  configuration.put(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM,scprovider.valueForSymbol(TAPESTRY_INSTALLER_PACKAGE));
  SymbolProvider provider=new MapSymbolProvider(configuration);
  String executionMode=System.getProperty("tapestry.execution-mode","production");
  TapestryAppInitializer appInitializer=new TapestryAppInitializer(logger,provider,filterName,"servlet",executionMode);
  appInitializer.addModules(InstallerModule.class);
  String appPackage=provider.valueForSymbol(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM);
  String className=appPackage + ".services.InstallerModule";
  try {
    Class<?> moduleClass=Thread.currentThread().getContextClassLoader().loadClass(className);
    appInitializer.addModules(moduleClass);
  }
 catch (  ClassNotFoundException ex) {
  }
  registry=appInitializer.createRegistry();
  context.setAttribute(REGISTRY_CONTEXT_NAME,registry);
  ServletApplicationInitializer ai=registry.getService("ServletApplicationInitializer",ServletApplicationInitializer.class);
  ai.initializeApplication(filterConfig.getServletContext());
  registry.performRegistryStartup();
  handler=registry.getService("HttpServletRequestHandler",HttpServletRequestHandler.class);
  init(registry);
  InstallationManager installationManager=registry.getService(InstallationManager.class);
  if (installationManager.hasWorkingDatabaseConnection()) {
    this.installed=true;
    this.start();
  }
 else {
    appInitializer.announceStartup();
  }
}
 

Example 28

From project ipdburt, under directory /iddb-web/src/main/java/iddb/web/security/service/.

Source file: UserServiceFilter.java

  15 
vote

@Override public void init(FilterConfig filterConfig) throws ServletException {
  this.context=filterConfig.getServletContext();
  Map<String,String> local=SecurityConfig.getInstance().getSection("urls");
  if (local == null) {
    urls=Collections.emptyMap();
  }
 else {
    urls=new LinkedHashMap<String,Set<String>>();
    for (    Entry<String,String> entry : local.entrySet()) {
      Set<String> s=new LinkedHashSet<String>(Arrays.asList(entry.getValue().split(",")));
      urls.put(entry.getKey(),s);
    }
  }
}
 

Example 29

From project jAPS2, under directory /src/com/agiletec/apsadmin/system/dispatcher/.

Source file: FilterDispatcher.java

  15 
vote

@Override protected Dispatcher createDispatcher(FilterConfig filterConfig){
  Map<String,String> params=new HashMap<String,String>();
  for (Enumeration e=filterConfig.getInitParameterNames(); e.hasMoreElements(); ) {
    String name=(String)e.nextElement();
    String value=filterConfig.getInitParameter(name);
    params.put(name,value);
  }
  String struts2Config=this.getServletContext().getInitParameter(ApsAdminSystemConstants.STRUTS2_CONFIG_INIT_PARAM_NAME);
  if (null != struts2Config) {
    params.put("config",struts2Config);
  }
  return new Dispatcher(filterConfig.getServletContext(),params);
}
 

Example 30

From project java-cas-client, under directory /cas-client-core/src/main/java/org/jasig/cas/client/authentication/.

Source file: AuthenticationFilter.java

  15 
vote

protected void initInternal(final FilterConfig filterConfig) throws ServletException {
  if (!isIgnoreInitConfiguration()) {
    super.initInternal(filterConfig);
    setCasServerLoginUrl(getPropertyFromInitParams(filterConfig,"casServerLoginUrl",null));
    log.trace("Loaded CasServerLoginUrl parameter: " + this.casServerLoginUrl);
    setRenew(parseBoolean(getPropertyFromInitParams(filterConfig,"renew","false")));
    log.trace("Loaded renew parameter: " + this.renew);
    setGateway(parseBoolean(getPropertyFromInitParams(filterConfig,"gateway","false")));
    log.trace("Loaded gateway parameter: " + this.gateway);
    final String gatewayStorageClass=getPropertyFromInitParams(filterConfig,"gatewayStorageClass",null);
    if (gatewayStorageClass != null) {
      try {
        this.gatewayStorage=(GatewayResolver)Class.forName(gatewayStorageClass).newInstance();
      }
 catch (      final Exception e) {
        log.error(e,e);
        throw new ServletException(e);
      }
    }
  }
}
 

Example 31

From project jbpm-plugin, under directory /jbpm/src/main/java/hudson/jbpm/.

Source file: JbpmContextFilter.java

  15 
vote

public void init(FilterConfig filterConfig) throws ServletException {
  this.jbpmConfigurationResource=filterConfig.getInitParameter("jbpm.configuration.resource");
  this.jbpmContextName=filterConfig.getInitParameter("jbpm.context.name");
  if (jbpmContextName == null) {
    jbpmContextName=JbpmContext.DEFAULT_JBPM_CONTEXT_NAME;
  }
  String isAuthenticationEnabledText=filterConfig.getInitParameter("authentication");
  if ((isAuthenticationEnabledText != null) && ("disabled".equalsIgnoreCase(isAuthenticationEnabledText))) {
    isAuthenticationEnabled=false;
  }
}
 

Example 32

From project jira-hudson-integration, under directory /hudson-apiv2-plugin/src/main/java/com/marvelution/hudson/plugins/apiv2/servlet/filter/.

Source file: HudsonAPIV2FilterConfig.java

  15 
vote

/** 
 * Constructor
 * @param parentFilterConfig the original {@link FilterConfig} provided by Hudson at startup
 * @throws IOException in case the Application properties cannot be loaded
 */
public HudsonAPIV2FilterConfig(FilterConfig parentFilterConfig) throws IOException {
  this.parentFilterConfig=parentFilterConfig;
  initParams=new Properties();
  initParams.load(HudsonAPIV2FilterConfig.class.getResourceAsStream("HudsonAPIV2FilterConfig.properties"));
  Enumeration<?> elements=parentFilterConfig.getInitParameterNames();
  while (elements.hasMoreElements()) {
    String paramName=elements.nextElement().toString();
    if (!initParams.containsKey(paramName)) {
      initParams.setProperty(paramName,parentFilterConfig.getInitParameter(paramName));
    }
  }
}
 

Example 33

From project lightweightEE, under directory /gui/src/main/java/de/jaxenter/eesummit/caroline/gui/filter/.

Source file: LogFilter.java

  15 
vote

@Override public void init(FilterConfig config) throws ServletException {
  dropUrls=new ArrayList<String>();
  int idx=0;
  String dropUrlParam;
  while ((dropUrlParam=config.getInitParameter("dropurl." + idx)) != null) {
    logger.info("adding dropUrl " + idx + ": "+ dropUrlParam);
    dropUrls.add(dropUrlParam);
    idx++;
  }
  String ndcParam=config.getInitParameter("ndc");
  ndcEnabled=false;
  if (ndcParam != null) {
    logger.info("NDC enabled: " + ndcParam);
    ndcEnabled=true;
    ndcSession=ndcParam.indexOf("session") != -1;
    ndcAddress=ndcParam.indexOf("address") != -1;
  }
}
 

Example 34

From project logback, under directory /logback-access/src/main/java/ch/qos/logback/access/servlet/.

Source file: TeeFilter.java

  15 
vote

public void init(FilterConfig filterConfig) throws ServletException {
  String includeListAsStr=filterConfig.getInitParameter(TEE_FILTER_INCLUDES_PARAM);
  String excludeListAsStr=filterConfig.getInitParameter(TEE_FILTER_EXCLUDES_PARAM);
  String localhostName=getLocalhostName();
  active=computeActivation(localhostName,includeListAsStr,excludeListAsStr);
  if (active)   System.out.println("TeeFilter will be ACTIVE on this host [" + localhostName + "]");
 else   System.out.println("TeeFilter will be DISABLED on this host [" + localhostName + "]");
}
 

Example 35

From project milton, under directory /milton/milton-servlet/src/main/java/com/bradmcevoy/http/.

Source file: ApplicationConfig.java

  15 
vote

public ApplicationConfig(FilterConfig config){
  parameterNames=new ArrayList<String>();
  this.config=config;
  this.servletConfig=null;
  servletContext=config.getServletContext();
  if (config == null)   return;
  Enumeration en=config.getInitParameterNames();
  while (en.hasMoreElements()) {
    parameterNames.add((String)en.nextElement());
  }
}
 

Example 36

From project milton2, under directory /milton-server/src/main/java/io/milton/servlet/.

Source file: ApplicationConfig.java

  15 
vote

public ApplicationConfig(FilterConfig config){
  parameterNames=new ArrayList<String>();
  this.config=config;
  this.servletConfig=null;
  servletContext=config.getServletContext();
  if (config == null)   return;
  Enumeration en=config.getInitParameterNames();
  while (en.hasMoreElements()) {
    parameterNames.add((String)en.nextElement());
  }
}
 

Example 37

From project ncDiamond, under directory /src/compressionFilters/.

Source file: CompressionFilter.java

  15 
vote

/** 
 * Place this filter into service.
 * @param filterConfig The filter configuration object
 */
public void init(FilterConfig filterConfig){
  config=filterConfig;
  if (filterConfig != null) {
    String value=filterConfig.getInitParameter("debug");
    if (value != null) {
      debug=Integer.parseInt(value);
    }
 else {
      debug=0;
    }
    String str=filterConfig.getInitParameter("compressionThreshold");
    if (str != null) {
      compressionThreshold=Integer.parseInt(str);
      if (compressionThreshold != 0 && compressionThreshold < minThreshold) {
        if (debug > 0) {
          System.out.println("compressionThreshold should be either 0 - no compression or >= " + minThreshold);
          System.out.println("compressionThreshold set to " + minThreshold);
        }
        compressionThreshold=minThreshold;
      }
    }
 else {
      compressionThreshold=0;
    }
  }
 else {
    compressionThreshold=0;
  }
}
 

Example 38

From project netnumeri, under directory /lib/gwt-2.5.0.rc1/samples/DynaTableRf/src/main/java/com/google/gwt/sample/dynatablerf/server/.

Source file: SchoolCalendarService.java

  15 
vote

public void init(FilterConfig config){
  backingStore=(PersonSource)config.getServletContext().getAttribute(SchoolCalendarService.class.getName());
  if (backingStore == null) {
    List<Person> randomPeople=PersonFuzzer.generateRandomPeople();
    scheduleStore=ScheduleSource.of(PersonFuzzer.collectSchedules(randomPeople));
    backingStore=PersonSource.of(randomPeople,scheduleStore);
    config.getServletContext().setAttribute(SchoolCalendarService.class.getName(),backingStore);
  }
}
 

Example 39

From project nuxeo-filesystem-connectors, under directory /nuxeo-generic-wss-front/src/main/java/org/nuxeo/wss/servlet/.

Source file: BaseWSSFilter.java

  15 
vote

@Override public void init(FilterConfig filterConfig) throws ServletException {
  if (filterConfig != null) {
    this.ctx=filterConfig.getServletContext();
  }
synchronized (this.getClass()) {
    initHandlers(filterConfig);
    this.filterConfig=filterConfig;
    if (filterConfig != null) {
      initBackend(filterConfig);
    }
  }
}
 

Example 40

From project nuxeo-opensocial, under directory /nuxeo-opensocial-server/src/main/java/org/nuxeo/opensocial/servlet/.

Source file: AuthenticationFilterDelayer.java

  15 
vote

public void init(FilterConfig filterConfig) throws ServletException {
  delayedConfig=filterConfig;
  if (hasBeenActivated) {
    try {
      delayed.init(filterConfig);
    }
 catch (    UnavailableException e) {
      log.error(e.getMessage());
      return;
    }
    ready=true;
  }
}
 

Example 41

From project nuxeo-services, under directory /nuxeo-platform-web-common/src/main/java/org/nuxeo/ecm/platform/ui/web/auth/.

Source file: NuxeoAuthenticationFilter.java

  15 
vote

public void init(FilterConfig config) throws ServletException {
  String val=config.getInitParameter("byPassAuthenticationLog");
  if (val != null && Boolean.parseBoolean(val)) {
    byPassAuthenticationLog=true;
  }
  val=config.getInitParameter("securityDomain");
  if (val != null) {
    securityDomain=val;
  }
}
 

Example 42

From project nuxeo-webengine, under directory /nuxeo-webengine-gwt/src/main/java/org/nuxeo/ecm/webengine/gwt/dev/.

Source file: NuxeoLauncher.java

  15 
vote

@Override public synchronized void init(FilterConfig config) throws ServletException {
  if (app != null) {
    return;
  }
  System.setProperty(GwtBundleActivator.GWT_DEV_MODE_PROP,"true");
  app=createApplication(config);
  Runtime.getRuntime().addShutdownHook(new Thread("Nuxeo Server Shutdown"){
    @Override public void run(){
      try {
        if (app != null) {
          app.shutdown();
        }
      }
 catch (      Exception e) {
        log.error(e,e);
      }
    }
  }
);
  super.init(config);
}
 

Example 43

From project ohmageServer, under directory /src/org/ohmage/jee/filter/.

Source file: OhmageCORSFilter.java

  15 
vote

/** 
 * Called on web application start up. Performs initialization based on web.xml and stores any disallowed URIs locally. The disallowed URI list may be overriden by setting the value for the cors-lenient-mode key to true in the database's preference table. If lenient mode is enabled, all URIs allow Cross-Origin requests.
 */
@Override public void init(final FilterConfig filterConfig) throws ServletException {
  super.init(filterConfig);
  boolean strict=true;
  try {
    Boolean lenientMode=StringUtils.decodeBoolean(PreferenceCache.instance().lookup(PreferenceCache.KEY_CORS_LENIENT_MODE));
    if (lenientMode != null && lenientMode) {
      LOGGER.info(PreferenceCache.KEY_CORS_LENIENT_MODE + " enabled");
      strict=false;
    }
  }
 catch (  CacheMissException cacheMiss) {
    LOGGER.info(PreferenceCache.KEY_CORS_LENIENT_MODE + " not found: defaulting to strict.");
  }
  if (strict) {
    Enumeration<?> en=filterConfig.getInitParameterNames();
    while (en.hasMoreElements()) {
      String key=(String)en.nextElement();
      if (key.equals("disallowedURIs")) {
        String value=filterConfig.getInitParameter(key);
        String[] uris=value.split(",");
        disallowedURIs=new ArrayList<String>();
        for (        String uri : uris) {
          disallowedURIs.add(RequestBuilder.getInstance().getRoot() + uri);
        }
        break;
      }
    }
  }
  if (disallowedURIs == null) {
    LOGGER.info("All URIs allowed for CORS");
    disallowedURIs=Collections.emptyList();
  }
 else {
    LOGGER.info("The following URIs have been disallowed for CORS: " + disallowedURIs);
  }
}
 

Example 44

From project Openbravo-POS-iPhone-App, under directory /OpenbravoPOS_PDA/src-pda/com/openbravo/pos/pda/struts/filter/.

Source file: PdaFilter.java

  15 
vote

/** 
 * Init method for this filter 
 */
public void init(FilterConfig filterConfig){
  this.filterConfig=filterConfig;
  if (filterConfig != null) {
    if (debug) {
      log("PdaFilter:Initializing filter");
    }
  }
}
 

Example 45

From project openwebbeans, under directory /webbeans-web/src/main/java/org/apache/webbeans/servlet/.

Source file: WebBeansConfigurationFilter.java

  15 
vote

/** 
 * {@inheritDoc}
 */
public void init(FilterConfig filterConfig) throws ServletException {
  this.lifeCycle=webBeansContext.getService(ContainerLifecycle.class);
  try {
    this.servletContext=filterConfig.getServletContext();
    this.lifeCycle.startApplication(new ServletContextEvent(this.servletContext));
  }
 catch (  Exception e) {
    logger.log(Level.SEVERE,WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0018,ServletCompatibilityUtil.getServletInfo(servletContext)));
    WebBeansUtil.throwRuntimeExceptions(e);
  }
}
 

Example 46

From project org.ops4j.pax.web, under directory /pax-web-runtime/src/it/java/org/ops4j/pax/web/service/internal/.

Source file: FilterTest.java

  15 
vote

@Test public void filterIsCalledOnUrlPattern() throws NamespaceException, ServletException, IOException {
  Servlet servlet=createMock(Servlet.class);
  servlet.init((ServletConfig)notNull());
  servlet.destroy();
  Filter filter=createMock(Filter.class);
  filter.init((FilterConfig)notNull());
  filter.doFilter((ServletRequest)notNull(),(ServletResponse)notNull(),(FilterChain)notNull());
  filter.destroy();
  replay(servlet,filter);
  HttpContext context=m_httpService.createDefaultHttpContext();
  m_httpService.registerServlet("/test",servlet,null,context);
  m_httpService.registerFilter(filter,new String[]{"/*"},null,context);
  HttpMethod method=new GetMethod("http://localhost:8080/test");
  m_client.executeMethod(method);
  method.releaseConnection();
  m_httpService.unregister("/test");
  m_httpService.unregisterFilter(filter);
  verify(servlet,filter);
}
 

Example 47

From project orion.server, under directory /bundles/org.eclipse.orion.server.useradmin/src/org/eclipse/orion/server/useradmin/servlets/.

Source file: UserAuthFilter.java

  15 
vote

public void init(FilterConfig filterConfig) throws ServletException {
  authenticationService=UserAdminActivator.getDefault().getAuthenticationService();
  if (authenticationService == null) {
    String msg="Authentication service is missing. The server configuration must specify an authentication scheme, or use \"None\" to indicate no authentication";
    LogHelper.log(new Status(IStatus.ERROR,UserAdminActivator.PI_USERADMIN,msg,null));
    throw new ServletException(msg);
  }
  String creators=PreferenceHelper.getString(ServerConstants.CONFIG_AUTH_USER_CREATION,null);
  if (creators != null) {
    authorizedAccountCreators=new ArrayList<String>();
    authorizedAccountCreators.addAll(Arrays.asList(creators.split(",")));
  }
}
 

Example 48

From project Possom, under directory /war/src/main/java/no/sesat/search/http/filters/.

Source file: SiteLocatorFilter.java

  15 
vote

/** 
 * Init method for this filter
 */
@Override public void init(final FilterConfig filterConfig){
  this.filterConfig=filterConfig;
  if (filterConfig != null) {
    LOG.debug("Initializing filter");
  }
}
 

Example 49

From project qi4j-libraries, under directory /struts2-plugin/src/main/java/org/qi4j/library/struts2/.

Source file: Qi4jFilterDispatcher.java

  15 
vote

@Override protected Dispatcher createDispatcher(final FilterConfig filterConfig){
  Dispatcher dispatcher=super.createDispatcher(filterConfig);
  ConfigurationManager configurationManager=createConfigurationManager(filterConfig);
  dispatcher.setConfigurationManager(configurationManager);
  return dispatcher;
}
 

Example 50

From project repose, under directory /project-set/commons/utilities/src/main/java/com/rackspace/papi/commons/util/servlet/filter/.

Source file: ApplicationContextAwareFilter.java

  15 
vote

@Override public void init(FilterConfig filterConfig) throws ServletException {
  final String adapterClassName=filterConfig.getInitParameter(InitParameter.APP_CONTEXT_ADAPTER_CLASS.getParameterName());
  if (adapterClassName != null && !"".equals(adapterClassName)) {
    try {
      final Object freshAdapter=Class.forName(adapterClassName).newInstance();
      if (freshAdapter instanceof ApplicationContextAdapter) {
        applicationContextAdapter=(ApplicationContextAdapter)freshAdapter;
        applicationContextAdapter.usingServletContext(filterConfig.getServletContext());
      }
 else {
        throw new ContextAdapterResolutionException("Unknown application context adapter class: " + adapterClassName);
      }
    }
 catch (    Exception ex) {
      throw new ContextAdapterResolutionException("Failure on ApplicationContextAwareFilter.init(...). Reason: " + ex.getMessage(),ex);
    }
  }
}
 

Example 51

From project rewrite, under directory /impl-servlet/src/main/java/org/ocpsoft/rewrite/servlet/.

Source file: RewriteFilter.java

  15 
vote

@Override @SuppressWarnings("unchecked") public void init(final FilterConfig filterConfig) throws ServletException {
  log.info("RewriteFilter starting up...");
  listeners=Iterators.asList(ServiceLoader.load(RewriteLifecycleListener.class));
  wrappers=Iterators.asList(ServiceLoader.load(RequestCycleWrapper.class));
  providers=Iterators.asList(ServiceLoader.load(RewriteProvider.class));
  inbound=Iterators.asList(ServiceLoader.load(InboundRewriteProducer.class));
  outbound=Iterators.asList(ServiceLoader.load(OutboundRewriteProducer.class));
  Collections.sort(listeners,new WeightedComparator());
  Collections.sort(wrappers,new WeightedComparator());
  Collections.sort(providers,new WeightedComparator());
  Collections.sort(inbound,new WeightedComparator());
  Collections.sort(outbound,new WeightedComparator());
  ServiceLogger.logLoadedServices(log,RewriteLifecycleListener.class,listeners);
  ServiceLogger.logLoadedServices(log,RequestCycleWrapper.class,wrappers);
  ServiceLogger.logLoadedServices(log,RewriteProvider.class,providers);
  ServiceLogger.logLoadedServices(log,InboundRewriteProducer.class,inbound);
  ServiceLogger.logLoadedServices(log,OutboundRewriteProducer.class,outbound);
  ServiceLogger.logLoadedServices(log,ContextListener.class,Iterators.asList(ServiceLoader.load(ContextListener.class)));
  ServiceLogger.logLoadedServices(log,RequestListener.class,Iterators.asList(ServiceLoader.load(RequestListener.class)));
  ServiceLogger.logLoadedServices(log,RequestParameterProvider.class,Iterators.asList(ServiceLoader.load(RequestParameterProvider.class)));
  ServiceLogger.logLoadedServices(log,ExpressionLanguageProvider.class,Iterators.asList(ServiceLoader.load(ExpressionLanguageProvider.class)));
  ServiceLogger.logLoadedServices(log,InvocationResultHandler.class,Iterators.asList(ServiceLoader.load(InvocationResultHandler.class)));
  ServiceLogger.logLoadedServices(log,ServiceEnricher.class,Iterators.asList(ServiceLoader.load(ServiceEnricher.class)));
  ServiceLogger.logLoadedServices(log,ConfigurationCacheProvider.class,Iterators.asList(ServiceLoader.load(ConfigurationCacheProvider.class)));
  List<ConfigurationProvider<?>> configurations=Iterators.asList(ServiceLoader.load(ConfigurationProvider.class));
  ServiceLogger.logLoadedServices(log,ConfigurationProvider.class,configurations);
  for (  RewriteProvider<ServletContext,Rewrite> provider : providers) {
    if (provider instanceof ServletRewriteProvider)     ((ServletRewriteProvider<?>)provider).init(filterConfig.getServletContext());
  }
  if ((configurations == null) || configurations.isEmpty()) {
    log.warn("No ConfigurationProviders were registered: " + "Rewrite will not be enabled on this application. " + "Did you forget to create a '/META-INF/services/" + ConfigurationProvider.class.getName() + " file containing the fully qualified name of your provider implementation?");
  }
  log.info("RewriteFilter initialized.");
}
 

Example 52

From project rolefen, under directory /dependency/apache-tomcat-6.0.26/webapps/examples/WEB-INF/classes/compressionFilters/.

Source file: CompressionFilter.java

  15 
vote

/** 
 * Place this filter into service.
 * @param filterConfig The filter configuration object
 */
public void init(FilterConfig filterConfig){
  config=filterConfig;
  if (filterConfig != null) {
    String value=filterConfig.getInitParameter("debug");
    if (value != null) {
      debug=Integer.parseInt(value);
    }
 else {
      debug=0;
    }
    String str=filterConfig.getInitParameter("compressionThreshold");
    if (str != null) {
      compressionThreshold=Integer.parseInt(str);
      if (compressionThreshold != 0 && compressionThreshold < minThreshold) {
        if (debug > 0) {
          System.out.println("compressionThreshold should be either 0 - no compression or >= " + minThreshold);
          System.out.println("compressionThreshold set to " + minThreshold);
        }
        compressionThreshold=minThreshold;
      }
    }
 else {
      compressionThreshold=0;
    }
  }
 else {
    compressionThreshold=0;
  }
}
 

Example 53

From project rollyourowncbf, under directory /apache-tomcat-6.0.32/webapps/examples/WEB-INF/classes/compressionFilters/.

Source file: CompressionFilter.java

  15 
vote

/** 
 * Place this filter into service.
 * @param filterConfig The filter configuration object
 */
public void init(FilterConfig filterConfig){
  config=filterConfig;
  if (filterConfig != null) {
    String value=filterConfig.getInitParameter("debug");
    if (value != null) {
      debug=Integer.parseInt(value);
    }
 else {
      debug=0;
    }
    String str=filterConfig.getInitParameter("compressionThreshold");
    if (str != null) {
      compressionThreshold=Integer.parseInt(str);
      if (compressionThreshold != 0 && compressionThreshold < minThreshold) {
        if (debug > 0) {
          System.out.println("compressionThreshold should be either 0 - no compression or >= " + minThreshold);
          System.out.println("compressionThreshold set to " + minThreshold);
        }
        compressionThreshold=minThreshold;
      }
    }
 else {
      compressionThreshold=0;
    }
  }
 else {
    compressionThreshold=0;
  }
}
 

Example 54

From project sandbox_2, under directory /wicket-portlet/src/main/java/org/apache/wicket/protocol/http/portlet/.

Source file: WicketFilterPortletContext.java

  15 
vote

/** 
 * Sets up the filter to process a given request cycle. Potentially wraps the request and response objects with portlet specific wrappers. <p> Also sets up the session proxy using Apache Portals Bridge to ensure portlet session isolation. This is an option feature of Portal 2.0 spec so we just use portal bridges instead as it guarantees us support.
 * @see org.apache.portals.bridges.util.ServletPortletSessionProxy
 * @param config filter configuration
 * @param filterRequestContext
 * @param filterPath
 * @return true if we are in a portlet environment
 * @throws IOException
 * @throws ServletException
 */
public boolean setupFilter(final FilterConfig config,final FilterRequestContext filterRequestContext,final String filterPath) throws IOException, ServletException {
  boolean inPortletContext=false;
  final PortletConfig portletConfig=(PortletConfig)filterRequestContext.getRequest().getAttribute("javax.portlet.config");
  if (portletConfig != null) {
    inPortletContext=true;
    final PortletRequest portletRequest=(PortletRequest)filterRequestContext.getRequest().getAttribute("javax.portlet.request");
    final WicketResponseState responseState=(WicketResponseState)filterRequestContext.getRequest().getAttribute(WicketPortlet.RESPONSE_STATE_ATTR);
    filterRequestContext.setRequest(new PortletServletRequestWrapper(config.getServletContext(),filterRequestContext.getRequest(),ServletPortletSessionProxy.createProxy(filterRequestContext.getRequest(),portletRequest.getWindowID()),filterPath));
    filterRequestContext.setResponse(new PortletServletResponseWrapper(filterRequestContext.getResponse(),responseState));
  }
 else {
    final ServletContext context=config.getServletContext();
    final HttpServletRequest request=filterRequestContext.getRequest();
    String pathInfo=request.getRequestURI().substring(request.getContextPath().length() + filterPath.length());
    final String portletWindowId=decodePortletWindowId(pathInfo);
    if (portletWindowId != null) {
      final HttpSession proxiedSession=ServletPortletSessionProxy.createProxy(request,portletWindowId);
      pathInfo=_stripWindowIdFromPathInfo(pathInfo);
      filterRequestContext.setRequest(new PortletServletRequestWrapper(context,request,proxiedSession,filterPath,pathInfo));
    }
  }
  return inPortletContext;
}
 

Example 55

From project scooter, under directory /source/src/com/scooterframework/web/controller/.

Source file: WebPageCachingFilter.java

  15 
vote

@Override public void doInit(FilterConfig filterConfig) throws CacheException {
  String propertyFileName=filterConfig.getInitParameter("configFile");
  if (propertyFileName == null)   propertyFileName="ehcache.xml";
  try {
    String appPath=ApplicationConfig.getInstance().getApplicationPath();
    File f=new File(appPath + File.separatorChar + "WEB-INF/config"+ File.separatorChar+ propertyFileName);
    if (f.exists()) {
      cacheManager=CacheManager.create(new FileInputStream(f));
      log.debug("Created cacheManager based on config file 'WEB-INF/config/" + f.getName() + "'.");
    }
 else {
      throw new IOException("There is no file named " + propertyFileName + " under WEB-INF/config directory.");
    }
  }
 catch (  IOException ex) {
    throw new IllegalArgumentException("Failed to load EhCache config file '" + propertyFileName + "' : "+ ex.getMessage());
  }
  String uncacheablePathsStr=filterConfig.getInitParameter("uncacheablePaths");
  if (uncacheablePathsStr != null) {
    uncacheablePaths=Converters.convertStringToSet(uncacheablePathsStr);
  }
  String cacheablePathsStr=filterConfig.getInitParameter("cacheablePaths");
  if (cacheablePathsStr != null) {
    cacheablePaths=Converters.convertStringToSet(cacheablePathsStr);
  }
  super.doInit(filterConfig);
}
 

Example 56

From project Solbase-Solr, under directory /src/webapp/src/org/apache/solr/servlet/.

Source file: SolrDispatchFilter.java

  15 
vote

public void init(FilterConfig config) throws ServletException {
  log.info("SolrDispatchFilter.init()");
  boolean abortOnConfigurationError=true;
  CoreContainer.Initializer init=createInitializer();
  try {
    this.pathPrefix=config.getInitParameter("path-prefix");
    init.setSolrConfigFilename(config.getInitParameter("solrconfig-filename"));
    this.cores=init.initialize();
    abortOnConfigurationError=init.isAbortOnConfigurationError();
    log.info("user.dir=" + System.getProperty("user.dir"));
  }
 catch (  Throwable t) {
    log.error("Could not start SOLR. Check solr/home property",t);
    SolrConfig.severeErrors.add(t);
    SolrCore.log(t);
  }
  if (abortOnConfigurationError && SolrConfig.severeErrors.size() > 0) {
    StringWriter sw=new StringWriter();
    PrintWriter out=new PrintWriter(sw);
    out.println("Severe errors in solr configuration.\n");
    out.println("Check your log files for more detailed information on what may be wrong.\n");
    out.println("If you want solr to continue after configuration errors, change: \n");
    out.println(" <abortOnConfigurationError>false</abortOnConfigurationError>\n");
    out.println("in " + init.getSolrConfigFilename() + "\n");
    for (    Throwable t : SolrConfig.severeErrors) {
      out.println("-------------------------------------------------------------");
      t.printStackTrace(out);
    }
    out.flush();
    abortErrorMessage=sw.toString();
  }
  log.info("SolrDispatchFilter.init() done");
}
 

Example 57

From project solder, under directory /impl/src/main/java/org/jboss/solder/servlet/exception/.

Source file: CatchExceptionFilter.java

  15 
vote

public void init(FilterConfig config) throws ServletException {
  try {
    if (!getBeanManager().getBeans(CatchExceptionFilter.class).isEmpty()) {
      enabled=true;
      log.catchIntegrationEnabled();
    }
  }
 catch (  BeanManagerUnavailableException e) {
    log.catchIntegrationDisabledNoBeanManager();
  }
}
 

Example 58

From project spark_1, under directory /src/main/java/spark/servlet/.

Source file: FilterTools.java

  15 
vote

static String getFilterPath(FilterConfig config){
  String result=config.getInitParameter(FILTER_MAPPING_PARAM);
  if (result == null || result.equals(SLASH_WILDCARD)) {
    return "";
  }
 else   if (!result.startsWith(SLASH) || !result.endsWith(SLASH_WILDCARD)) {
    throw new RuntimeException("The " + FILTER_MAPPING_PARAM + " must start with \"/\" and end with \"/*\". It's: "+ result);
  }
  return result.substring(1,result.length() - 1);
}
 

Example 59

From project spring-security, under directory /web/src/test/java/org/springframework/security/web/authentication/.

Source file: AnonymousAuthenticationFilterTests.java

  15 
vote

@Test public void testOperationWhenAuthenticationExistsInContextHolder() throws Exception {
  Authentication originalAuth=new TestingAuthenticationToken("user","password","ROLE_A");
  SecurityContextHolder.getContext().setAuthentication(originalAuth);
  AnonymousAuthenticationFilter filter=new AnonymousAuthenticationFilter("qwerty","anonymousUsername",AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));
  MockHttpServletRequest request=new MockHttpServletRequest();
  request.setRequestURI("x");
  executeFilterInContainerSimulator(mock(FilterConfig.class),filter,request,new MockHttpServletResponse(),new MockFilterChain(true));
  assertEquals(originalAuth,SecurityContextHolder.getContext().getAuthentication());
}
 

Example 60

From project springside4, under directory /examples/showcase/src/main/java/org/springside/examples/showcase/demos/web/.

Source file: CacheControlHeaderFilter.java

  15 
vote

/** 
 * @see Filter#init(FilterConfig)
 */
@Override public void init(FilterConfig filterConfig){
  String expiresSecondsParam=filterConfig.getInitParameter(PARAM_EXPIRES_SECONDS);
  if (expiresSecondsParam != null) {
    expiresSeconds=Long.valueOf(expiresSecondsParam);
  }
 else {
    expiresSeconds=Servlets.ONE_YEAR_SECONDS;
  }
}
 

Example 61

From project tiles, under directory /tiles-servlet/src/main/java/org/apache/tiles/web/util/.

Source file: TilesDecorationFilter.java

  15 
vote

/** 
 * {@inheritDoc} 
 */
public void init(FilterConfig config) throws ServletException {
  filterConfig=config;
  servletContext=filterConfig.getServletContext();
  containerKey=filterConfig.getInitParameter(CONTAINER_KEY_INIT_PARAMETER);
  String temp=config.getInitParameter("attribute-name");
  if (temp != null) {
    definitionAttributeName=temp;
  }
  temp=config.getInitParameter("definition");
  if (temp != null) {
    definitionName=temp;
  }
  temp=config.getInitParameter("prevent-token");
  preventDecorationToken="org.apache.tiles.decoration.PREVENT:" + (temp == null ? definitionName : temp);
  alternateDefinitions=parseAlternateDefinitions();
  temp=config.getInitParameter("mutator");
  if (temp != null) {
    try {
      mutator=(AttributeContextMutator)ClassUtil.instantiate(temp);
    }
 catch (    CannotInstantiateObjectException e) {
      throw new ServletException("Unable to instantiate specified context mutator.",e);
    }
  }
 else {
    mutator=new DefaultMutator();
  }
}
 

Example 62

From project tocollege.net, under directory /src/main/java/com/apress/progwt/server/util/.

Source file: GearsManifestFilter.java

  15 
vote

public void init(FilterConfig filterConfig){
  _extensions=filterConfig.getInitParameter(EXTENSIONS);
  _manifestVersion=filterConfig.getInitParameter(MANIFEST_VERSION);
  System.out.println("Extensions: " + _extensions);
  String realPath=filterConfig.getServletContext().getRealPath("/");
  System.out.println("Path:" + realPath);
  File dir=new File(realPath);
  List<String> resourceFilenames=new GearResourcesExplorer().list(dir,new GearRegexpFilenameFilter(_extensions),true,true);
  for (int i=0; i < resourceFilenames.size(); i++) {
    System.out.println("File: " + resourceFilenames.get(i));
  }
  FilenameFilter noCacheFilter=new FilenameFilter(){
    public boolean accept(    File dir,    String name){
      if (name.endsWith(".nocache.js") && !name.endsWith("-xs.nocache.js"))       return true;
      return false;
    }
  }
;
  String[] noCacheFilenames=dir.list(noCacheFilter);
  if (noCacheFilenames.length != 1) {
    System.out.println("Error !!");
  }
 else {
    getResourcesAccordingUserAgent(realPath + noCacheFilenames[0]);
  }
  _manifestMap.put(Browser.SAFARI,createManifest(Browser.SAFARI.getCacheFileName(),_manifestVersion,resourceFilenames));
  _manifestMap.put(Browser.GECKO,createManifest(Browser.GECKO.getCacheFileName(),_manifestVersion,resourceFilenames));
  _manifestMap.put(Browser.GECKO1_8,createManifest(Browser.GECKO1_8.getCacheFileName(),_manifestVersion,resourceFilenames));
  _manifestMap.put(Browser.OPERA,createManifest(Browser.OPERA.getCacheFileName(),_manifestVersion,resourceFilenames));
  _manifestMap.put(Browser.IE6,createManifest(Browser.IE6.getCacheFileName(),_manifestVersion,resourceFilenames));
}
 

Example 63

From project torquebox, under directory /modules/web/src/main/java/org/torquebox/web/servlet/.

Source file: RackFilter.java

  15 
vote

public void init(FilterConfig filterConfig) throws ServletException {
  ServiceRegistry registry=(ServiceRegistry)filterConfig.getServletContext().getAttribute("service.registry");
  ServiceName componentResolverServiceName=(ServiceName)filterConfig.getServletContext().getAttribute("component.resolver.service-name");
  this.componentResolver=(ComponentResolver)registry.getService(componentResolverServiceName).getValue();
  if (this.componentResolver == null) {
    throw new ServletException("Unable to obtain Rack component resolver: " + componentResolverServiceName);
  }
  ServiceName runtimePoolServiceName=(ServiceName)filterConfig.getServletContext().getAttribute("runtime.pool.service-name");
  this.runtimePool=(RubyRuntimePool)registry.getService(runtimePoolServiceName).getValue();
  if (this.runtimePool == null) {
    throw new ServletException("Unable to obtain runtime pool: " + runtimePoolServiceName);
  }
  this.servletContext=filterConfig.getServletContext();
}
 

Example 64

From project turismo, under directory /src/main/java/com/ghosthack/turismo/multipart/.

Source file: MultipartFilter.java

  15 
vote

/** 
 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
 */
public void init(FilterConfig config) throws ServletException {
  final String charsetName=config.getInitParameter(CHARSET_NAME_PARAMETER);
  if (charsetName != null) {
    MultipartFilter.CHARSET_NAME=charsetName;
  }
}
 

Example 65

From project usergrid-stack, under directory /rest/src/main/java/org/usergrid/rest/.

Source file: SwaggerServlet.java

  15 
vote

@Override public void init(FilterConfig config) throws ServletException {
  logger.info("init(FilterConfig paramFilterConfig)");
  if (sc == null) {
    sc=config.getServletContext();
  }
  properties=(Properties)getSpringBeanFromWeb("properties");
  loadSwagger();
}
 

Example 66

From project vraptor, under directory /vraptor-core/src/main/java/br/com/caelum/vraptor/.

Source file: VRaptor.java

  15 
vote

public void init(FilterConfig cfg) throws ServletException {
  servletContext=cfg.getServletContext();
  BasicConfiguration config=new BasicConfiguration(servletContext);
  init(config.getProvider());
  logger.info("VRaptor 3.5.0-SNAPSHOT successfuly initialized");
}
 

Example 67

From project waffle, under directory /Source/ThirdParty/tomcat/webapps/examples/WEB-INF/classes/compressionFilters/.

Source file: CompressionFilter.java

  15 
vote

/** 
 * Place this filter into service.
 * @param filterConfig The filter configuration object
 */
public void init(FilterConfig filterConfig){
  config=filterConfig;
  if (filterConfig != null) {
    String value=filterConfig.getInitParameter("debug");
    if (value != null) {
      debug=Integer.parseInt(value);
    }
 else {
      debug=0;
    }
    String str=filterConfig.getInitParameter("compressionThreshold");
    if (str != null) {
      compressionThreshold=Integer.parseInt(str);
      if (compressionThreshold != 0 && compressionThreshold < minThreshold) {
        if (debug > 0) {
          System.out.println("compressionThreshold should be either 0 - no compression or >= " + minThreshold);
          System.out.println("compressionThreshold set to " + minThreshold);
        }
        compressionThreshold=minThreshold;
      }
    }
 else {
      compressionThreshold=0;
    }
  }
 else {
    compressionThreshold=0;
  }
}
 

Example 68

From project wayback, under directory /wayback-core/src/main/java/org/archive/wayback/resourceindex/updater/.

Source file: RemoteSubmitFilter.java

  15 
vote

@SuppressWarnings("unchecked") public void init(FilterConfig c) throws ServletException {
  Properties p=new Properties();
  ServletContext sc=c.getServletContext();
  for (Enumeration e=sc.getInitParameterNames(); e.hasMoreElements(); ) {
    String key=(String)e.nextElement();
    p.put(key,sc.getInitParameter(key));
  }
  for (Enumeration e=c.getInitParameterNames(); e.hasMoreElements(); ) {
    String key=(String)e.nextElement();
    p.put(key,c.getInitParameter(key));
  }
  String cfgName=INCOMING_PATH;
  String incomingPath=p.getProperty(cfgName);
  if ((incomingPath == null) || incomingPath.length() == 0) {
    throw new ServletException("Invalid or missing " + cfgName + " configuration");
  }
  incoming=new File(incomingPath);
  tmpIncoming=new File(incoming,"tmp");
  try {
    ensureDir(incoming);
    ensureDir(tmpIncoming);
  }
 catch (  IOException e) {
    throw new ServletException(e);
  }
}
 

Example 69

From project webutilities, under directory /src/main/java/com/googlecode/webutilities/filters/.

Source file: CharacterEncodingFilter.java

  15 
vote

public void init(FilterConfig config) throws ServletException {
  super.init(config);
  this.encoding=filterConfig.getInitParameter(INIT_PARAM_ENCODING);
  this.force=readBoolean(filterConfig.getInitParameter(INIT_PARAM_FORCE),this.force);
  LOGGER.debug("Filter initialized with: {}:{}, {}:{}",new Object[]{INIT_PARAM_ENCODING,encoding,INIT_PARAM_FORCE,force.toString()});
}
 

Example 70

From project ws, under directory /exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/.

Source file: AliasedURLRequestRedirector.java

  15 
vote

/** 
 * Filter initialization method.
 * @param conf filter configuration
 * @throws ServletException exception
 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
 */
@SuppressWarnings("unchecked") public void init(FilterConfig conf) throws ServletException {
  Enumeration<String> enumeration=conf.getInitParameterNames();
  while (enumeration.hasMoreElements()) {
    String key=(String)enumeration.nextElement();
    String val=conf.getInitParameter(key);
    replaceMap.put(key,val);
  }
}
 

Example 71

From project zengsource-mvc, under directory /src/src/main/java/org/zengsource/mvc/.

Source file: SetCharacterEncodingFilter.java

  15 
vote

public void init(FilterConfig filterConfig) throws ServletException {
  this.filterConfig=filterConfig;
  this.encoding=filterConfig.getInitParameter("encoding");
  String value=filterConfig.getInitParameter("ignore");
  if (value == null)   this.ignore=true;
 else   if (value.equalsIgnoreCase("true"))   this.ignore=true;
 else   if (value.equalsIgnoreCase("yes"))   this.ignore=true;
 else   this.ignore=false;
}
 

Example 72

From project zxing, under directory /zxingorg/src/com/google/zxing/web/.

Source file: DoSFilter.java

  15 
vote

@Override public void init(FilterConfig filterConfig){
  context=filterConfig.getServletContext();
  timer.scheduleAtFixedRate(new ResetTask(),0L,MAX_ACCESS_INTERVAL_MSEC);
  timer.scheduleAtFixedRate(new UnbanTask(),0L,UNBAN_INTERVAL_MSEC);
  badIPAddresses.clear();
  String badIPsString=filterConfig.getInitParameter(BAD_IPS_INIT_PARAM);
  if (badIPsString != null) {
    badIPAddresses.addAll(Arrays.asList(badIPsString.split(",")));
  }
}