복잡하기 때문에 부분 부분 알아보고 나중에 합쳐 보자.

인증된 사용자 정보는 Principal이라고 한다.

이 정보를 Authentication 객체에 담아서 관리하고 그 밖을 또 두번 감싼다.

SecurityContextHolder

전역 데이터를 한번 사용해 보자.

@Service
public class SampleService {

	public void dashboard() {
		Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
		Object principal = authentication.getPrincipal();
		Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
		Object credentials = authentication.getCredentials();
		boolean authenticated = authentication.isAuthenticated();
	}
}