스프링
Spring Security - username 정보 가져오기
미랭군
2012. 1. 9. 17:18
아래와 같이 하면 Spring Security를 사용할 때 User와 관련된 정보(username, password, authorities)를 얻어올 수 있다.
User user = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
System.out.println("username = " + user.getName());
User user = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
System.out.println("username = " + user.getName());