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:com.pararede.alfresco.security.AlfrescoContainerSecurityFilter.java

public void init(FilterConfig config) throws ServletException {
    this.context = WebApplicationContextUtils.getWebApplicationContext(config.getServletContext());
    this.registry = (ServiceRegistry) this.context.getBean("ServiceRegistry");
}

From source file:org.nuxeo.ecm.platform.ui.web.rest.FancyURLFilter.java

@Override
public void init(FilterConfig conf) throws ServletException {
    log.debug("Nuxeo5 URLFilter started");
    servletContext = conf.getServletContext();
}

From source file:coyote.commons.web.AuthFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    context = filterConfig.getServletContext();
    LOG.info("Servlet Context:" + context);

    applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
    LOG.info("Spring Context:" + applicationContext);

    @SuppressWarnings("rawtypes")
    Enumeration initNames = context.getInitParameterNames();
    if (initNames != null) {
        while (initNames.hasMoreElements()) {
            String name = (String) initNames.nextElement();
            String value = filterConfig.getInitParameter(name);
            LOG.trace("Init:" + name + ":" + value);
        }//from w w w .  j  av a  2  s . co m
    }

    @SuppressWarnings("rawtypes")
    Enumeration attrNames = context.getAttributeNames();
    if (attrNames != null) {
        while (attrNames.hasMoreElements()) {
            String name = (String) attrNames.nextElement();
            String value = filterConfig.getInitParameter(name);
            LOG.trace("Attr:" + name + ":" + value);
        }
    }

    @SuppressWarnings("rawtypes")
    Enumeration initParams = filterConfig.getInitParameterNames();
    if (initParams != null) {
        while (initParams.hasMoreElements()) {
            String name = (String) initParams.nextElement();
            String value = filterConfig.getInitParameter(name);
            LOG.trace(name + ":" + value);
        }
    }

    if (applicationContext != null && applicationContext.containsBean("securityContext")) {
        securityContext = (SecurityContext) applicationContext.getBean("securityContext");
    }

    if (securityContext != null) {
        LOG.trace("Security Context Initialized");
    } else {
        LOG.fatal("Could not obtain a reference to the security context); application is unsecured!");
    }

    LOG.trace("Authentication Filter initialized");
}

From source file:org.hifivault.geo.location.filters.GeoLocationFilter.java

public void init(FilterConfig filterConfig) throws ServletException {

    BeanFactory beanFactory = WebApplicationContextUtils
            .getRequiredWebApplicationContext(filterConfig.getServletContext());
    manager = (GeoLocationManager) beanFactory.getBean("geoLocationManager");

    Enumeration<String> names = filterConfig.getInitParameterNames();
    while (names.hasMoreElements()) {
        String key = names.nextElement();
        String value = filterConfig.getInitParameter(key);
        if (value != null && value.length() > 0) {
            override.put(key.toUpperCase(), value.toUpperCase());
        }/*  ww  w .j  a v  a  2  s. co  m*/
    }
}

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

public void init(FilterConfig filterConfig) throws ServletException {
    ServletContext context = filterConfig.getServletContext();
    initLoginParameters(context);// ww w  .j a  v a  2 s .  c  o m
    initTimeoutParameters(context);
    initErrorParameters(context);
}

From source file:org.codelibs.fess.filter.EncodingFilter.java

@Override
public void init(final FilterConfig config) throws ServletException {
    servletContext = config.getServletContext();

    encoding = config.getInitParameter(LastaPrepareFilter.ENCODING_KEY);
    if (encoding == null) {
        encoding = LastaPrepareFilter.DEFAULT_ENCODING;
    }/* w  w w .  j  ava2 s .  co  m*/

    // ex. sjis:Shift_JIS,eucjp:EUC-JP
    final String value = config.getInitParameter(ENCODING_MAP);
    if (StringUtil.isNotBlank(value)) {
        final String[] encodingPairs = value.split(",");
        for (final String pair : encodingPairs) {
            final String[] encInfos = pair.trim().split(":");
            if (encInfos.length == 2) {
                encodingMap.put("/" + encInfos[0] + "/", encInfos[1]);
            }
        }
    }
}

From source file:org.cryptomator.frontend.webdav.filters.UriNormalizationFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    contextPath = filterConfig.getServletContext().getContextPath();
}

From source file:org.dd4t.servlet.filters.ImageFilter.java

@Override
public void init(FilterConfig config) throws ServletException {
    // nothing to config

    context = config.getServletContext();
}

From source file:org.wso2.adminui.AdminUIServletFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    this.filterConfig = filterConfig;
    this.servletContext = filterConfig.getServletContext();
    this.servletContext.setAttribute(this.getClass().getName(), this);
}

From source file:jease.cms.web.servlet.JeaseController.java

public void init(FilterConfig config) throws ServletException {
    contextPath = config.getServletContext().getContextPath();
    dispatcher = config.getServletContext().getInitParameter(Names.JEASE_SITE_DISPATCHER);
    servlets = Pattern.compile(/*ww w .j  av  a  2s  .  co m*/
            String.format("/(%s).*", config.getServletContext().getInitParameter(Names.JEASE_SITE_SERVLETS)));
    locales = new HashSet<>();
    for (Locale locale : Locale.getAvailableLocales()) {
        locales.add(locale.getLanguage());
    }
}