public void init(FilterConfig filterConfig) throws ServletException {
   this.encoding = filterConfig.getInitParameter("encoding");
   String fe = filterConfig.getInitParameter("forceEncoding");
   if (StringUtils.isNotBlank(fe)) {
     this.forceEncoding = Boolean.parseBoolean(fe);
   }
 }
 public void init(FilterConfig filterConfig) throws ServletException {
   super.init(filterConfig);
   resourceSearchPackage =
       filterConfig.getInitParameter(KatharsisProperties.RESOURCE_SEARCH_PACKAGE);
   resourceDefaultDomain =
       filterConfig.getInitParameter(KatharsisProperties.RESOURCE_DEFAULT_DOMAIN);
 }
 /* (non-Javadoc)
  * @see esg.orp.app.PolicyServiceFilterCollaborator#init(javax.servlet.FilterConfig)
  */
 public void init(FilterConfig filterConfig) {
   String authRequiredPatternStr =
       filterConfig.getInitParameter(Parameters.AUTHENTICATION_REQUIRED_PATTERNS);
   String authNotRequiredPatternStr =
       filterConfig.getInitParameter(Parameters.AUTHENTICATION_NOT_REQUIRED_PATTERNS);
   if ((authRequiredPatternStr != null) && (authNotRequiredPatternStr != null)) {
     LOG.error(
         String.format(
             "Only one of the initialisation parameters %s and %s should be specified.",
             Parameters.AUTHENTICATION_REQUIRED_PATTERNS,
             Parameters.AUTHENTICATION_NOT_REQUIRED_PATTERNS));
   }
   String patternStr = null;
   // Find the pattern parameter - if both are specified, only act on the access denied patterns.
   if (authNotRequiredPatternStr != null) {
     patternStr = authNotRequiredPatternStr;
     matchResult = false;
   } else if (authRequiredPatternStr != null) {
     patternStr = authRequiredPatternStr;
     matchResult = true;
   }
   if (patternStr == null) {
     LOG.error(
         String.format(
             "One of the initialisation parameters %s and %s should be specified.",
             Parameters.AUTHENTICATION_REQUIRED_PATTERNS,
             Parameters.AUTHENTICATION_NOT_REQUIRED_PATTERNS));
     // Default to requiring authorization for all URLs.
     patternStr = "";
     matchResult = false;
   }
   patterns = parsePatternString(patternStr);
 }
    /**
     * Create new FilterConfigPropertyValues.
     *
     * @param config FilterConfig we'll use to take PropertyValues from
     * @param requiredProperties set of property names we need, where we can't accept default values
     * @throws ServletException if any required properties are missing
     */
    public FilterConfigPropertyValues(FilterConfig config, Set requiredProperties)
        throws ServletException {

      Set missingProps =
          (requiredProperties != null && !requiredProperties.isEmpty())
              ? new HashSet(requiredProperties)
              : null;

      Enumeration en = config.getInitParameterNames();
      while (en.hasMoreElements()) {
        String property = (String) en.nextElement();
        Object value = config.getInitParameter(property);
        addPropertyValue(new PropertyValue(property, value));
        if (missingProps != null) {
          missingProps.remove(property);
        }
      }

      // Fail if we are still missing properties.
      if (missingProps != null && missingProps.size() > 0) {
        throw new ServletException(
            "Initialization from FilterConfig for filter '"
                + config.getFilterName()
                + "' failed; the following required properties were missing: "
                + StringUtils.collectionToDelimitedString(missingProps, ", "));
      }
    }
  @Override
  public void init(final FilterConfig filterConfig) {
    ikey = filterConfig.getInitParameter("ikey");
    skey = filterConfig.getInitParameter("skey");
    akey = filterConfig.getInitParameter("akey");
    host = filterConfig.getInitParameter("host");

    if (filterConfig.getInitParameter("login.url") != null) {
      loginUrl = filterConfig.getInitParameter("login.url");
    }
    // Init our unprotected endpoints
    unprotectedDirs = new ArrayList<String>(Arrays.asList(defaultUnprotectedDirs));

    if (filterConfig.getInitParameter("unprotected.dirs") != null) {
      String[] userSpecifiedUnprotectedDirs =
          filterConfig.getInitParameter("unprotected.dirs").split(" ");
      unprotectedDirs.addAll(Arrays.asList(userSpecifiedUnprotectedDirs));
    }

    if (filterConfig.getInitParameter("bypass.APIs") != null) {
      apiBypassEnabled = Boolean.parseBoolean(filterConfig.getInitParameter("bypass.APIs"));
    }

    if (filterConfig.getInitParameter("fail.Open") != null) {
      failOpen = Boolean.parseBoolean(filterConfig.getInitParameter("fail.Open"));
    }
  }
  public void testDoFilterNotAuthenticated() throws Exception {
    AuthenticationFilter filter = new AuthenticationFilter();
    try {
      FilterConfig config = Mockito.mock(FilterConfig.class);
      Mockito.when(config.getInitParameter(AuthenticationFilter.AUTH_TYPE))
          .thenReturn(DummyAuthenticationHandler.class.getName());
      Mockito.when(config.getInitParameterNames())
          .thenReturn(new Vector(Arrays.asList(AuthenticationFilter.AUTH_TYPE)).elements());
      filter.init(config);

      HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
      Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://foo:8080/bar"));

      HttpServletResponse response = Mockito.mock(HttpServletResponse.class);

      FilterChain chain = Mockito.mock(FilterChain.class);

      Mockito.doAnswer(
              new Answer() {
                @Override
                public Object answer(InvocationOnMock invocation) throws Throwable {
                  fail();
                  return null;
                }
              })
          .when(chain)
          .doFilter(Mockito.<ServletRequest>anyObject(), Mockito.<ServletResponse>anyObject());

      filter.doFilter(request, response, chain);

      Mockito.verify(response).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    } finally {
      filter.destroy();
    }
  }
  /**
   * 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");
    }
  }
  public void testGetToken() throws Exception {
    AuthenticationFilter filter = new AuthenticationFilter();
    try {
      FilterConfig config = Mockito.mock(FilterConfig.class);
      Mockito.when(config.getInitParameter(AuthenticationFilter.AUTH_TYPE))
          .thenReturn(DummyAuthenticationHandler.class.getName());
      Mockito.when(config.getInitParameter(AuthenticationFilter.SIGNATURE_SECRET))
          .thenReturn("secret");
      Mockito.when(config.getInitParameterNames())
          .thenReturn(
              new Vector(
                      Arrays.asList(
                          AuthenticationFilter.AUTH_TYPE, AuthenticationFilter.SIGNATURE_SECRET))
                  .elements());
      filter.init(config);

      AuthenticationToken token =
          new AuthenticationToken("u", "p", DummyAuthenticationHandler.TYPE);
      token.setExpires(System.currentTimeMillis() + 1000);
      Signer signer = new Signer("secret".getBytes());
      String tokenSigned = signer.sign(token.toString());

      Cookie cookie = new Cookie(AuthenticatedURL.AUTH_COOKIE, tokenSigned);
      HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
      Mockito.when(request.getCookies()).thenReturn(new Cookie[] {cookie});

      AuthenticationToken newToken = filter.getToken(request);

      assertEquals(token.toString(), newToken.toString());
    } finally {
      filter.destroy();
    }
  }
  @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();
    }
  }
  /**
   * 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;
  }
Exemple #11
0
  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);
  }
 /** @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();
 }
Exemple #13
0
 public void init(FilterConfig filterConfig) throws ServletException {
   this.filterChar = filterConfig.getInitParameter("FilterChar");
   this.replaceChar = filterConfig.getInitParameter("ReplaceChar");
   this.splitChar = filterConfig.getInitParameter("SplitChar");
   this.excludeUrls = filterConfig.getInitParameter("excludeUrls");
   this.filterConfig = filterConfig;
 }
  /**
   * 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());
    }
  }
Exemple #15
0
  @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();
    }
  }
  /**
   * 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);
        }
      }
    }
  }
  /**
   * 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;
    }
  }
 /** {@inheritDoc} */
 @Override
 public void init(FilterConfig filterConfig) throws ServletException {
   final List<String> parameterNames = Collections.list(filterConfig.getInitParameterNames());
   for (final String parameterName : parameterNames) {
     customResources.put(parameterName, filterConfig.getInitParameter(parameterName));
   }
 }
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
      throws IOException, ServletException {

    HttpServletResponse httpResponse = (HttpServletResponse) response;
    HttpServletRequest httpRequest = (HttpServletRequest) request;

    // 不放入session的跳转页面中
    String failure = this.errorPage;

    for (Enumeration e = filterConfig.getInitParameterNames(); e.hasMoreElements(); ) {
      String headerName = (String) e.nextElement();
      httpResponse.addHeader(headerName, filterConfig.getInitParameter(headerName));
    }

    try {
      Enumeration e = request.getParameterNames();
      while (e.hasMoreElements()) {
        String parameterName = e.nextElement().toString();
        String value = request.getParameter(parameterName);
        if (!StringHelper.isNullString(value)) {
          if (this.webfilter) FilterManager.filter((String) value, new WebFilter());
          if (this.sqlfilter) FilterManager.filter((String) value, new SqlFilter());
          if (this.specialfilter) FilterManager.filter((String) value, new SpecialCharFilter());
        }
      }

      chain.doFilter(request, httpResponse);
    } catch (Exception e) {
      logger.info("安全过滤信息:" + e.getMessage());
      httpResponse.getWriter().write(e.getMessage());
    }
  }
  /**
   * Place this filter into service.
   *
   * @param filterConfig The filter configuration object
   */
  public void init(FilterConfig filterConfig) throws ServletException {
    this.filterConfig = filterConfig;
    this.errorPage = filterConfig.getInitParameter("errorPage");

    String webFilter = filterConfig.getInitParameter("webfilter");
    if ((webFilter == null)
        || webFilter.equalsIgnoreCase("true")
        || webFilter.equalsIgnoreCase("yes")) {
      this.webfilter = true;
    } else {
      this.webfilter = false;
    }

    String sqlFilter = filterConfig.getInitParameter("sqlfilter");
    if ((sqlFilter == null)
        || sqlFilter.equalsIgnoreCase("true")
        || sqlFilter.equalsIgnoreCase("yes")) {
      this.sqlfilter = true;
    } else {
      this.sqlfilter = false;
    }

    String specialfilter = filterConfig.getInitParameter("specialfilter");
    if ((specialfilter == null)
        || specialfilter.equalsIgnoreCase("true")
        || specialfilter.equalsIgnoreCase("yes")) {
      this.specialfilter = true;
    } else {
      this.specialfilter = false;
    }
  }
  @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);
    }
  }
 @Override
 public final void init(FilterConfig config) throws ServletException {
   Enumeration<String> parameterNames = config.getInitParameterNames();
   while (parameterNames.hasMoreElements()) {
     String name = parameterNames.nextElement();
     headers.put(name, config.getInitParameter(name));
   }
 }
