org.springframework.security.web.session.HttpSessionEventPublisher Java Examples

The following examples show how to use org.springframework.security.web.session.HttpSessionEventPublisher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InceptionWebInitializer.java    From inception with Apache License 2.0 6 votes vote down vote up
@Override
public void onStartup(ServletContext aServletContext) throws ServletException
{
    // 2) Make username accessible to logging framework
    FilterRegistration loggingFilter = aServletContext.addFilter("logging",
            LoggingFilter.class);
    loggingFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*");

    // 5) Make sure we have one JPA session/transaction per request. Closes session at the
    // end, without this, changed data may not be automatically saved to the DB.
    FilterRegistration openSessionInViewFilter = aServletContext.addFilter("opensessioninview",
            OpenEntityManagerInViewFilter.class);
    openSessionInViewFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false,
            "/*");
    
    aServletContext.addListener(HttpSessionEventPublisher.class);
}
 
Example #2
Source File: WebAnnoWebInitializer.java    From webanno with Apache License 2.0 6 votes vote down vote up
@Override
public void onStartup(ServletContext aServletContext) throws ServletException
{
    // 2) Make username accessible to logging framework
    FilterRegistration loggingFilter = aServletContext.addFilter("logging",
            LoggingFilter.class);
    loggingFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*");

    // 5) Make sure we have one JPA session/transaction per request. Closes session at the
    // end, without this, changed data may not be automatically saved to the DB.
    FilterRegistration openSessionInViewFilter = aServletContext.addFilter("opensessioninview",
            OpenEntityManagerInViewFilter.class);
    openSessionInViewFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false,
            "/*");
    
    aServletContext.addListener(HttpSessionEventPublisher.class);
}
 
Example #3
Source File: WebAppInitializer.java    From springsecuritystudy with MIT License 5 votes vote down vote up
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain"))
    .addMappingForUrlPatterns(null, false, "/api/*");
    
    // 静态资源映射
    servletContext.getServletRegistration("default").addMapping("/static/*", "*.html", "*.ico");
    
    servletContext.addListener(HttpSessionEventPublisher.class);
    super.onStartup(servletContext);
}
 
Example #4
Source File: SecSecurityConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
    return new HttpSessionEventPublisher();
}
 
Example #5
Source File: WebConfig.java    From Spring with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
    return new HttpSessionEventPublisher();
}
 
Example #6
Source File: MolgenisWebAppInitializer.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
/** A Molgenis common web application initializer */
protected void onStartup(ServletContext servletContext, Class<?> appConfig, int maxFileSize) {
  // Create the 'root' Spring application context
  AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
  rootContext.registerShutdownHook();
  rootContext.setAllowBeanDefinitionOverriding(false);
  rootContext.register(appConfig);

  // Manage the lifecycle of the root application context
  servletContext.addListener(new ContextLoaderListener(rootContext));

  // Register and map the dispatcher servlet
  DispatcherServlet dispatcherServlet = new DispatcherServlet(rootContext);
  dispatcherServlet.setDispatchOptionsRequest(true);
  // instead of throwing a 404 when a handler is not found allow for custom handling
  dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);

  ServletRegistration.Dynamic dispatcherServletRegistration =
      servletContext.addServlet("dispatcher", dispatcherServlet);
  if (dispatcherServletRegistration == null) {
    LOG.warn(
        "ServletContext already contains a complete ServletRegistration for servlet 'dispatcher'");
  } else {
    final long maxSize = (long) maxFileSize * MB;
    dispatcherServletRegistration.addMapping("/");
    dispatcherServletRegistration.setMultipartConfig(
        new MultipartConfigElement(null, maxSize, maxSize, FILE_SIZE_THRESHOLD));
    dispatcherServletRegistration.setAsyncSupported(true);
  }

  // Add filters
  Dynamic browserDetectionFiler =
      servletContext.addFilter("browserDetectionFilter", BrowserDetectionFilter.class);
  browserDetectionFiler.setAsyncSupported(true);
  browserDetectionFiler.addMappingForUrlPatterns(
      EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC), false, "*");

  Dynamic etagFilter = servletContext.addFilter("etagFilter", ShallowEtagHeaderFilter.class);
  etagFilter.setAsyncSupported(true);
  etagFilter.addMappingForServletNames(
      EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC), true, "dispatcher");

  // enable use of request scoped beans in FrontController
  servletContext.addListener(new RequestContextListener());

  servletContext.addListener(HttpSessionEventPublisher.class);
}
 
Example #7
Source File: MolgenisWebAppSecurityConfig.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
  return new HttpSessionEventPublisher();
}
 
Example #8
Source File: MultiHttpSecurityConfig.java    From enhanced-pet-clinic with Apache License 2.0 4 votes vote down vote up
@Bean
public static ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() {
	return new ServletListenerRegistrationBean<HttpSessionEventPublisher>(new HttpSessionEventPublisher());
}
 
Example #9
Source File: RedisHttpSessionConfig.java    From spring-session with Apache License 2.0 4 votes vote down vote up
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
	return new HttpSessionEventPublisher();
}
 
Example #10
Source File: WebSecurityConfig.java    From fredbet with Creative Commons Attribution Share Alike 4.0 International 4 votes vote down vote up
@Bean
public ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() {
    return new ServletListenerRegistrationBean<>(new HttpSessionEventPublisher());
}
 
Example #11
Source File: SecurityConfig.java    From spring-boot-samples with Apache License 2.0 4 votes vote down vote up
@Bean
public ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() {
    return new ServletListenerRegistrationBean<HttpSessionEventPublisher>(new HttpSessionEventPublisher());
}
 
Example #12
Source File: SessionConfig.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
    return new HttpSessionEventPublisher();
}
 
Example #13
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
    return new HttpSessionEventPublisher();
}
 
Example #14
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
    return new HttpSessionEventPublisher();
}
 
Example #15
Source File: SessionConfig.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
    return new HttpSessionEventPublisher();
}
 
Example #16
Source File: SecurityConfig.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
    return new HttpSessionEventPublisher();
}
 
Example #17
Source File: SpringContextConfig.java    From Spring-5.0-Cookbook with MIT License 4 votes vote down vote up
@Bean
 public HttpSessionEventPublisher httpSessionEventPublisher() {
	    return new HttpSessionEventPublisher();
}
 
Example #18
Source File: SpringContextConfig.java    From Spring-5.0-Cookbook with MIT License 4 votes vote down vote up
@Bean
 public HttpSessionEventPublisher httpSessionEventPublisher() {
	    return new HttpSessionEventPublisher();
}
 
Example #19
Source File: SecurityAutoConfiguration.java    From albedo with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public HttpSessionEventPublisher httpSessionEventPublisher() {
	return new HttpSessionEventPublisher();
}
 
Example #20
Source File: SecurityManagedConfiguration.java    From hawkbit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Listener to redirect to login page after session timeout. Close the
 * vaadin session, because it's is not possible to redirect in
 * atmosphere.
 *
 * @return the servlet listener.
 */
@Bean
public ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() {
    return new ServletListenerRegistrationBean<>(new HttpSessionEventPublisher());
}