mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-24 04:52:16 +00:00
added fix to preserve custom UserDetails implementations (Matt DeHoust fix recommendation)
This commit is contained in:
parent
d44b570087
commit
24394b7b2b
@ -462,7 +462,7 @@ public class SwitchUserProcessingFilter implements Filter, InitializingBean,
|
||||
authorities = (GrantedAuthority[]) newAuths.toArray(authorities);
|
||||
|
||||
// create the new authentication token
|
||||
targetUserRequest = new UsernamePasswordAuthenticationToken(username,
|
||||
targetUserRequest = new UsernamePasswordAuthenticationToken(targetUser,
|
||||
targetUser.getPassword(), authorities);
|
||||
|
||||
// set details
|
||||
|
@ -355,7 +355,8 @@ public class SwitchUserProcessingFilterTests extends TestCase {
|
||||
Authentication targetAuth = SecurityContextHolder.getContext()
|
||||
.getAuthentication();
|
||||
assertNotNull(targetAuth);
|
||||
assertEquals("jacklord", targetAuth.getPrincipal());
|
||||
assertTrue(targetAuth.getPrincipal() instanceof UserDetails);
|
||||
assertEquals("jacklord", ((User)targetAuth.getPrincipal()).getUsername());
|
||||
}
|
||||
|
||||
private MockHttpServletRequest createMockSwitchRequest() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user