Exemple #23
0
 /**
  * Set filter init params with proper values and check they are the same in {@link
  * WroConfiguration} object.
  */
 @Test(expected = WroRuntimeException.class)
 public void testFilterInitParamsAreWrong() throws Exception {
   Mockito.when(config.getInitParameter(ConfigConstants.cacheUpdatePeriod.name()))
       .thenReturn("InvalidNumber");
   Mockito.when(config.getInitParameter(ConfigConstants.modelUpdatePeriod.name()))
       .thenReturn("100");
   filter.init(config);
 }
Exemple #24
0
 @Override
 public void init(FilterConfig filterConfig) throws ServletException {
   proxy = filterConfig.getInitParameter("proxy");
   String value = filterConfig.getInitParameter("redirects");
   if (StringUtils.isNotBlank(value)) {
     redirects = Boolean.parseBoolean(value);
   }
 }
Exemple #25
0
    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());
    }
Exemple #26
0
 private Map<String, String> filterConfigToMap(FilterConfig filterConfig) {
   Map<String, String> configMap = new HashMap<String, String>();
   Enumeration params = filterConfig.getInitParameterNames();
   while (params.hasMoreElements()) {
     String paramName = (String) params.nextElement();
     configMap.put(paramName, filterConfig.getInitParameter(paramName));
   }
   return configMap;
 }
