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


Java DelegatingFilterProxy类代码示例

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


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

示例1: beforeSpringSecurityFilterChain

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
@Override
// Questo serve (anche) per consentire il file upload verso url protette:
//   The first option is to ensure that the MultipartFilter is specified before the Spring Security filter. 
//   Specifying the MultipartFilter before the Spring Security filter means that there is no authorization 
//   for invoking the MultipartFilter which means anyone can place temporary files on your server. 
//   However, only authorized users will be able to submit a File that is processed by your application. 
//   In general, this is the recommended approach because the temporary file upload should have a 
//   negligble impact on most servers.
   protected void beforeSpringSecurityFilterChain(ServletContext servletContext) {
	// Per aggiungere altri filtri basta metterli in fila, in ordine di esecuzione
       // insertFilters(servletContext, new YadaMultipartExceptionHandler(), new MultipartFilter());
	CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
	characterEncodingFilter.setEncoding("UTF-8");
	characterEncodingFilter.setForceEncoding(true);
	// L'AuditFilter lo metto prima di tutto almeno viene eseguito prima dell'autorizzazione e riesco a capire il motivo di eventuali 403
	// For some reason the characterEncodingFilter can not be after the MultipartFilter otherwise encoding in forms doesn't work (for non-multipart forms).
       insertFilters(servletContext, new CheckSessionFilter(), characterEncodingFilter, new AuditFilter(), new MultipartFilter(), new DelegatingFilterProxy("yadaLocalePathVariableFilter"));
   }
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:19,代码来源:SecurityWebApplicationInitializer.java

示例2: onStartup

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
	WebApplicationContext context = getContext();
	servletContext.addListener(new ContextLoaderListener(context));
	servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter("UTF-8"));

	DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
	dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);

	ServletRegistration.Dynamic dispatcher = servletContext.addServlet("Dispatcher", dispatcherServlet);
	dispatcher.setLoadOnStartup(1);
	dispatcher.addMapping("/*");

	CXFServlet cxf = new CXFServlet();
	BusFactory.setDefaultBus(cxf.getBus());
	ServletRegistration.Dynamic cxfServlet = servletContext.addServlet("CXFServlet", cxf);
	cxfServlet.setLoadOnStartup(1);
	cxfServlet.addMapping("/services/*");

	servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain")).addMappingForUrlPatterns(null, false,
			"/*");

	servletContext.getSessionCookieConfig().setSecure(cookieSecure);
}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:25,代码来源:AppInitializer.java

示例3: onStartup

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
/**
 * Configure the given {@link ServletContext} with any servlets, filters, listeners
 * context-params and attributes necessary for initializing this web application. See examples
 * {@linkplain WebApplicationInitializer above}.
 *
 * @param servletContext the {@code ServletContext} to initialize
 * @throws ServletException if any call against the given {@code ServletContext} throws a {@code ServletException}
 */
public void onStartup(ServletContext servletContext) throws ServletException {
	// Spring Context Bootstrapping
	AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext();
	rootAppContext.register(AutoPivotConfig.class);
	servletContext.addListener(new ContextLoaderListener(rootAppContext));

	// Set the session cookie name. Must be done when there are several servers (AP,
	// Content server, ActiveMonitor) with the same URL but running on different ports.
	// Cookies ignore the port (See RFC 6265).
	CookieUtil.configure(servletContext.getSessionCookieConfig(), CookieUtil.COOKIE_NAME);

	// The main servlet/the central dispatcher
	final DispatcherServlet servlet = new DispatcherServlet(rootAppContext);
	servlet.setDispatchOptionsRequest(true);
	Dynamic dispatcher = servletContext.addServlet("springDispatcherServlet", servlet);
	dispatcher.addMapping("/*");
	dispatcher.setLoadOnStartup(1);

	// Spring Security Filter
	final FilterRegistration.Dynamic springSecurity = servletContext.addFilter(SPRING_SECURITY_FILTER_CHAIN, new DelegatingFilterProxy());
	springSecurity.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");

}
 
