use of org.springframework.security.core.session.SessionRegistry in project spring-security by spring-projects.
the class SessionManagementConfigurer method createConccurencyFilter.
private ConcurrentSessionFilter createConccurencyFilter(H http) {
SessionInformationExpiredStrategy expireStrategy = getExpiredSessionStrategy();
SessionRegistry sessionRegistry = getSessionRegistry(http);
if (expireStrategy == null) {
return new ConcurrentSessionFilter(sessionRegistry);
}
return new ConcurrentSessionFilter(sessionRegistry, expireStrategy);
}
use of org.springframework.security.core.session.SessionRegistry in project spring-security by spring-projects.
the class SessionManagementConfigurer method getSessionRegistry.
private SessionRegistry getSessionRegistry(H http) {
if (this.sessionRegistry == null) {
this.sessionRegistry = getBeanOrNull(SessionRegistry.class);
}
if (this.sessionRegistry == null) {
SessionRegistryImpl sessionRegistry = new SessionRegistryImpl();
registerDelegateApplicationListener(http, sessionRegistry);
this.sessionRegistry = sessionRegistry;
}
return this.sessionRegistry;
}
use of org.springframework.security.core.session.SessionRegistry in project spring-security by spring-projects.
the class SessionManagementConfigTests method autowireWhenConcurrencyControlIsSetThenLogoutHandlersGetAuthenticationObject.
/**
* SEC-2057
*/
@Test
public void autowireWhenConcurrencyControlIsSetThenLogoutHandlersGetAuthenticationObject() throws Exception {
this.spring.configLocations(xml("ConcurrencyControlCustomLogoutHandler")).autowire();
MvcResult result = this.mvc.perform(get("/auth").with(httpBasic("user", "password"))).andExpect(session()).andReturn();
MockHttpSession session = (MockHttpSession) result.getRequest().getSession(false);
SessionRegistry sessionRegistry = this.spring.getContext().getBean(SessionRegistry.class);
sessionRegistry.getSessionInformation(session.getId()).expireNow();
// @formatter:off
this.mvc.perform(get("/auth").session(session)).andExpect(header().string("X-Username", "user"));
// @formatter:on
}
use of org.springframework.security.core.session.SessionRegistry in project spring-security by spring-projects.
the class NamespaceSessionManagementTests method authenticateWhenUsingExpiredUrlThenMatchesNamespace.
@Test
public void authenticateWhenUsingExpiredUrlThenMatchesNamespace() throws Exception {
this.spring.register(CustomSessionManagementConfig.class).autowire();
MockHttpSession session = new MockHttpSession();
SessionInformation sessionInformation = new SessionInformation(new Object(), session.getId(), new Date(0));
sessionInformation.expireNow();
SessionRegistry sessionRegistry = this.spring.getContext().getBean(SessionRegistry.class);
given(sessionRegistry.getSessionInformation(session.getId())).willReturn(sessionInformation);
this.mvc.perform(get("/auth").session(session)).andExpect(redirectedUrl("/expired-session"));
}
use of org.springframework.security.core.session.SessionRegistry in project spring-security by spring-projects.
the class NamespaceSessionManagementTests method authenticateWhenUsingSessionRegistryThenMatchesNamespace.
@Test
public void authenticateWhenUsingSessionRegistryThenMatchesNamespace() throws Exception {
this.spring.register(CustomSessionManagementConfig.class, BasicController.class, UserDetailsServiceConfig.class).autowire();
SessionRegistry sessionRegistry = this.spring.getContext().getBean(SessionRegistry.class);
MockHttpServletRequestBuilder request = get("/auth").with(httpBasic("user", "password"));
this.mvc.perform(request).andExpect(status().isOk());
verify(sessionRegistry).registerNewSession(any(String.class), any(Object.class));
}
Aggregations