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.bibisco.filters.FileFilter.java

public void init(FilterConfig pFilterConfig) throws ServletException {
    mLog.debug("FileFilter initialized!!");

    mIntRejectThreshold = Integer.parseInt(pFilterConfig.getInitParameter("REJECT_THRESHOLD"));
    mIntDiskThreshold = Integer.parseInt(pFilterConfig.getInitParameter("DISK_THRESHOLD"));
    mStrTmpDir = ContextManager.getInstance().getTempDirectoryPath();
    mBlnWrapperOnlyIfNeeded = true;/*from  www .ja v a 2 s .c  o  m*/
}

From source file:jp.co.opentone.bsol.linkbinder.view.filter.UploadFileFilter.java

@Override
public void init(FilterConfig config) throws ServletException {
    String s = config.getInitParameter("max-size");
    maxSize = toInt(s, maxSize);//from  www .jav a  2  s.co m

    s = config.getInitParameter("threshold-size");
    thresholdSize = toInt(s, thresholdSize);

    // ????MB???
    // DEFAULT_MAX_SIZE???.
    s = SystemConfig.getValue(Constants.KEY_FILE_MAX_SIZE);
    maxFileSize = toInt(s, maxFileSize) * DEFAULT_MAX_SIZE;

    s = SystemConfig.getValue(Constants.KEY_FILE_DIR_PATH);
    if (!StringUtils.isEmpty(s)) {
        File f = new File(s);
        if (!f.exists() || !f.isDirectory()) {
            throw new ServletException("temporary directory is missing ;" + f.getAbsolutePath());
        }
        temporaryDirectory = f;
    } else {
        throw new ServletException("temporary directory parameter is missing");
    }

    s = SystemConfig.getValue(Constants.KEY_FILENAME_MAX_LENGTH);
    maxFilenameLength = toInt(s, maxFilenameLength);
}

From source file:org.apache.hadoop.gateway.openid.filter.OIDCFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    tokenEndpoint = filterConfig.getInitParameter(PARAM_TOKEN_ENDPOINT);
    authorizeEndpoint = filterConfig.getInitParameter(PARAM_AUTHORIZE_ENDPOINT);
    clientId = filterConfig.getInitParameter(PARAM_CLIENT_ID);
    clientSecret = filterConfig.getInitParameter(PARAM_CLIENT_SECRET);
}

From source file:org.sakaiproject.util.TrustedLoginFilter.java

public void init(FilterConfig config) throws ServletException {
    sessionManager = org.sakaiproject.tool.cover.SessionManager.getInstance();
    sharedSecret = config.getInitParameter("shared.secret");
}

From source file:it.unipmn.di.dcs.sharegrid.web.servlet.MultipartFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    String param = null;/*from   w  w w . j  a  v  a2 s . c o  m*/

    // Look for 'uploadMaxSize'
    param = filterConfig.getInitParameter(ServletConstants.UploadMaxSizeParamName);
    if (param != null) {
        try {
            this.maxSize = ServletUtil.ParseSizeLong(param);
        } catch (Exception e) {
            //ServletException se = new ServletException();
            //se.initCause(e);
            //throw se;
            throw new ServletException(
                    "Init parameter '" + ServletConstants.UploadMaxSizeParamName + "' is not numeric.", e);
        }
    } else {
        this.maxSize = ServletConstants.DefaultUploadMaxSize;
    }

    // Look for 'uploadMaxFileSize'
    param = filterConfig.getInitParameter(ServletConstants.UploadMaxFileSizeParamName);
    if (param != null) {
        try {
            this.maxFileSize = ServletUtil.ParseSizeLong(param);
        } catch (Exception e) {
            throw new ServletException(
                    "Init parameter '" + ServletConstants.UploadMaxFileSizeParamName + "' is not numeric.", e);
        }
    } else {
        this.maxFileSize = ServletConstants.DefaultUploadMaxFileSize;
    }

    // Look for 'uploadThresholdSize'
    param = filterConfig.getInitParameter(ServletConstants.UploadThresholdSizeParamName);
    if (param != null) {
        try {
            this.thresholdSize = ServletUtil.ParseSizeInt(param);
        } catch (Exception e) {
            throw new ServletException(
                    "Init parameter '" + ServletConstants.UploadThresholdSizeParamName + "' is not numeric.",
                    e);
        }
    } else {
        this.maxSize = ServletConstants.DefaultUploadThresholdSize;
    }

    // Look for 'uploadRepositoryPath'
    param = filterConfig.getInitParameter(ServletConstants.UploadRepositoryPathParamName);
    if (param != null) {
        this.repositoryPath = param;
    } else {
        this.repositoryPath = ServletConstants.DefaultUploadRepositoryPath;
    }
}