开发者ID:activeviam,项目名称:autopivot,代码行数:32,代码来源:AutoPivotWebAppInitializer.java

示例4: onStartup

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
@Override
public void onStartup(ServletContext sc) throws ServletException {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(AppConfig.class);

    sc.addListener(new ContextLoaderListener(context));
    sc.setInitParameter("defaultHtmlEscape", "true");

    ServletRegistration.Dynamic dispatcher = sc.addServlet("dispatcherServlet", new DispatcherServlet(context));

    dispatcher.setLoadOnStartup(1);
    dispatcher.setAsyncSupported(true);
    dispatcher.addMapping("/");

    FilterRegistration.Dynamic securityFilter = sc.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class);
    securityFilter.addMappingForUrlPatterns(null, false, "/*");
    securityFilter.setAsyncSupported(true);
}
 
开发者ID:ortolanph,项目名称:hojeehdiaderua,代码行数:19,代码来源:DiaDeRuaWebInitializer.java

示例5: onStartup

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
	Map<String, String> filterChainDefinitionMap = Application.getSecurityFilterChainDefinitionMap();
	filterChainDefinitionMap.put("/admin", DefaultFilter.authc.name());
	filterChainDefinitionMap.put("/admin/logout", DefaultFilter.logout.name());
	filterChainDefinitionMap.put("/admin/**", DefaultFilter.authc.name());

	List<Filter> filters = Application.getFilters();

	DelegatingFilterProxy shiroFilter = new DelegatingFilterProxy("shiroFilter");
	shiroFilter.setTargetFilterLifecycle(true);
	filters.add(shiroFilter);

	filters.add(new RequestContextFilter());
	filters.add(new CharacterEncodingFilter("UTF-8", true));
}
 
开发者ID:xiangxik,项目名称:java-platform,代码行数:17,代码来源:CentralizeInitializer.java

