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:com.delmar.core.web.filter.ExportFilter.java

/**
 * {@inheritDoc}/*  w  w w.  ja v a2 s . c  om*/
 */
public void init(FilterConfig filterConfig) {
    log = LogFactory.getLog(ExportFilter.class);
    String bufferParam = filterConfig.getInitParameter("buffer");
    if (log.isDebugEnabled()) {
        log.debug("bufferParam=" + bufferParam);
    }
    buffer = bufferParam == null || StringUtils.equalsIgnoreCase("true", bufferParam);

    log.info("Filter initialized. Response buffering is " + (buffer ? "enabled" : "disabled"));
    this.endcoding = filterConfig.getInitParameter("endcoding");
}

From source file:com.mindmutex.draugiem.DraugiemHttpFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    String configPath = filterConfig.getInitParameter("configPath");
    if (configPath == null) {
        configPath = DEFAULT_CONFIG_PATH;
    }/*from w  w  w .  ja v a2 s  . c o  m*/

    ClassLoader classLoader = getClass().getClassLoader();
    InputStream inputStream = classLoader.getResourceAsStream(configPath);
    if (inputStream == null) {
        throw new ServletException("unable to load configuration file: " + configPath);
    }
    configuration = new Properties();
    try {
        configuration.load(inputStream);
    } catch (IOException ex) {
        throw new ServletException(ex);
    }
    configureFilter();

    logger.info("Initialised");
}

From source file:eionet.gdem.web.filters.SetCharacterEncodingFilter.java

/**
 * Place this filter into service.//from ww w .j  av  a2s . co m
 *
 * @param filterConfig
 *            The filter configuration object
 */
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;

}

From source file:com.ait.tooling.server.core.servlet.filter.HeaderInjectorFilter.java

@Override
public void init(final FilterConfig fc) throws ServletException {
    try {// w  w w. j a  v a 2s .c  om
        final String name = StringOps.toTrimOrNull(fc.getInitParameter("config"));

        if (null != name) {
            final InputStream in = fc.getServletContext().getResourceAsStream(name);

            try {
                final HeaderInjectorParser parser = new HeaderInjectorParser();

                parser.parse(in);

                addHeaderInjectors(parser.getInjectors());
            } catch (Throwable t) {
                logger.error("Could not create injectors", t);
            } finally {
                IOUtils.closeQuietly(in);
            }
        }
    } catch (Throwable t) {
        logger.error("Could not create injectors", t);
    }
}

From source file:net.sf.j2ep.RewriteFilter.java

/**
 * Initialize.//from   w w w . j  a  v a  2  s .  co  m
 * 
 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
 */
public void init(FilterConfig filterConfig) throws ServletException {
    log = LogFactory.getLog(RewriteFilter.class);

    String data = filterConfig.getInitParameter("dataUrl");
    if (data == null) {
        throw new ServletException("dataUrl is required.");
    } else {
        try {
            File dataFile = new File(filterConfig.getServletContext().getRealPath(data));
            ConfigParser parser = new ConfigParser(dataFile);
            serverChain = parser.getServerChain();
        } catch (Exception e) {
            throw new ServletException(e);
        }
    }

}

From source file:org.displaytag.filter.ResponseOverrideFilter.java

/**
 * {@inheritDoc}//from w  ww .  ja  va 2s .  c  om
 */
public void init(FilterConfig filterConfig) {
    log = LogFactory.getLog(ResponseOverrideFilter.class);
    String bufferParam = filterConfig.getInitParameter("buffer");
    if (log.isDebugEnabled()) {
        log.debug("bufferParam=" + bufferParam);
    }
    buffer = bufferParam == null || StringUtils.equalsIgnoreCase("true", bufferParam);

    log.info("Filter initialized. Response buffering is " + (buffer ? "enabled" : "disabled"));
}

From source file:eu.semlibproject.annotationserver.filters.CORSFilter.java

public void init(FilterConfig filterConfig) throws ServletException {

    super.initSemlibFilter(filterConfig);

    String _cEnabled = filterConfig.getInitParameter(SemlibConstantsConfiguration.CORS_ENABLED_PARAM);
    if (_cEnabled != null) {
        if (_cEnabled.equalsIgnoreCase("yes")) {
            filterEnabled = true;/*from w w w .  j  ava2s.c o m*/
        } else if (_cEnabled.equalsIgnoreCase("no")) {
            filterEnabled = false;
        }
    }

    String _origin = filterConfig.getInitParameter(SemlibConstantsConfiguration.CORS_ORIGINS_PARAM);
    if (StringUtils.isNotBlank(_origin)) {
        allowOrigin = _origin;
    }

    String _methods = filterConfig.getInitParameter(SemlibConstantsConfiguration.CORS_METHODS_PARAM);
    if (StringUtils.isNotBlank(_methods)) {
        supportedMethods = _methods;
    }

    String _headers = filterConfig.getInitParameter(SemlibConstantsConfiguration.CORS_HEADERS_PARAM);
    if (StringUtils.isNotBlank(_headers)) {
        supportedHeaders = _headers;
    }

    String _credentials = filterConfig.getInitParameter(SemlibConstantsConfiguration.CORS_CREDENTIALS_PARAM);
    if (_credentials != null) {
        if (_credentials.equalsIgnoreCase("yes")) {
            supportsCredentials = "true";
        } else if (_credentials.equalsIgnoreCase("no")) {
            supportsCredentials = "false";
        }
    }
}

From source file:AIR.Common.Web.Session.CaseInsensitiveFileNameFilter.java

private void setupExtensionsPattern(FilterConfig filterConfig) {
    String extensions = filterConfig.getInitParameter("extensionsToFilter");
    if (StringUtils.isEmpty(extensions)) {
        _logger.warn(//from  w w  w. j  ava2 s .com
                "No extensions provided to filter on. No filtering will be done. Please fill out the extensionsToFilter init-param for CaseInsensitiveFileNameFilter. Extensions are pipe (|) seperated.");
    } else {
        _pattern = Pattern.compile(String.format(".*\\.(?:%s)$", extensions), Pattern.CASE_INSENSITIVE);
    }
}

From source file:com.surevine.chat.auth.GroupAuthorisationFilter.java

public void init(FilterConfig filterConfig) {
    _logger.debug("Initialising filter");
    _rootDN = filterConfig.getInitParameter("connectDistinguisedName");
    _rootPW = filterConfig.getInitParameter("connectPassword");
    _host = filterConfig.getInitParameter("LdapHostname");
    _rootContext = filterConfig.getInitParameter("rootContext");
    _groupName = filterConfig.getInitParameter("groupName");
}

From source file:net.ymate.platform.module.wechat.web.WeChatFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    _LOG.debug("YMP Module WeChat Started");
    token = StringUtils.defaultIfEmpty(filterConfig.getInitParameter("token"), "wechat");
}