當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。