use of org.springframework.security.web.context.SecurityContextPersistenceFilter in project motech by motech.
the class SecurityRuleBuilder method addSecurityContextPersistenceFilter.
private void addSecurityContextPersistenceFilter(List<Filter> filters, SecurityContextRepository contextRepository) {
SecurityContextPersistenceFilter securityContextFilter = new SecurityContextPersistenceFilter(contextRepository);
filters.add(securityContextFilter);
}
use of org.springframework.security.web.context.SecurityContextPersistenceFilter in project spring-security by spring-projects.
the class SecurityContextConfigurer method configure.
@Override
@SuppressWarnings("unchecked")
public void configure(H http) {
SecurityContextRepository securityContextRepository = http.getSharedObject(SecurityContextRepository.class);
if (securityContextRepository == null) {
securityContextRepository = new HttpSessionSecurityContextRepository();
}
SecurityContextPersistenceFilter securityContextFilter = new SecurityContextPersistenceFilter(securityContextRepository);
SessionManagementConfigurer<?> sessionManagement = http.getConfigurer(SessionManagementConfigurer.class);
SessionCreationPolicy sessionCreationPolicy = (sessionManagement != null) ? sessionManagement.getSessionCreationPolicy() : null;
if (SessionCreationPolicy.ALWAYS == sessionCreationPolicy) {
securityContextFilter.setForceEagerSessionCreation(true);
}
securityContextFilter = postProcess(securityContextFilter);
http.addFilter(securityContextFilter);
}
use of org.springframework.security.web.context.SecurityContextPersistenceFilter in project spring-security by spring-projects.
the class SecurityMockMvcRequestPostProcessorsJwtTests method setup.
@BeforeEach
public void setup() {
SecurityContextPersistenceFilter filter = new SecurityContextPersistenceFilter(this.repository);
MockServletContext servletContext = new MockServletContext();
servletContext.setAttribute(BeanIds.SPRING_SECURITY_FILTER_CHAIN, new FilterChainProxy(new DefaultSecurityFilterChain(AnyRequestMatcher.INSTANCE, filter)));
this.request = new MockHttpServletRequest(servletContext);
WebTestUtils.setSecurityContextRepository(this.request, this.repository);
}
Aggregations