SpringSecurityにて手動でAuthentication情報を書き換えるサンプルを紹介します。
Authentication情報の書き換えサンプル
public class RewriteClientInfoSample {
@Autowired
private AuthenticationManager authManager;
private void rewriteClientInfo(String principal, String credential) {
UsernamePasswordAuthenticationToken authReq = new UsernamePasswordAuthenticationToken(principal, credential);
Authentication auth = authManager.authenticate(authReq);
SecurityContextHolder.getContext().setAuthentication(auth);
}
}