1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Merge branch '5.8.x'

# Conflicts:
#	web/src/main/java/org/springframework/security/web/context/HttpSessionSecurityContextRepository.java
#	web/src/test/java/org/springframework/security/web/context/SecurityContextRepositoryTests.java
This commit is contained in:
Steve Riesenberg
2022-10-17 19:35:27 -05:00
13 changed files with 445 additions and 23 deletions
@@ -75,6 +75,7 @@ import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.context.DeferredSecurityContext;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.context.SecurityContextHolderStrategy;
@@ -487,7 +488,8 @@ public class MiscHttpConfigTests {
this.spring.configLocations(xml("ExplicitSaveAndExplicitRepository")).autowire();
SecurityContextRepository repository = this.spring.getContext().getBean(SecurityContextRepository.class);
SecurityContext context = new SecurityContextImpl(new TestingAuthenticationToken("user", "password"));
given(repository.loadContext(any(HttpServletRequest.class))).willReturn(() -> context);
given(repository.loadDeferredContext(any(HttpServletRequest.class)))
.willReturn(new TestDeferredSecurityContext(context, false));
// @formatter:off
MvcResult result = this.mvc.perform(formLogin())
.andExpect(status().is3xxRedirection())
@@ -1037,4 +1039,27 @@ public class MiscHttpConfigTests {
}
static class TestDeferredSecurityContext implements DeferredSecurityContext {
private SecurityContext securityContext;
private boolean isGenerated;
TestDeferredSecurityContext(SecurityContext securityContext, boolean isGenerated) {
this.securityContext = securityContext;
this.isGenerated = isGenerated;
}
@Override
public SecurityContext get() {
return this.securityContext;
}
@Override
public boolean isGenerated() {
return this.isGenerated;
}
}
}