Exemple #27
0
  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);
  }
Exemple #28
0
 @Test
 public void testDisableCacheInitParamInDeploymentMode() throws Exception {
   Mockito.when(config.getInitParameter(FilterConfigWroConfigurationFactory.PARAM_CONFIGURATION))
       .thenReturn(FilterConfigWroConfigurationFactory.PARAM_VALUE_DEPLOYMENT);
   Mockito.when(config.getInitParameter(ConfigConstants.disableCache.name())).thenReturn("true");
   filter.init(config);
   Assert.assertEquals(false, filter.getWroConfiguration().isDebug());
   Assert.assertEquals(false, filter.getWroConfiguration().isDisableCache());
 }
 /**
  * Init session filter
  *
  * @param filterConfig A filter configuration object used by a servlet container to pass
  *     information to a filter during initialization.
  */
 @Override
 public void init(FilterConfig filterConfig) throws ServletException {
   // 初始化系统信息
   Constants.setSystemInfo(
       filterConfig.getServletContext().getRealPath(""),
       filterConfig.getServletContext().getContextPath(),
       filterConfig.getInitParameter("JS_Version"),
       null);
 }
Exemple #30
0
    public String getInitParameter(String name) {
      String result = filterConfig.getInitParameter(name);

      if (result == null) {
        result = filterConfig.getServletContext().getInitParameter(name);
      }

      return result;
    }