Example usage for javax.servlet FilterConfig getServletContext

List of usage examples for javax.servlet FilterConfig getServletContext

Introduction

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

Prototype

public ServletContext getServletContext();

Source Link

Document

Returns a reference to the ServletContext in which the caller is executing.

Usage

From source file:org.ambraproject.web.VirtualJournalMappingFilter.java

public void init(final FilterConfig filterConfig) throws ServletException {
    // need ServletContext to get "real" path/file names
    this.servletContext = filterConfig.getServletContext();
    this.configuration = ConfigurationStore.getInstance().getConfiguration();
}

From source file:org.apache.hadoop.gateway.provider.federation.jwt.filter.JWTFederationFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    GatewayServices services = (GatewayServices) filterConfig.getServletContext()
            .getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
    authority = (JWTokenAuthority) services.getService(GatewayServices.TOKEN_SERVICE);
}

From source file:com.versatus.jwebshield.filter.SessionCheckFilter.java

/**
 * @see Filter#init(FilterConfig)//from  ww w  .j  av a  2  s.co m
 */
@Override
public void init(FilterConfig fConfig) throws ServletException {
    String file = fConfig.getServletContext().getInitParameter("configFile");
    if (file != null) {
        UrlExclusionList urlExList = new UrlExclusionList();
        fConfig.getServletContext().setAttribute(SecurityConstant.SESSION_CHECK_URL_EXCL_LIST_ATTR_NAME,
                urlExList);

        try {
            XMLConfiguration config = new XMLConfiguration(file);
            SubnodeConfiguration fields = config.configurationAt("sessionCheck");
            List<Object> exclusionList = fields.getList("sessionCheckUrlExclusions");
            redirectPage = fields.getString("redirectPage");
            attributeToCheck = fields.getString("attributeToCheck");
            send401 = fields.getBoolean("send401");

            if (exclusionList != null) {
                for (Object obj : exclusionList) {
                    urlExList.addUrl((String) obj);
                }
            }
            // logger.info("init: sessionCheckUrlExclusions=" +
            // exclusionList);
            logger.info("init: sessionCheckUrlExclusionsList=" + urlExList);
            logger.info("init: redirectPage=" + redirectPage);

        } catch (Exception cex) {
            logger.error("init: unable to load configFile " + file, cex);

        }
    } else {
        logger.error("init: No configFile specified");
    }

}

From source file:com.thoughtworks.go.spark.SparkPreFilter.java

@Override
public void init(FilterConfig config) throws ServletException {
    servletHelper = ServletHelper.getInstance();
    this.wac = WebApplicationContextUtils.getWebApplicationContext(config.getServletContext());
    super.init(config);
}

From source file:com.raissi.utils.CustomFileUploadFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    boolean isAtLeastJSF22 = detectJSF22();
    String uploader = filterConfig.getServletContext().getInitParameter(Constants.ContextParams.UPLOADER);
    if (uploader == null || uploader.equals("auto"))
        bypass = isAtLeastJSF22 ? true : false;
    else if (uploader.equals("native"))
        bypass = true;/*w  w w .  j  a  v a  2  s  .  c o m*/
    else if (uploader.equals("commons"))
        bypass = false;

    thresholdSize = filterConfig.getInitParameter(THRESHOLD_SIZE_PARAM);
    uploadDir = filterConfig.getInitParameter(UPLOAD_DIRECTORY_PARAM);
    logger.debug("FileUploadFilter initiated successfully");
}

From source file:org.apache.pluto.driver.PortalDriverFilter.java

/**
 * Initialize the Portal Driver./* w w w .j  a  va  2 s  .co m*/
 * This method retrieves the portlet container instance
 * from the servlet context scope.
 *
 * @see org.apache.pluto.PortletContainer
 */
public void init(FilterConfig filterConfig) throws ServletException {
    servletContext = filterConfig.getServletContext();
    container = (PortletContainer) servletContext.getAttribute(AttributeKeys.PORTLET_CONTAINER);
}

From source file:org.jasig.resourceserver.utils.filter.AggregationAwareFilterBean.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    if (this.resourcesElementsProvider == null) {
        final ServletContext servletContext = filterConfig.getServletContext();
        this.resourcesElementsProvider = ResourcesElementsProviderUtils
                .getOrCreateResourcesElementsProvider(servletContext);
    }/*from   ww  w.ja  va  2  s  .  co m*/

    this.filter.init(filterConfig);
}

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

/**
 * Initialize this filter.// w w  w  . j a va2 s  .  c om
 *
 * @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:com.ocpsoft.pretty.PrettyFilter.java

/**
 * Load and cache configurations//from  ww  w  .ja va2  s .c om
 */
public void init(final FilterConfig filterConfig) throws ServletException {
    final PrettyConfigurator configurator = new PrettyConfigurator(filterConfig.getServletContext());

    try {
        log.info("PrettyFilter starting up...");
        PrettyConfig config = configurator.configure();
        servletContext = filterConfig.getServletContext();
        setConfig(config);
        log.info("PrettyFilter initialized.");
    } catch (IOException ioex) {
        throw new ServletException("Error configuring Pretty Faces, could not load the configuration.", ioex);
    } catch (SAXException saxex) {
        throw new ServletException("Error configuring Pretty Faces, could not parse the configuration.", saxex);
    }
}

From source file:com.xpn.xwiki.web.ActionFilter.java

/**
 * {@inheritDoc}/*w  ww.j a va2  s .co m*/
 * 
 * @see Filter#init(FilterConfig)
 */
public void init(FilterConfig filterConfig) throws ServletException {
    this.servletContext = filterConfig.getServletContext();
}