일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
- s4a
- 안드로이드
- 설정
- html5
- mysql
- 잡토이 메이킹 코딩 학원
- 라즈베리파이
- Android
- 시작하기
- 설치
- 오라클
- 잡토이
- Unity
- 운정
- jsp
- 유니티
- 파주
- 예제
- MSSQL
- 코딩
- librecad
- tomcat
- oracle
- 리브레캐드
- Spring Security
- 강좌
- 스크래치
- 아두이노
- 톰캣
- jobtoy
- Today
- Total
랩제이
[spring security] 이용자 정보 가져오기 설정하기 본문
[spring security] 이용자 정보 가져오기 설정하기
Security에서 로그인을 하면 com.swick.service.impl.UserDetailsServiceImpl의 loadUserByUsername(...) 에서
이용자정보를 DB에서 가지고와서 org.springframework.security.core.userdetails.UserDetails에 저장합니다.
여기서는 로그인 유저 정보 저장을 위해서
com.swick.service.impl.UserDetailsImpl에서 LibroCustomer를 상속받아서 set, get을 선언해두었습니다.
그리고 UserDetailsServiceImpl에서 DB조회된 값을 set해주었습니다.
java소스에서 로그인 유저 정보를 가져올 때
SecurityContext context = SecurityContextHolder.getContext();
Object principalObj = context.getAuthentication().getPrincipal();
선언하고 principalObj 로 DB조회된 유저정보를 get합니다.
String custId = ((UserDetailsImpl) principalObj).getUsername();
String userId = ((UserDetailsImpl) principalObj).getUsername();
String userPw = ((UserDetailsImpl) principalObj).getPassword();
String userNm = ((UserDetailsImpl) principalObj).getCusName();
[spring security] 이용자 정보 가져오기 설정하기
'programming > spring_security' 카테고리의 다른 글
[Spring Security] STS로 Spring Security 시작하기 (2) | 2016.08.05 |
---|---|
[spring security] 파일 다운로드 (0) | 2014.11.17 |
[spring security] 페이징 게시판 만들기 2) 고객센터 게시판 달기 (0) | 2014.09.19 |
[spring security] jquery li 클릭시 자바스크립트 push 이용하기 (0) | 2014.09.16 |
[spring security] mybatis Map으로 요청해서 List Map으로 가져오기 (0) | 2014.09.16 |