OK挖了一下,终于找到了答案。
我们可以创建一个UsernamePasswordAuthenticationToken并将更新的Principal分配给上下文。
Authentication authentication = new UsernamePasswordAuthenticationToken(userObject, userObject.getPassword(), userObject.getAuthorities());SecurityContextHolder.getContext().setAuthentication(authentication);



