added fix to preserve custom UserDetails implementations (Matt DeHoust fix recommendation)

This commit is contained in:
Mark St. Godard 2005-09-19 02:22:44 +00:00
parent d44b570087
commit 24394b7b2b
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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() {