From source file:org.apache.hadoop.hbase.rest.filter.RestCsrfPreventionFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    String customHeader = filterConfig.getInitParameter(CUSTOM_HEADER_PARAM);
    if (customHeader != null) {
        headerName = customHeader;//from   www.  j  ava 2s.c o  m
    }
    String customMethodsToIgnore = filterConfig.getInitParameter(CUSTOM_METHODS_TO_IGNORE_PARAM);
    if (customMethodsToIgnore != null) {
        parseMethodsToIgnore(customMethodsToIgnore);
    } else {
        parseMethodsToIgnore(METHODS_TO_IGNORE_DEFAULT);
    }

    String agents = filterConfig.getInitParameter(BROWSER_USER_AGENT_PARAM);
    if (agents == null) {
        agents = BROWSER_USER_AGENTS_DEFAULT;
    }
    parseBrowserUserAgents(agents);
    LOG.info(String.format(
            "Adding cross-site request forgery (CSRF) protection, "
                    + "headerName = %s, methodsToIgnore = %s, browserUserAgents = %s",
            headerName, methodsToIgnore, browserUserAgents));
}

From source file:com.threewks.analytics.filter.HttpRequestResponseTrackingFilter.java

/**
 * Get a mandatory initialization parameter from the filter configuration.
 * //www. ja va 2  s.c  o m
 * @param config the filter configuration to get the parameter from.
 * @param paramName the name of the parameter.
 * @return the parameter value.
 * @throws ServletException if the value of the parameter is blank.
 */
private String getMandatoryInitParam(FilterConfig config, String paramName) throws ServletException {
    String value = config.getInitParameter(paramName);
    if (StringUtils.isBlank(value)) {
        throw new ServletException(String.format("Missing mandatory init param '%s' for %s", paramName,
                this.getClass().getCanonicalName()));
    } else {
        return value;
    }
}

From source file:com.microsoft.aad.adal4jsample.BasicFilter.java

public void init(FilterConfig config) throws ServletException {
    clientId = config.getInitParameter("client_id");
    authority = config.getServletContext().getInitParameter("authority");
    tenant = config.getServletContext().getInitParameter("tenant");
    clientSecret = config.getInitParameter("secret_key");
}

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

public void init(FilterConfig filterConfig) throws ServletException {

    super.initSemlibFilter(filterConfig);

    String openIDEnabled = filterConfig
            .getInitParameter(SemlibConstantsConfiguration.AUTHENTICATION_ENABLED_PARAM);
    if (openIDEnabled != null) {
        if (openIDEnabled.equalsIgnoreCase("yes")) {
            authenticationEnabled = true;
        } else if (openIDEnabled.equalsIgnoreCase("no")) {
            authenticationEnabled = false;
        }//from   w  ww  . ja v a 2s.  c  o m

        String loginForm = filterConfig
                .getInitParameter(SemlibConstantsConfiguration.AUTHENTICATION_LOGINFORM_PARAM);
        if (StringUtils.isNotBlank(loginForm)) {
            if (!loginForm.startsWith("http://")) {
                // we have a relative path
                if (!loginForm.startsWith("/")) {
                    loginForm = "/" + loginForm;
                }
            }

            authenticationLoginFrom = loginForm;
        }

        String sTokenTime = filterConfig
                .getInitParameter(SemlibConstantsConfiguration.AUTHENTICATION_TOKEN_TIME_PARAM);
        if (sTokenTime != null) {
            try {
                long tTockenTime = Long.parseLong(sTokenTime);
                TokenManager.getInstance().setTokenTimeValidity(tTockenTime);
            } catch (Exception e) {
                // do nothing...use default value
            }
        }

        // Specify here a list of API that does not require any authentication
        // and any fake authentication (anonym user)
        if (noAuthAPI == null) {
            noAuthAPI = new ArrayList<String>();
            noAuthAPI.add("/users/current");
            noAuthAPI.add("/users/logout");
        }
    }
}

From source file:com.zimbra.cs.servlet.ContextPathBasedThreadPoolBalancerFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    suspendMs = DEFAULT_SUSPEND_MS;/* ww  w  .  j av  a2 s .  c  o m*/
    String str = StringUtils.trimToNull(filterConfig.getInitParameter(SUSPEND_INIT_PARAM));
    if (str != null) {
        suspendMs = Integer.parseInt(str);
    }

    str = StringUtils.trimToNull(filterConfig.getInitParameter(RULES_INIT_PARAM));
    parse(str);
    ZimbraLog.misc.info("Initialized with %s", str);

    ThreadPool threadPool = JettyMonitor.getThreadPool();
    if (threadPool instanceof QueuedThreadPool) {
        queuedThreadPool = (QueuedThreadPool) threadPool;
        ZimbraLog.misc.info("Thread pool was configured to max=" + queuedThreadPool.getMaxThreads());
    }
}