Example usage for javax.servlet FilterConfig getInitParameter

List of usage examples for javax.servlet FilterConfig getInitParameter

Introduction

In this page you can find the example usage for javax.servlet FilterConfig getInitParameter.

Prototype

public String getInitParameter(String name);

Source Link

Document

Returns a String containing the value of the named initialization parameter, or null if the initialization parameter does not exist.

Usage

From source file:org.sakaiproject.tool.section.filter.AuthnFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    authnRedirect = filterConfig.getInitParameter("authnRedirect");
    authnBean = filterConfig.getInitParameter("authnBean");
}

From source file:org.opendaylight.controller.filtervalve.cors.jaxb.ParserTest.java

@Test
public void testParsing() throws Exception {
    File xmlFile = new File(getClass().getResource("/sample-cors-config.xml").getFile());
    assertThat(xmlFile.canRead(), is(true));
    String xmlFileContent = FileUtils.readFileToString(xmlFile);
    Host host = Parser.parse(xmlFileContent, "fileName");
    assertEquals(1, host.getContexts().size());
    // check that MockedFilter has init params merged/replaced
    Optional<Context> context = host.findContext("/restconf");
    assertTrue(context.isPresent());/*www  .  ja  va  2s . c  o  m*/
    assertEquals(1, context.get().getFilters().size());
    MockedFilter filter = (MockedFilter) context.get().getFilters().get(0).getActualFilter();
    FilterConfig filterConfig = filter.getFilterConfig();
    assertEquals("*", filterConfig.getInitParameter("cors.allowed.origins"));
    assertEquals("11", filterConfig.getInitParameter("cors.preflight.maxage"));
}

From source file:org.eclipse.skalli.view.internal.filter.CacheFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    String cacheResourcesParam = filterConfig.getInitParameter("cachedResources"); //$NON-NLS-1$
    if (StringUtils.isBlank(cacheResourcesParam)) {
        throw new ServletException("Filter parameter 'cachedResources' must not be empty");
    }/*ww w .  j a  v a 2s  .  c o  m*/
    cachedResources = CollectionUtils.asSet(StringUtils.split(cacheResourcesParam, ','));
    maxAge = NumberUtils.toLong(filterConfig.getInitParameter("maxAge"), -1); //$NON-NLS-1$
}

From source file:org.infoscoop.web.I18NFilter.java

public void init(FilterConfig config) throws ServletException {
    String typeVar = config.getInitParameter("type");
    if (log.isInfoEnabled())
        log.info("initialize : type=" + typeVar);
    Field f;//from   w ww . j av  a2  s. c  o m
    try {
        f = I18NUtil.class.getDeclaredField(typeVar);
        type = (String) f.get(null);
    } catch (Exception e) {
        throw new ServletException(e);
    }
}

From source file:org.sharetask.utility.log.LogUidFilter.java

@Override
public void init(final FilterConfig config) throws ServletException {
    final String id = config.getInitParameter(IDENTIFIERT);
    if (id != null && !id.isEmpty()) {
        identifiert = id;/*from   w  w w.j  av  a  2  s. c o  m*/
    }
}

From source file:net.sourceforge.safr.jaas.web.LoginFilter.java

public void init(FilterConfig config) throws ServletException {
    logoutUrl = config.getInitParameter("logoutUrl");
}

From source file:alpine.filters.ClickjackingFilter.java

@Override
public void init(final FilterConfig filterConfig) {
    final String mode = filterConfig.getInitParameter("mode");
    final String uri = filterConfig.getInitParameter("uri");
    if (StringUtils.isNotBlank(mode)) {
        if (("ALLOW-FROM").equals(mode)) {
            this.mode = mode + " " + uri;
        } else if (("DENY").equals(mode) || ("SAMEORIGIN").equals(mode)) {
            this.mode = mode;
        }/*from   ww w  .j ava2 s  .  c  om*/
    }
}

From source file:com.serotonin.m2m2.web.filter.LoggedInFilter.java

@Override
public void init(FilterConfig config) {
    exceededIpLimitUrl = config.getInitParameter("exceededIpLimitUrl");

    LicenseFeature uniqueIpAddresses = Common.licenseFeature("uniqueIpAddresses");
    if (uniqueIpAddresses == null)
        maxUniqueIps = 3;//from   www .j a  v  a2s. c  om
    else {
        if ("unlimited".equals(uniqueIpAddresses.getValue()))
            maxUniqueIps = -1;
        else
            maxUniqueIps = Integer.parseInt(uniqueIpAddresses.getValue());
    }
}

From source file:org.soulwing.cas.filter.FilterToBeanProxy.java

private String getTargetBeanName(FilterConfig filterConfig) throws ServletException {
    String beanName = filterConfig.getInitParameter(TARGET_BEAN);
    if (beanName == null) {
        throw new ServletException(TARGET_BEAN + INIT_PARAMETER_REQUIRED);
    }//ww w  .j  a va 2s .  c  o  m
    return beanName;
}

From source file:com.log4ic.compressor.cache.filter.BrowserCacheFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    if (filterConfig != null) {
        String ct = filterConfig.getInitParameter("cache-time");
        if (StringUtils.isNotBlank(ct)) {
            this.cacheTime = new Integer(ct);
        }//from  ww w . j a  va  2 s  .  c  o  m
    }
}