Class AbstractSecurityWebApplicationInitializer
- java.lang.Object
- 
- org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer
 
- 
- All Implemented Interfaces:
- org.springframework.web.WebApplicationInitializer
 
 public abstract class AbstractSecurityWebApplicationInitializer extends java.lang.Object implements org.springframework.web.WebApplicationInitializerRegisters theDelegatingFilterProxyto use the springSecurityFilterChain before any other registeredFilter. When used withAbstractSecurityWebApplicationInitializer(Class...), it will also register aContextLoaderListener. When used withAbstractSecurityWebApplicationInitializer(), this class is typically used in addition to a subclass ofAbstractContextLoaderInitializer.By default the DelegatingFilterProxyis registered without support, but can be enabled by overridingisAsyncSecuritySupported()andgetSecurityDispatcherTypes().Additional configuration before and after the springSecurityFilterChain can be added by overriding afterSpringSecurityFilterChain(ServletContext).CaveatsSubclasses of AbstractDispatcherServletInitializer will register their filters before any other Filter. This means that you will typically want to ensure subclasses of AbstractDispatcherServletInitializer are invoked first. This can be done by ensuring theOrderorOrderedof AbstractDispatcherServletInitializer are sooner than subclasses ofAbstractSecurityWebApplicationInitializer.
- 
- 
Field SummaryFields Modifier and Type Field Description static java.lang.StringDEFAULT_FILTER_NAME
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedAbstractSecurityWebApplicationInitializer()Creates a new instance that assumes the Spring Security configuration is loaded by some other means than this class.protectedAbstractSecurityWebApplicationInitializer(java.lang.Class<?>... configurationClasses)Creates a new instance that will instantiate theContextLoaderListenerwith the specified classes.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafterSpringSecurityFilterChain(javax.servlet.ServletContext servletContext)Invoked after the springSecurityFilterChain is added.protected voidappendFilters(javax.servlet.ServletContext servletContext, javax.servlet.Filter... filters)Inserts the providedFilters after existingFilters using default generated names,getSecurityDispatcherTypes(), andisAsyncSecuritySupported().protected voidbeforeSpringSecurityFilterChain(javax.servlet.ServletContext servletContext)Invoked before the springSecurityFilterChain is added.protected booleanenableHttpSessionEventPublisher()Override this ifHttpSessionEventPublishershould be added as a listener.protected java.lang.StringgetDispatcherWebApplicationContextSuffix()Return the <servlet-name> to use the DispatcherServlet'sWebApplicationContextto find theDelegatingFilterProxyor null to use the parentApplicationContext.protected java.util.EnumSet<javax.servlet.DispatcherType>getSecurityDispatcherTypes()Get theDispatcherTypefor the springSecurityFilterChain.protected java.util.Set<javax.servlet.SessionTrackingMode>getSessionTrackingModes()Determines how a session should be tracked.protected voidinsertFilters(javax.servlet.ServletContext servletContext, javax.servlet.Filter... filters)Inserts the providedFilters before existingFilters using default generated names,getSecurityDispatcherTypes(), andisAsyncSecuritySupported().protected booleanisAsyncSecuritySupported()Determine if the springSecurityFilterChain should be marked as supporting asynch.voidonStartup(javax.servlet.ServletContext servletContext)
 
- 
- 
- 
Field Detail- 
DEFAULT_FILTER_NAMEpublic static final java.lang.String DEFAULT_FILTER_NAME - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
AbstractSecurityWebApplicationInitializerprotected AbstractSecurityWebApplicationInitializer() Creates a new instance that assumes the Spring Security configuration is loaded by some other means than this class. For example, a user might create aContextLoaderListenerusing a subclass ofAbstractContextLoaderInitializer.- See Also:
- ContextLoaderListener
 
 - 
AbstractSecurityWebApplicationInitializerprotected AbstractSecurityWebApplicationInitializer(java.lang.Class<?>... configurationClasses) Creates a new instance that will instantiate theContextLoaderListenerwith the specified classes.- Parameters:
- configurationClasses-
 
 
- 
 - 
Method Detail- 
onStartuppublic final void onStartup(javax.servlet.ServletContext servletContext) - Specified by:
- onStartupin interface- org.springframework.web.WebApplicationInitializer
 
 - 
enableHttpSessionEventPublisherprotected boolean enableHttpSessionEventPublisher() Override this ifHttpSessionEventPublishershould be added as a listener. This should be true, if session management has specified a maximum number of sessions.- Returns:
- true to add HttpSessionEventPublisher, else false
 
 - 
insertFiltersprotected final void insertFilters(javax.servlet.ServletContext servletContext, javax.servlet.Filter... filters)Inserts the providedFilters before existingFilters using default generated names,getSecurityDispatcherTypes(), andisAsyncSecuritySupported().- Parameters:
- servletContext- the- ServletContextto use
- filters- the- Filters to register
 
 - 
appendFiltersprotected final void appendFilters(javax.servlet.ServletContext servletContext, javax.servlet.Filter... filters)Inserts the providedFilters after existingFilters using default generated names,getSecurityDispatcherTypes(), andisAsyncSecuritySupported().- Parameters:
- servletContext- the- ServletContextto use
- filters- the- Filters to register
 
 - 
getSessionTrackingModesprotected java.util.Set<javax.servlet.SessionTrackingMode> getSessionTrackingModes() Determines how a session should be tracked. By default,SessionTrackingMode.COOKIEis used.Note that SessionTrackingMode.URLis intentionally omitted to help protected against session fixation attacks.SessionTrackingMode.SSLis omitted because SSL configuration is required for this to work.Subclasses can override this method to make customizations. - Returns:
 
 - 
getDispatcherWebApplicationContextSuffixprotected java.lang.String getDispatcherWebApplicationContextSuffix() Return the <servlet-name> to use the DispatcherServlet'sWebApplicationContextto find theDelegatingFilterProxyor null to use the parentApplicationContext.For example, if you are using AbstractDispatcherServletInitializer or AbstractAnnotationConfigDispatcherServletInitializer and using the provided Servlet name, you can return "dispatcher" from this method to use the DispatcherServlet's WebApplicationContext.- Returns:
- the <servlet-name> of the DispatcherServlet to use its
 WebApplicationContextor null (default) to use the parentApplicationContext.
 
 - 
beforeSpringSecurityFilterChainprotected void beforeSpringSecurityFilterChain(javax.servlet.ServletContext servletContext) Invoked before the springSecurityFilterChain is added.- Parameters:
- servletContext- the- ServletContext
 
 - 
afterSpringSecurityFilterChainprotected void afterSpringSecurityFilterChain(javax.servlet.ServletContext servletContext) Invoked after the springSecurityFilterChain is added.- Parameters:
- servletContext- the- ServletContext
 
 - 
getSecurityDispatcherTypesprotected java.util.EnumSet<javax.servlet.DispatcherType> getSecurityDispatcherTypes() Get theDispatcherTypefor the springSecurityFilterChain.- Returns:
 
 - 
isAsyncSecuritySupportedprotected boolean isAsyncSecuritySupported() Determine if the springSecurityFilterChain should be marked as supporting asynch. Default is true.- Returns:
- true if springSecurityFilterChain should be marked as supporting asynch
 
 
- 
 
-