当前位置: 首页>>代码示例>>Java>>正文


Java FilterConfig类代码示例

本文整理汇总了Java中javax.servlet.FilterConfig的典型用法代码示例。如果您正苦于以下问题:Java FilterConfig类的具体用法?Java FilterConfig怎么用?Java FilterConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FilterConfig类属于javax.servlet包,在下文中一共展示了FilterConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import javax.servlet.FilterConfig; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    filter = new AuthorizationFilter();
    filter.authService = mock(APPAuthenticationServiceBean.class);

    VOUserDetails user = new VOUserDetails();
    user.setLocale("de");
    doReturn(user).when(filter.authService).authenticateAdministrator(
            any(PasswordAuthentication.class));

    chain = mock(FilterChain.class);
    config = mock(FilterConfig.class);
    req = mock(HttpServletRequest.class);
    resp = mock(HttpServletResponse.class);
    session = mock(HttpSession.class);

    when(req.getSession()).thenReturn(session);
    when(req.getLocale()).thenReturn(new Locale("en"));
    when(req.getServletPath()).thenReturn("/xxx");
    when(config.getInitParameter(any(String.class))).thenReturn("css");
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:22,代码来源:AuthorizationFilterTest.java

示例2: testInitCaseSensitivity

import javax.servlet.FilterConfig; //导入依赖的package包/类
@Test
public void testInitCaseSensitivity() throws Exception {
  // minimal configuration & simple auth handler (Pseudo)
  AuthenticationFilter filter = new AuthenticationFilter();
  try {
    FilterConfig config = Mockito.mock(FilterConfig.class);
    Mockito.when(config.getInitParameter(AuthenticationFilter.AUTH_TYPE)).thenReturn("SimPle");
    Mockito.when(config.getInitParameter(AuthenticationFilter.AUTH_TOKEN_VALIDITY)).thenReturn(
        (new Long(TOKEN_VALIDITY_SEC)).toString());
    Mockito.when(config.getInitParameterNames()).thenReturn(
        new Vector<String>(Arrays.asList(AuthenticationFilter.AUTH_TYPE,
            AuthenticationFilter.AUTH_TOKEN_VALIDITY)).elements());
    getMockedServletContextWithStringSigner(config);

    filter.init(config);
    Assert.assertEquals(PseudoAuthenticationHandler.class, 
        filter.getAuthenticationHandler().getClass());
  } finally {
    filter.destroy();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestAuthenticationFilter.java

示例3: init

import javax.servlet.FilterConfig; //导入依赖的package包/类
/**
    * Place this filter into service.
    *
    * @param filterConfig The filter configuration object
    */
   public void init(FilterConfig filterConfig) throws ServletException {

this.filterConfig = filterConfig;
       this.encoding = filterConfig.getInitParameter("encoding");
       String value = filterConfig.getInitParameter("ignore");
       if (value == null)
           this.ignore = true;
       else if (value.equalsIgnoreCase("true"))
           this.ignore = true;
       else if (value.equalsIgnoreCase("yes"))
           this.ignore = true;
       else
           this.ignore = false;

   }
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:SetCharacterEncodingFilter.java

示例4: init

import javax.servlet.FilterConfig; //导入依赖的package包/类
@Override
public void init(FilterConfig filterConfig) throws ServletException
{
    super.init(filterConfig);

    synchronized (this)
    {
        if (_opaqueTokenValidator == null)
        {
            _opaqueTokenValidator = createTokenValidator(getFilterConfiguration());

            _logger.info(() -> String.format("%s successfully initialized", OAuthFilter.class.getSimpleName()));
        }
        else
        {
            _logger.warning("Attempted to set introspect URI more than once! Ignoring further attempts.");
        }
    }
}
 
开发者ID:curityio,项目名称:oauth-filter-for-java,代码行数:20,代码来源:OAuthOpaqueFilter.java

示例5: getFilterConfigSpecificOriginAndSupportsCredentialsDisabled

import javax.servlet.FilterConfig; //导入依赖的package包/类
public static FilterConfig
        getFilterConfigSpecificOriginAndSupportsCredentialsDisabled() {
    final String allowedHttpHeaders =
            CorsFilter.DEFAULT_ALLOWED_HTTP_HEADERS;
    final String allowedHttpMethods =
            CorsFilter.DEFAULT_ALLOWED_HTTP_METHODS + ",PUT";
    final String allowedOrigins =
            HTTP_TOMCAT_APACHE_ORG + "," + HTTPS_WWW_APACHE_ORG;
    final String exposedHeaders = CorsFilter.DEFAULT_EXPOSED_HEADERS;
    final String supportCredentials = "false";
    final String preflightMaxAge =
            CorsFilter.DEFAULT_PREFLIGHT_MAXAGE;
    final String decorateRequest = CorsFilter.DEFAULT_DECORATE_REQUEST;

    return generateFilterConfig(allowedHttpHeaders, allowedHttpMethods,
            allowedOrigins, exposedHeaders, supportCredentials,
            preflightMaxAge, decorateRequest);
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:19,代码来源:TesterFilterConfigs.java

示例6: testGetSimpleAuthDefaultConfiguration

import javax.servlet.FilterConfig; //导入依赖的package包/类
@Test
public void testGetSimpleAuthDefaultConfiguration() throws ServletException {
  AuthFilter filter = new AuthFilter();
  Map<String, String> m = new HashMap<String,String>();
  
  FilterConfig config = new DummyFilterConfig(m);
  Properties p = filter.getConfiguration("random", config);
  Assert.assertEquals("true",
      p.getProperty(PseudoAuthenticationHandler.ANONYMOUS_ALLOWED));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestAuthFilter.java

示例7: init

import javax.servlet.FilterConfig; //导入依赖的package包/类
@Override
public void init(FilterConfig filterConfig) throws ServletException {
    this.filterConfig = filterConfig;
    ServletContext servletContext = filterConfig.getServletContext();

    // use decorators from context attributes
    Object contextAttribute = servletContext.getAttribute(SPAN_DECORATORS);
    if (contextAttribute instanceof Collection) {
        List<ServletFilterSpanDecorator> decorators = new ArrayList<>();
        for (Object decorator: (Collection)contextAttribute) {
            if (decorator instanceof ServletFilterSpanDecorator) {
                decorators.add((ServletFilterSpanDecorator) decorator);
            } else {
                log.severe(decorator + " is not an instance of " + ServletFilterSpanDecorator.class);
            }
        }
        this.spanDecorators = decorators.size() > 0 ? decorators : this.spanDecorators;
    }

    contextAttribute = servletContext.getAttribute(SKIP_PATTERN);
    if (contextAttribute instanceof Pattern) {
        skipPattern = (Pattern) contextAttribute;
    }
}
 
开发者ID:opentracing-contrib,项目名称:java-web-servlet-filter,代码行数:25,代码来源:TracingFilter.java

示例8: setup

import javax.servlet.FilterConfig; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    proxyFilter = spy(new ProxyFilter());
    requestMock = mock(HttpServletRequest.class);
    doReturn("/oscm-portal").when(requestMock).getContextPath();
    doReturn("/oscm-portal/opt/80e8/").when(requestMock)
            .getRequestURI();
    responseMock = mock(HttpServletResponse.class);
    chainMock = mock(FilterChain.class);
    responseHandlerMock = mock(ResponseHandler.class);
    filterConfigMock = mock(FilterConfig.class);
    serverMock = mock(Server.class);
    doReturn(serverMock).when(requestMock).getAttribute(eq("proxyServer"));
    ruleMock = mock(Rule.class);
    doReturn(ruleMock).when(serverMock).getRule();
    doReturn(requestMock).when(serverMock).preExecute(
            any(HttpServletRequest.class));
    doReturn("/oscm-portal/opt/80e8/").when(ruleMock).process(
            anyString());
    doReturn("http").when(requestMock).getScheme();
    doReturn("localhost:8180").when(serverMock).getDomainName();
    doReturn("").when(serverMock).getPath();
    proxyFilter.init(filterConfigMock);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:25,代码来源:ProxyFilterTest.java

示例9: correlationIdFilter

import javax.servlet.FilterConfig; //导入依赖的package包/类
@Bean
public FilterRegistrationBean correlationIdFilter() {
    return new FilterRegistrationBean(new Filter() {

        @Override
        public void init(FilterConfig filterConfig) throws ServletException {
        }

        @Override
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
            chain.doFilter(request, response);
        }

        @Override
        public void destroy() {
        }
    });
}
 
开发者ID:voyages-sncf-technologies,项目名称:cerebro,代码行数:19,代码来源:App.java

示例10: testSameOrigin

import javax.servlet.FilterConfig; //导入依赖的package包/类
@Test
public void testSameOrigin() throws ServletException, IOException {

  // Setup the configuration settings of the server
  Map<String, String> conf = new HashMap<String, String>();
  conf.put(CrossOriginFilter.ALLOWED_ORIGINS, "");
  FilterConfig filterConfig = new FilterConfigTest(conf);

  // Origin is not specified for same origin requests
  HttpServletRequest mockReq = mock(HttpServletRequest.class);
  when(mockReq.getHeader(CrossOriginFilter.ORIGIN)).thenReturn(null);

  // Objects to verify interactions based on request
  HttpServletResponse mockRes = mock(HttpServletResponse.class);
  FilterChain mockChain = mock(FilterChain.class);

  // Object under test
  CrossOriginFilter filter = new CrossOriginFilter();
  filter.init(filterConfig);
  filter.doFilter(mockReq, mockRes, mockChain);

  verifyZeroInteractions(mockRes);
  verify(mockChain).doFilter(mockReq, mockRes);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestCrossOriginFilter.java

示例11: getSecureFilterConfig

import javax.servlet.FilterConfig; //导入依赖的package包/类
public static FilterConfig getSecureFilterConfig() {
    final String allowedHttpHeaders =
            CorsFilter.DEFAULT_ALLOWED_HTTP_HEADERS;
    final String allowedHttpMethods =
            CorsFilter.DEFAULT_ALLOWED_HTTP_METHODS + ",PUT";
    final String allowedOrigins = HTTPS_WWW_APACHE_ORG;
    final String exposedHeaders = CorsFilter.DEFAULT_EXPOSED_HEADERS;
    final String supportCredentials = "true";
    final String preflightMaxAge =
            CorsFilter.DEFAULT_PREFLIGHT_MAXAGE;
    final String decorateRequest = CorsFilter.DEFAULT_DECORATE_REQUEST;

    return generateFilterConfig(allowedHttpHeaders, allowedHttpMethods,
            allowedOrigins, exposedHeaders, supportCredentials,
            preflightMaxAge, decorateRequest);
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:17,代码来源:TesterFilterConfigs.java

示例12: initStaticFileList

import javax.servlet.FilterConfig; //导入依赖的package包/类
private void initStaticFileList(FilterConfig filterConfig) {
    // 先初始化默认后缀
    ignoreSuffix.addAll(Arrays.asList(DEFULT_STATIC_FILE_SUFFIX));
    String staticFileList = this.getPropertyFromInitParams(filterConfig, IGNORE_STATIC_FILE_SUFFIXS, StringUtils.EMPTY);
    if (StringUtils.isBlank(staticFileList)) {
        return;
    }

    // 如果列表配置不为空,则要清空列表
    ignoreSuffix.clear();

    // 循环并把配置的加入列表
    String[] lists = staticFileList.split(",");
    List<String> ignoreList = new ArrayList<String>();
    if (lists != null && lists.length > 0) {
        for (String s : lists) {
            if (StringUtils.isNotBlank(s)) {
                ignoreList.add(s.trim());
            }
        }
        if (ignoreList.size() > 0) {
            ignoreSuffix.addAll(ignoreList);
        }
    }
}
 
开发者ID:bridgeli,项目名称:netty-socketio-demo,代码行数:26,代码来源:AbstractConfigurationFilter.java

示例13: testCrossOriginFilter

import javax.servlet.FilterConfig; //导入依赖的package包/类
@Test
public void testCrossOriginFilter() throws ServletException, IOException {

  // Setup the configuration settings of the server
  Map<String, String> conf = new HashMap<String, String>();
  conf.put(CrossOriginFilter.ALLOWED_ORIGINS, "example.com");
  FilterConfig filterConfig = new FilterConfigTest(conf);

  // Origin is not specified for same origin requests
  HttpServletRequest mockReq = mock(HttpServletRequest.class);
  when(mockReq.getHeader(CrossOriginFilter.ORIGIN)).thenReturn("example.com");
  when(mockReq.getHeader(CrossOriginFilter.ACCESS_CONTROL_REQUEST_METHOD))
      .thenReturn("GET");
  when(mockReq.getHeader(CrossOriginFilter.ACCESS_CONTROL_REQUEST_HEADERS))
      .thenReturn("X-Requested-With");

  // Objects to verify interactions based on request
  HttpServletResponse mockRes = mock(HttpServletResponse.class);
  FilterChain mockChain = mock(FilterChain.class);

  // Object under test
  CrossOriginFilter filter = new CrossOriginFilter();
  filter.init(filterConfig);
  filter.doFilter(mockReq, mockRes, mockChain);

  verify(mockRes).setHeader(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN,
      "example.com");
  verify(mockRes).setHeader(
      CrossOriginFilter.ACCESS_CONTROL_ALLOW_CREDENTIALS,
      Boolean.TRUE.toString());
  verify(mockRes).setHeader(CrossOriginFilter.ACCESS_CONTROL_ALLOW_METHODS,
      filter.getAllowedMethodsHeader());
  verify(mockRes).setHeader(CrossOriginFilter.ACCESS_CONTROL_ALLOW_HEADERS,
      filter.getAllowedHeadersHeader());
  verify(mockChain).doFilter(mockReq, mockRes);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:TestCrossOriginFilter.java

示例14: init

import javax.servlet.FilterConfig; //导入依赖的package包/类
@Override
public void init(FilterConfig config) throws ServletException {
    this.filterConfig = config;
    if (this.filterConfig == null) {
        logger.info("No configuration for: " + this.getClass().getName());
    }

    init();
}
 
开发者ID:discoverygarden,项目名称:fcrepo3-security-jaas,代码行数:10,代码来源:UpstreamAuthFilterJAAS.java

示例15: init

import javax.servlet.FilterConfig; //导入依赖的package包/类
@Override
public void init(FilterConfig filterConfig) throws ServletException {
	Enumeration<String> paramNames = filterConfig.getInitParameterNames();
	while (paramNames.hasMoreElements()) {
		String paramName = paramNames.nextElement();
		if (!IntrospectionUtils.setProperty(this, paramName, filterConfig.getInitParameter(paramName))) {
			String msg = sm.getString("filterbase.noSuchProperty", paramName, this.getClass().getName());
			if (isConfigProblemFatal()) {
				throw new ServletException(msg);
			} else {
				getLogger().warn(msg);
			}
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:16,代码来源:FilterBase.java


注:本文中的javax.servlet.FilterConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。