示例6: registerRestApiServlet

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
protected void registerRestApiServlet(ServletContext servletContext) {
    CubaRestApiServlet cubaRestApiServlet = new SingleAppRestApiServlet(dependencyJars);
    try {
        cubaRestApiServlet.init(new CubaServletConfig("rest_api", servletContext));
    } catch (ServletException e) {
        throw new RuntimeException("An error occurred while initializing dispatcher servlet", e);
    }
    ServletRegistration.Dynamic cubaRestApiServletReg = servletContext.addServlet("rest_api", cubaRestApiServlet);
    cubaRestApiServletReg.setLoadOnStartup(2);
    cubaRestApiServletReg.addMapping("/rest/*");

    DelegatingFilterProxy restSpringSecurityFilterChain = new DelegatingFilterProxy();
    restSpringSecurityFilterChain.setContextAttribute("org.springframework.web.servlet.FrameworkServlet.CONTEXT.rest_api");
    restSpringSecurityFilterChain.setTargetBeanName("springSecurityFilterChain");

    FilterRegistration.Dynamic restSpringSecurityFilterChainReg =
            servletContext.addFilter("restSpringSecurityFilterChain", restSpringSecurityFilterChain);
    restSpringSecurityFilterChainReg.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/rest/*");
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:SingleAppWebContextLoader.java

示例7: onStartup

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
@Override
public void onStartup(ServletContext container) throws ServletException {
    AnnotationConfigWebApplicationContext rootContext =
            new AnnotationConfigWebApplicationContext();
    rootContext.register(AppConfig.class);

    container.addListener(new ContextLoaderListener(rootContext));

    //container.addListener(EnvironmentLoaderListener.class);
    //container.setInitParameter("shiroEnvironmentClass","org.apache.shiro.web.env.DefaultWebEnvironment");


    container.addListener(SessionSupport.class);
    container.setInitParameter("org.atmosphere.cpr.sessionSupport","true");

    EnumSet<DispatcherType> d = EnumSet.of(DispatcherType.REQUEST
            ,DispatcherType.ASYNC
            ,DispatcherType.ERROR,DispatcherType.FORWARD,DispatcherType.INCLUDE);

    FilterRegistration.Dynamic shiroFilter = container.addFilter("shiroFilter", DelegatingFilterProxy.class);
        shiroFilter.setInitParameter("targetFilterLifecycle","true");
        shiroFilter.addMappingForUrlPatterns(d, false, "/*");
        shiroFilter.setAsyncSupported(true);
}
 
开发者ID:jvalenciag,项目名称:VaadinSpringShiroMongoDB,代码行数:25,代码来源:CustomWebApplicationInitializer.java

示例8: addFilter

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
protected void addFilter(final ServletContext ctx) {

        AccessFilter af= (AccessFilter) rootContext.getBean("accessFilter");
        CharacterEncodingFilter cef = (CharacterEncodingFilter) rootContext.getBean("characterEncodingFilter");

        DelegatingFilterProxy dfp = new DelegatingFilterProxy("springSecurityFilterChain");

        EnumSet<DispatcherType> dts=EnumSet.allOf(DispatcherType.class);

        // Access log filter
        ctx.addFilter("accessFilter",af).addMappingForUrlPatterns(dts,true,"/*");
        // Error wrapper filter
        // Character encoding filter
        ctx.addFilter("characterEncodingFilter", cef).addMappingForUrlPatterns(dts, true, "/*");
        // Spring security filter
        ctx.addFilter("spring-security", dfp).addMappingForUrlPatterns(dts, true, "/*");

    }
 
开发者ID:rockagen,项目名称:security-stateless-samples,代码行数:19,代码来源:BootStrap.java

示例9: onStartup

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
	logger.info("*** entered #onStartup");
	WebApplicationContext context = getContext();

	// Manage the lifecycle of the application context and stop jetty, if the initialization of the context fails
	servletContext.addListener(new ContextListener(context));

	// add spring-security
	DelegatingFilterProxy securityFilter = new DelegatingFilterProxy("springSecurityFilterChain");
	securityFilter.setServletContext(servletContext);
	servletContext.addFilter("springSecurityFilterChain", securityFilter).addMappingForUrlPatterns(null, true, "/*");
	
	ServletRegistration.Dynamic fmConnector = servletContext.addServlet("fmConnectorServlet", new ConnectorServlet());
	fmConnector.setLoadOnStartup(10);
	fmConnector.addMapping("/filemanager/connectors/java/*");
	
	// Register and map the dispatcher servlet
	ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher-servlet", new DispatcherServlet(context));
	dispatcher.setLoadOnStartup(20);
	dispatcher.addMapping("/*");
}
 
开发者ID:th-schwarz,项目名称:bacoma,代码行数:23,代码来源:WebInitializer.java

示例10: onStartup

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
@Override
public void onStartup(ServletContext container) throws ServletException {
    XmlWebApplicationContext context = new XmlWebApplicationContext();

    context.setConfigLocations(CONTEXT_CONFIG_LOCATIONS);

    DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
    dispatcherServlet.setPublishContext(true);

    FilterRegistration.Dynamic sessionFilter = container.addFilter("sessionFilter", new DelegatingFilterProxy("sessionFilter"));

    sessionFilter.addMappingForUrlPatterns(null, false, "*.jsp");

    this.servlets.stream().forEach( servlet -> {
        addServlet(container, sessionFilter, servlet);
    });
}
 
开发者ID:bullhorn,项目名称:starter-kit-spring-maven,代码行数:18,代码来源:ServletInitializer.java

示例11: onStartup

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {

    //Create webapp context
    AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); //part of spring-web
    root.register(SpringSecurityConfiguration.class); //register class by annotation. Here be all security rules.

    //Register DelegatingFilterProxy
    FilterRegistration.Dynamic springSecurityFilterChainReg = servletContext.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class);
    springSecurityFilterChainReg.addMappingForUrlPatterns(EnumSet.of(DispatcherType.ERROR, DispatcherType.REQUEST), false, "/*");

    servletContext.addListener(new ContextLoaderListener(root));

    //Register WicketFilter
    WicketFilter wicketFilter = new WicketFilter(new WicketApplication()) {
        @Override
        public void init(boolean isServlet, FilterConfig filterConfig) throws ServletException {
            setFilterPath(""); //don't use web.xml. WicketApplication.init is a custom override for it.
            super.init(isServlet, filterConfig);
        }
    };
    FilterRegistration.Dynamic wicketFilterReg = servletContext.addFilter("wicketFilter", wicketFilter);
    wicketFilterReg.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "*");
}
 
开发者ID:holy-shit,项目名称:wicket-spring-security-example,代码行数:25,代码来源:AppInitializer.java

示例12: onStartup

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    CharacterEncodingFilter filter = new CharacterEncodingFilter();
    filter.setEncoding("UTF-8");
    filter.setForceEncoding(true);
    servletContext.addFilter("characterEncodingFilter", filter).addMappingForUrlPatterns(null, false, "/*");

    servletContext.addFilter("openEntityManagerInViewFilter", new OpenEntityManagerInViewFilter()).addMappingForUrlPatterns(null, false, "/*");

    DelegatingFilterProxy delegatingFilterProxy = new DelegatingFilterProxy();
    delegatingFilterProxy.setTargetFilterLifecycle(true);
    servletContext.addFilter("shiroFilter", delegatingFilterProxy).addMappingForUrlPatterns(null, false, "/*");

    servletContext.addServlet("kaptcha", new KaptchaServlet()).addMapping("/kaptcha");

    super.onStartup(servletContext);
}
 
开发者ID:qatang,项目名称:ctm,代码行数:18,代码来源:WebInitializer.java

示例13: contextInitialized

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
public void contextInitialized(ServletContextEvent sce) {
	ServletContext servletContext = sce.getServletContext();
	
	Object attribute = servletContext.getAttribute( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE );
	if(attribute == null){
		Enumeration<String> attributeNames = servletContext.getAttributeNames();
		throw new IllegalStateException( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + " not ready. Available attributes: " + EnumerationUtils.toList(attributeNames) );
	}
	
	EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST);
	boolean isMatchAfter = true;
	String urlPatterns = "/*";
	servletContext
		.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class.getCanonicalName())
		.addMappingForUrlPatterns(dispatcherTypes, isMatchAfter, urlPatterns);
	;
}
 
开发者ID:danidemi,项目名称:jlubricant,代码行数:18,代码来源:SpringSecurityFeature.java

示例14: onStartup

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(RootApplicationContext.class);

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(rootContext));
    dispatcher.setLoadOnStartup(1);
    dispatcher.setAsyncSupported(true);
    dispatcher.addMapping("/");

    EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);

    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");
    characterEncodingFilter.setForceEncoding(true);

    FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter);
    characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*");

    FilterRegistration.Dynamic security = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());
    security.addMappingForUrlPatterns(dispatcherTypes, true, "/*");

    servletContext.addListener(new ContextLoaderListener(rootContext));
}
 
开发者ID:the-james-burton,项目名称:sshw,代码行数:25,代码来源:RootApplicationConfig.java

示例15: delegatingFilterProxy

import org.springframework.web.filter.DelegatingFilterProxy; //导入依赖的package包/类
/**
 * 注册DelegatingFilterProxy(Shiro)
 *
 * @return
 * @author SHANHY
 * @create  2016年1月13日
 */
@Bean
public FilterRegistrationBean delegatingFilterProxy() {
    FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
    filterRegistration.setFilter(new DelegatingFilterProxy("shiroFilter"));
    //  该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理
    filterRegistration.addInitParameter("targetFilterLifecycle", "true");
    filterRegistration.setEnabled(true);
    filterRegistration.addUrlPatterns("/*");
    return filterRegistration;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:ShiroCasConfiguration.java


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