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:jp.eisbahn.oauth2.server.spi.servlet.ProtectedResourceFilter.java

@SuppressWarnings("unchecked")
private <T> T createInstance(String name, FilterConfig config)
        throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    String className = config.getInitParameter(name);
    if (className != null) {
        Class<?> clazz = Class.forName(className);
        return (T) clazz.newInstance();
    } else {//from   ww  w .  java  2s.c  o m
        return null;
    }
}

From source file:org.bibsonomy.webapp.filters.ContentNegotiationFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    final String initParameterExcludePatterns = filterConfig.getInitParameter("excludePattern");
    if (present(initParameterExcludePatterns)) {
        this.excludePattern = Pattern.compile(initParameterExcludePatterns);
    }// w w  w  .  j  a  v  a  2s.  c  om
}

From source file:alpine.filters.ContentSecurityPolicyFilter.java

/**
 * Returns the value of the initParam.//from w  ww  .jav a  2 s  .  c om
 * @param filterConfig a FilterConfig instance
 * @param initParam the name of the init parameter
 * @param variable the variable to use if the init param was not defined
 * @return a String
 */
private String getValue(FilterConfig filterConfig, String initParam, String variable) {
    final String value = filterConfig.getInitParameter(initParam);
    if (StringUtils.isNotBlank(value)) {
        return value;
    } else {
        return variable;
    }
}

From source file:org.seasar.extension.filter.RequestDumpFilter.java

private boolean getBooleanParameter(final FilterConfig filterConfig, final String name,
        final boolean defaultValue) {
    final String value = filterConfig.getInitParameter(name);
    if (value == null) {
        return defaultValue;
    }/*ww  w .  j  a  va  2s  . c om*/
    return BooleanConversionUtil.toPrimitiveBoolean(value);
}

From source file:CacheFilter.java

public void init(FilterConfig config) {
    Enumeration<?> names = config.getInitParameterNames();
    ArrayList<String[]> tmp = new ArrayList<String[]>();
    while (names.hasMoreElements()) {
        String name = (String) names.nextElement();
        String value = config.getInitParameter(name);
        String[] pair = { name, value };
        tmp.add(pair);/*from  ww  w  . j  ava  2s  .com*/
    }
    replyHeaders = new String[tmp.size()][2];
    tmp.toArray(replyHeaders);
}

From source file:org.picketbox.jaxrs.filters.JWEInterceptor.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    this.theConfig = filterConfig;
    String keyStoreURL = filterConfig.getInitParameter("keystore");
    keyStorePass = filterConfig.getInitParameter("storepass");
    if (keyStoreURL == null) {
        keyStoreURL = SecurityActions.getSystemProperty("javax.net.ssl.keyStore", null);
    }//from ww w  .  ja  va  2  s .co m
    if (keyStorePass == null) {
        keyStorePass = SecurityActions.getSystemProperty("javax.net.ssl.keyStorePassword", null);
    }
    try {
        InputStream is = this.getKeyStoreInputStream(keyStoreURL);
        keystore = KeyStoreUtil.getKeyStore(is, keyStorePass.toCharArray());
    } catch (Exception e) {
        throw new ServletException(e);
    }
}

From source file:org.apache.hadoop.gateway.dispatch.GatewayDispatchFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    super.init(filterConfig);
    if (dispatch == null) {
        String dispatchImpl = filterConfig.getInitParameter("dispatch-impl");
        dispatch = newInstanceFromName(dispatchImpl);
    }// w w w .ja va 2  s  .c o  m
    configuration().target(dispatch).source(filterConfig).inject();
    HttpClientFactory httpClientFactory;
    String httpClientFactoryClass = filterConfig.getInitParameter("httpClientFactory");
    if (httpClientFactoryClass != null) {
        httpClientFactory = newInstanceFromName(httpClientFactoryClass);
    } else {
        httpClientFactory = new DefaultHttpClientFactory();
    }
    httpClient = httpClientFactory.createHttpClient(filterConfig);
    dispatch.setHttpClient(httpClient);
    dispatch.init();
}

From source file:edu.vt.middleware.servlet.filter.SessionAttributeFilter.java

/**
 * Initialize this filter.//w  ww. j  a  va  2  s.co m
 *
 * @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);
            }
        }
    }
}

From source file:nl.nn.adapterframework.webcontrol.ParamWrapperFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    final String toCompile;
    final String initParameter = filterConfig.getInitParameter(INIT_PARAM_NAME);
    if (initParameter != null && initParameter.trim().length() > 0) {
        toCompile = initParameter;/*from ww w .  j a  v  a 2s.  c  o  m*/
    } else {
        toCompile = DEFAULT_BLACKLIST_PATTERN;
    }

    iaflog.info("INFO Message: Struts1 'do'-Filter active");
    this.pattern = Pattern.compile(toCompile, Pattern.DOTALL);
}

From source file:cc.kune.core.server.rack.RackServletFilter.java

private String getModuleName(final FilterConfig filterConfig) {
    final String moduleName = filterConfig.getInitParameter(MODULE_PARAMETER);
    if (moduleName == null) {
        throw new ServerException("Rack module name can't be null!");
    }//from  w  w w  .  ja  v  a  2s  .  c  o  m
    return moduleName;
}