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:cn.vlabs.duckling.vwb.PromitionLogFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    createUrl = filterConfig.getInitParameter("createUrl");
}

From source file:se.vgregion.javg.web.filter.WebErrorHandlingFilter.java

public void init(FilterConfig arg0) throws ServletException {
    tyckTillErrorFormURL = arg0.getInitParameter("TyckTillErrorFormURL");
    // String ldapContextConfigLocation =
    // arg0.getServletContext().getInitParameter("ldapContextConfigLocation");
    ac = WebApplicationContextUtils.getWebApplicationContext(arg0.getServletContext());

    contextName = arg0.getServletContext().getServletContextName();
    reportMethod = arg0.getInitParameter("TyckTillReportMethod");
    reportEmail = arg0.getInitParameter("TyckTillReportEmail");
    getLdapService(); // Test Before use
}

From source file:org.apache.hadoop.gateway.identityasserter.common.filter.CommonIdentityAssertionFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    String principalMapping = filterConfig.getInitParameter(PRINCIPAL_MAPPING);
    if (principalMapping == null || principalMapping.isEmpty()) {
        principalMapping = filterConfig.getServletContext().getInitParameter(PRINCIPAL_MAPPING);
    }/*from  w  ww. j av  a  2  s.  com*/
    String groupPrincipalMapping = filterConfig.getInitParameter(GROUP_PRINCIPAL_MAPPING);
    if (groupPrincipalMapping == null || groupPrincipalMapping.isEmpty()) {
        groupPrincipalMapping = filterConfig.getServletContext().getInitParameter(GROUP_PRINCIPAL_MAPPING);
    }
    if (principalMapping != null && !principalMapping.isEmpty()
            || groupPrincipalMapping != null && !groupPrincipalMapping.isEmpty()) {
        try {
            mapper.loadMappingTable(principalMapping, groupPrincipalMapping);
        } catch (PrincipalMappingException e) {
            throw new ServletException("Unable to load principal mapping table.", e);
        }
    }
}

From source file:org.fao.geonet.web.XFrameOptionsFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    mode = filterConfig.getInitParameter("mode");
    url = filterConfig.getInitParameter("url");

    // Mode: DENY, SAMEORIGIN, ALLOW-FROM. Any other value will default to SAMEORIGIN
    if (!mode.equals(MODE_DENY) && !mode.equals(MODE_SAMEORIGIN) && !mode.equals(MODE_ALLOWFROM)) {
        mode = MODE_DENY;//from w  ww.  j a v a2 s .co  m
    }

    // If ALLOW-FROM, make sure a valid url is given, otherwise fallback to deny
    if (mode.equals(MODE_ALLOWFROM)) {
        if (StringUtils.isEmpty(url)) {
            Log.info(Geonet.GEONETWORK,
                    "XFrameOptions filter url parameter is missing for mode ALLOW-FROM. Setting mode to DENY.");
            mode = MODE_DENY;
        } else {
            try {
                URL urlValue = new URL(url);
                domain = urlValue.getHost() + ((urlValue.getPort() == -1) ? "" : ":" + urlValue.getPort());

            } catch (MalformedURLException ex) {
                Log.info(Geonet.GEONETWORK, String.format(
                        "XFrameOptions filter url parameter (%s) is not valid for mode ALLOW-FROM. Setting mode to DENY.",
                        url));
                mode = MODE_DENY;
            }
        }
    }

    if (Log.isDebugEnabled(Geonet.GEONETWORK)) {
        Log.debug(Geonet.GEONETWORK,
                String.format("XFrameOptions filter initialized. Using mode %s.", getXFrameOptionsValue()));
    }

}

From source file:org.yes.cart.web.filter.AbstractFilter.java

/**
 * {@inheritDoc}/*from   www. j  ava  2 s. c om*/
 */
public void init(final FilterConfig filterConfig) throws ServletException {
    this.filterConfig = filterConfig;
    if (StringUtils.isNotBlank(filterConfig.getInitParameter("excludePattern"))) {
        skipUri = Pattern.compile(filterConfig.getInitParameter("excludePattern"));
    }
}

From source file:org.jasig.cas.web.LicenceFilter.java

public void init(FilterConfig config) throws ServletException {
    //licence/*from www . j a  va2  s  .c  om*/
    String liurl = config.getInitParameter("liurl");
    if (liurl == null || liurl.isEmpty()) {
        throw new ServletException();
    }
    CloseableHttpClient httpclient = HttpClients.createDefault();
    HttpGet httpGet = new HttpGet(liurl);
    httpGet.addHeader("accept", "application/json");
    CloseableHttpResponse response1 = null;
    try {
        response1 = httpclient.execute(httpGet);
        if (response1.getStatusLine().getStatusCode() != 200) {
            System.out.println("licence ");
            throw new ServletException();
        }
        HttpEntity entity1 = response1.getEntity();
        BufferedReader br = new BufferedReader(new InputStreamReader((entity1.getContent())));
        String output;
        StringBuilder sb = new StringBuilder();
        while ((output = br.readLine()) != null) {
            sb.append(output);
        }
        JSONObject jsonObject = new JSONObject(sb.toString());
        String error = jsonObject.getString("code");
        if (!error.equals("S_OK")) {
            System.out.println("licence ");
            throw new ServletException();
        }
        String strexprietime = jsonObject.getJSONObject("var").getJSONObject("licInfo").getString("expireTime");
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        this.expiretime = df.parse(strexprietime).getTime();
        EntityUtils.consume(entity1);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            response1.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

From source file:org.cruxframework.crux.core.declarativeui.filter.DeclarativeUIFilter.java

@Override
public void init(FilterConfig config) throws ServletException {
    super.init(config);
    if (!production) {
        modulesUrlPrefix = config.getInitParameter("modulesUrlPrefix");
    }/*  w ww  . j a va2s. c  o m*/
}

From source file:org.apache.hadoop.gateway.hive.HiveHttpClientDispatch.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    super.init(filterConfig);
    String basicAuthPreemptiveString = filterConfig.getInitParameter(BASIC_AUTH_PREEMPTIVE_PARAM);
    if (basicAuthPreemptiveString != null) {
        setBasicAuthPreemptive(Boolean.parseBoolean(basicAuthPreemptiveString));
    }/*w  w  w  . j a  va  2  s  .co  m*/
}

From source file:org.opencms.main.OpenCmsUrlServletFilter.java

/**
 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
 *///  w  w w. j a v a  2  s . c  om
public void init(FilterConfig filterConfig) {

    m_additionalExcludePrefixes = filterConfig.getInitParameter(INIT_PARAM_ADDITIONAL_EXCLUDEPREFIXES);
}

From source file:info.magnolia.cms.filters.CommonsFileUploadMultipartRequestFilter.java

/**
 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
 *//*from  w w w  .ja  v a  2 s.  c  o  m*/
public void init(FilterConfig config) throws ServletException {
    String maxFileSize = config.getInitParameter(PARAM_MAX_FILE_SIZE);
    if (maxFileSize != null) {
        this.maxFileSize = Integer.parseInt(maxFileSize);
    }

    this.tempDir = new File(Path.getTempDirectoryPath());
}