本文整理汇总了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"));
}
示例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);
}
示例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, "/*");
}
示例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);
}
示例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));
}
示例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/*");
}
示例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);
}
示例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, "/*");
}
示例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("/*");
}
示例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);
});
}
示例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, "*");
}
示例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);
}
示例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);
;
}
示例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));
}
示例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;
}