

250521 김혜민 사용자 검증 서비스 추가 및 리팩토링
@bc5e24e5973815b1f76617e3b7d7e66a6bfce4d9
--- src/main/java/com/takensoft/cms/accesCtrl/service/Impl/AccesCtrlServiceImpl.java
+++ src/main/java/com/takensoft/cms/accesCtrl/service/Impl/AccesCtrlServiceImpl.java
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 |
import com.takensoft.cms.codeManage.vo.CodeManageVO; |
8 | 8 |
import com.takensoft.common.Pagination; |
9 | 9 |
import com.takensoft.common.exception.*; |
10 |
-import com.takensoft.common.util.JWTUtil; |
|
10 |
+import com.takensoft.common.service.VerificationService; |
|
11 | 11 |
import lombok.RequiredArgsConstructor; |
12 | 12 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
13 | 13 |
import org.slf4j.Logger; |
... | ... | @@ -43,9 +43,9 @@ |
43 | 43 |
public class AccesCtrlServiceImpl extends EgovAbstractServiceImpl implements AccesCtrlService { |
44 | 44 |
|
45 | 45 |
private static final Logger LOGGER = LoggerFactory.getLogger(AccesCtrlServiceImpl.class); |
46 |
- private final JWTUtil jwtUtil; |
|
47 | 46 |
private final AccesCtrlDAO accesCtrlDAO; |
48 | 47 |
private final CodeManageService codeManageService; |
48 |
+ private final VerificationService verificationService; |
|
49 | 49 |
|
50 | 50 |
/** |
51 | 51 |
* @param accesCtrlVO - 접근 제어 정보 |
... | ... | @@ -64,7 +64,7 @@ |
64 | 64 |
public Map<String, Object> accesCtrlSave(AccesCtrlVO accesCtrlVO) { |
65 | 65 |
try { |
66 | 66 |
// 등록된 토큰에서 사용자 정보 조회 |
67 |
- String writer = jwtUtil.getWriter(); |
|
67 |
+ String writer = verificationService.getCurrentUserId(); |
|
68 | 68 |
if (writer == null || writer.isEmpty()) { |
69 | 69 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
70 | 70 |
} |
... | ... | @@ -101,7 +101,7 @@ |
101 | 101 |
public int accesCtrlUpdate(AccesCtrlVO accesCtrlVO) { |
102 | 102 |
try { |
103 | 103 |
// 등록된 토큰에서 사용자 정보 조회 |
104 |
- String writer = jwtUtil.getWriter(); |
|
104 |
+ String writer = verificationService.getCurrentUserId(); |
|
105 | 105 |
if (writer == null || writer.isEmpty()) { |
106 | 106 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
107 | 107 |
} |
--- src/main/java/com/takensoft/cms/bbs/service/Impl/BbsCnServiceImpl.java
+++ src/main/java/com/takensoft/cms/bbs/service/Impl/BbsCnServiceImpl.java
... | ... | @@ -12,7 +12,7 @@ |
12 | 12 |
import com.takensoft.common.file.service.FileMngService; |
13 | 13 |
import com.takensoft.common.file.vo.FileMngVO; |
14 | 14 |
import com.takensoft.common.idgen.service.IdgenService; |
15 |
-import com.takensoft.common.util.JWTUtil; |
|
15 |
+import com.takensoft.common.service.VerificationService; |
|
16 | 16 |
import lombok.RequiredArgsConstructor; |
17 | 17 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
18 | 18 |
import org.jsoup.Jsoup; |
... | ... | @@ -55,10 +55,8 @@ |
55 | 55 |
private final BbsMngDAO bbsMngDAO; |
56 | 56 |
private final FileDAO fileDAO; |
57 | 57 |
private final WordMngDAO wordMngDAO; |
58 |
- |
|
58 |
+ private final VerificationService verificationService; |
|
59 | 59 |
private final IdgenService bbsIdgn; |
60 |
- private final JWTUtil jwtUtil; |
|
61 |
- |
|
62 | 60 |
private final FileMngService fileMngService; |
63 | 61 |
|
64 | 62 |
@Value("${front.url}") |
... | ... | @@ -143,7 +141,7 @@ |
143 | 141 |
bbsCn.setBbsId(bbsId); |
144 | 142 |
|
145 | 143 |
// 등록된 토큰에서 사용자 정보 조회 |
146 |
- String writer = jwtUtil.getWriter(); |
|
144 |
+ String writer = verificationService.getCurrentUserId(); |
|
147 | 145 |
if (writer == null || writer.isEmpty()) { |
148 | 146 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
149 | 147 |
} |
... | ... | @@ -365,7 +363,7 @@ |
365 | 363 |
// } |
366 | 364 |
|
367 | 365 |
// 등록된 토큰에서 사용자 정보 조회 |
368 |
- String writer = jwtUtil.getWriter(); |
|
366 |
+ String writer = verificationService.getCurrentUserId(); |
|
369 | 367 |
if (writer == null || writer.isEmpty()) { |
370 | 368 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
371 | 369 |
} |
... | ... | @@ -439,7 +437,7 @@ |
439 | 437 |
public int deleteBbsCn(BbsCnVO bbsCnVO) { |
440 | 438 |
try { |
441 | 439 |
// 등록된 토큰에서 사용자 정보 조회 |
442 |
- String writer = jwtUtil.getWriter(); |
|
440 |
+ String writer = verificationService.getCurrentUserId(); |
|
443 | 441 |
if (writer == null || writer.isEmpty()) { |
444 | 442 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
445 | 443 |
} |
... | ... | @@ -613,7 +611,7 @@ |
613 | 611 |
try { |
614 | 612 |
HashMap<String, Object> result = new HashMap<>(); |
615 | 613 |
// 등록된 토큰에서 사용자 정보 조회 |
616 |
- String writer = jwtUtil.getWriter(); |
|
614 |
+ String writer = verificationService.getCurrentUserId(); |
|
617 | 615 |
if (writer == null || writer.isEmpty()) { |
618 | 616 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
619 | 617 |
} |
... | ... | @@ -665,7 +663,7 @@ |
665 | 663 |
HashMap<String, Object> result = new HashMap<>(); |
666 | 664 |
|
667 | 665 |
// 등록된 토큰에서 사용자 정보 조회 |
668 |
- String writer = jwtUtil.getWriter(); |
|
666 |
+ String writer = verificationService.getCurrentUserId(); |
|
669 | 667 |
if (writer == null || writer.isEmpty()) { |
670 | 668 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
671 | 669 |
} |
... | ... | @@ -711,7 +709,7 @@ |
711 | 709 |
public int deleteAns(BbsCnVO bbsCnVO) { |
712 | 710 |
try { |
713 | 711 |
// 등록된 토큰에서 사용자 정보 조회 |
714 |
- String writer = jwtUtil.getWriter(); |
|
712 |
+ String writer = verificationService.getCurrentUserId(); |
|
715 | 713 |
if(writer == null || writer.isEmpty()){ |
716 | 714 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
717 | 715 |
} |
--- src/main/java/com/takensoft/cms/bbs/service/Impl/BbsMngServiceImpl.java
+++ src/main/java/com/takensoft/cms/bbs/service/Impl/BbsMngServiceImpl.java
... | ... | @@ -12,7 +12,7 @@ |
12 | 12 |
import com.takensoft.common.Pagination; |
13 | 13 |
import com.takensoft.common.exception.*; |
14 | 14 |
import com.takensoft.common.idgen.service.IdgenService; |
15 |
-import com.takensoft.common.util.JWTUtil; |
|
15 |
+import com.takensoft.common.service.VerificationService; |
|
16 | 16 |
import lombok.RequiredArgsConstructor; |
17 | 17 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
18 | 18 |
import org.springframework.cache.annotation.CacheEvict; |
... | ... | @@ -49,8 +49,7 @@ |
49 | 49 |
private final IdgenService bbsMngIdgn; |
50 | 50 |
private final IdgenService bbsRouterIdgn; |
51 | 51 |
private final MenuService menuService; |
52 |
- |
|
53 |
- private final JWTUtil jwtUtil; |
|
52 |
+ private final VerificationService verificationService; |
|
54 | 53 |
|
55 | 54 |
/** |
56 | 55 |
* @param bbsMngVO - 게시판 정보 |
... | ... | @@ -101,7 +100,7 @@ |
101 | 100 |
bbsMngVO.setBbsMngId(bbsMngId); |
102 | 101 |
|
103 | 102 |
// 등록된 토큰에서 사용자 정보 조회 |
104 |
- String writer = jwtUtil.getWriter(); |
|
103 |
+ String writer = verificationService.getCurrentUserId(); |
|
105 | 104 |
if (writer == null || writer.isEmpty()) { |
106 | 105 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
107 | 106 |
} |
... | ... | @@ -271,7 +270,7 @@ |
271 | 270 |
public int updateBbsMng(BbsMngVO bbsMngVO) { |
272 | 271 |
try { |
273 | 272 |
// 등록된 토큰에서 사용자 정보 조회 |
274 |
- String writer = jwtUtil.getWriter(); |
|
273 |
+ String writer = verificationService.getCurrentUserId(); |
|
275 | 274 |
if (writer == null || writer.isEmpty()) { |
276 | 275 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
277 | 276 |
} |
... | ... | @@ -350,7 +349,7 @@ |
350 | 349 |
public int deleteBbsMng(BbsMngVO bbsMngVO) { |
351 | 350 |
try { |
352 | 351 |
// 등록된 토큰에서 사용자 정보 조회 |
353 |
- String writer = jwtUtil.getWriter(); |
|
352 |
+ String writer = verificationService.getCurrentUserId(); |
|
354 | 353 |
if (writer == null || writer.isEmpty()) { |
355 | 354 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
356 | 355 |
} |
--- src/main/java/com/takensoft/cms/bbs/service/Impl/BbsTypeMngServiceImpl.java
+++ src/main/java/com/takensoft/cms/bbs/service/Impl/BbsTypeMngServiceImpl.java
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 |
import com.takensoft.cms.bbs.vo.BbsTypeMngVO; |
6 | 6 |
import com.takensoft.common.exception.*; |
7 | 7 |
import com.takensoft.common.idgen.service.IdgenService; |
8 |
-import com.takensoft.common.util.JWTUtil; |
|
8 |
+import com.takensoft.common.service.VerificationService; |
|
9 | 9 |
import lombok.RequiredArgsConstructor; |
10 | 10 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
11 | 11 |
import org.springframework.dao.DataAccessException; |
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 |
public class BbsTypeMngServiceImpl extends EgovAbstractServiceImpl implements BbsTypeMngService { |
36 | 36 |
private final BbsTypeMngDAO bbsTypeMngDAO; |
37 | 37 |
private final IdgenService bbsTypeIdgn; |
38 |
- private final JWTUtil jwtUtil; |
|
38 |
+ private final VerificationService verificationService; |
|
39 | 39 |
|
40 | 40 |
/** |
41 | 41 |
* @param bbsTypeMngVO - 게시판 유형 관리 정보 |
... | ... | @@ -59,7 +59,7 @@ |
59 | 59 |
bbsTypeMngVO.setBbsTypeId(bbsTypeMngId); |
60 | 60 |
|
61 | 61 |
// 등록된 토큰에서 사용자 정보 조회 |
62 |
- String writer = jwtUtil.getWriter(); |
|
62 |
+ String writer = verificationService.getCurrentUserId(); |
|
63 | 63 |
if (writer == null || writer.isEmpty()) { |
64 | 64 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
65 | 65 |
} |
--- src/main/java/com/takensoft/cms/bbs/service/Impl/CmntServiceImpl.java
+++ src/main/java/com/takensoft/cms/bbs/service/Impl/CmntServiceImpl.java
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 |
import com.takensoft.cms.bbs.service.CmntService; |
6 | 6 |
import com.takensoft.cms.bbs.vo.CmntVO; |
7 | 7 |
import com.takensoft.common.exception.*; |
8 |
-import com.takensoft.common.util.JWTUtil; |
|
8 |
+import com.takensoft.common.service.VerificationService; |
|
9 | 9 |
import lombok.RequiredArgsConstructor; |
10 | 10 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
11 | 11 |
import org.springframework.dao.DataAccessException; |
... | ... | @@ -35,8 +35,8 @@ |
35 | 35 |
public class CmntServiceImpl extends EgovAbstractServiceImpl implements CmntService { |
36 | 36 |
|
37 | 37 |
private final CmntDAO cmntDAO; |
38 |
- private final JWTUtil jwtUtil; |
|
39 | 38 |
private final WordMngDAO wordMngDAO; |
39 |
+ private final VerificationService verificationService; |
|
40 | 40 |
|
41 | 41 |
/** |
42 | 42 |
* @param cmntVO - 게시판 댓글 정보 |
... | ... | @@ -66,7 +66,7 @@ |
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
// 등록된 토큰에서 사용자 정보 조회 |
69 |
- String writer = jwtUtil.getWriter(); |
|
69 |
+ String writer = verificationService.getCurrentUserId(); |
|
70 | 70 |
if (writer == null || writer.isEmpty()) { |
71 | 71 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
72 | 72 |
} |
... | ... | @@ -168,7 +168,7 @@ |
168 | 168 |
} |
169 | 169 |
|
170 | 170 |
// 등록된 토큰에서 사용자 정보 조회 |
171 |
- String writer = jwtUtil.getWriter(); |
|
171 |
+ String writer = verificationService.getCurrentUserId(); |
|
172 | 172 |
if (writer == null || writer.isEmpty()) { |
173 | 173 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
174 | 174 |
} |
... | ... | @@ -202,7 +202,7 @@ |
202 | 202 |
public int deleteCmnt(CmntVO cmntVO) { |
203 | 203 |
try { |
204 | 204 |
// 등록된 토큰에서 사용자 정보 조회 |
205 |
- String writer = jwtUtil.getWriter(); |
|
205 |
+ String writer = verificationService.getCurrentUserId(); |
|
206 | 206 |
if (writer == null || writer.isEmpty()) { |
207 | 207 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
208 | 208 |
} |
--- src/main/java/com/takensoft/cms/bbs/service/Impl/WordMngServiceImpl.java
+++ src/main/java/com/takensoft/cms/bbs/service/Impl/WordMngServiceImpl.java
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 |
import com.takensoft.cms.bbs.vo.WordMngVO; |
6 | 6 |
import com.takensoft.common.Pagination; |
7 | 7 |
import com.takensoft.common.exception.*; |
8 |
-import com.takensoft.common.util.JWTUtil; |
|
8 |
+import com.takensoft.common.service.VerificationService; |
|
9 | 9 |
import lombok.RequiredArgsConstructor; |
10 | 10 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
11 | 11 |
import org.springframework.dao.DataAccessException; |
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 |
public class WordMngServiceImpl extends EgovAbstractServiceImpl implements WordMngService { |
34 | 34 |
|
35 | 35 |
private final WordMngDAO wordMngDAO; |
36 |
- private final JWTUtil jwtUtil; |
|
36 |
+ private final VerificationService verificationService; |
|
37 | 37 |
|
38 | 38 |
/** |
39 | 39 |
* @param wordList - 금지어 목록 정보 |
... | ... | @@ -50,7 +50,7 @@ |
50 | 50 |
public int saveWords(HashMap<String, Object> wordList) { |
51 | 51 |
try { |
52 | 52 |
// 등록된 토큰에서 사용자 정보 조회 |
53 |
- String writer = jwtUtil.getWriter(); |
|
53 |
+ String writer = verificationService.getCurrentUserId(); |
|
54 | 54 |
if (writer == null || writer.isEmpty()) { |
55 | 55 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
56 | 56 |
} |
--- src/main/java/com/takensoft/cms/cntxtPth/service/Impl/CntxtPthServiceImpl.java
+++ src/main/java/com/takensoft/cms/cntxtPth/service/Impl/CntxtPthServiceImpl.java
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 |
import com.takensoft.cms.cntxtPth.vo.CntxtPthVO; |
6 | 6 |
import com.takensoft.common.exception.*; |
7 | 7 |
import com.takensoft.common.idgen.service.IdgenService; |
8 |
-import com.takensoft.common.util.JWTUtil; |
|
8 |
+import com.takensoft.common.service.VerificationService; |
|
9 | 9 |
import lombok.RequiredArgsConstructor; |
10 | 10 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
11 | 11 |
import org.springframework.cache.annotation.CacheEvict; |
... | ... | @@ -31,8 +31,8 @@ |
31 | 31 |
@RequiredArgsConstructor |
32 | 32 |
public class CntxtPthServiceImpl extends EgovAbstractServiceImpl implements CntxtPthService { |
33 | 33 |
private final CntxtPthDAO cntxtPthDAO; |
34 |
- private final JWTUtil jwtUtil; |
|
35 | 34 |
private final IdgenService cntxtPthIdgn; |
35 |
+ private final VerificationService verificationService; |
|
36 | 36 |
|
37 | 37 |
/** |
38 | 38 |
* @return String - 컨텍스트 패스 경로 |
... | ... | @@ -74,7 +74,7 @@ |
74 | 74 |
public int cntxtPthSave(CntxtPthVO cntxtPthVO) { |
75 | 75 |
try { |
76 | 76 |
// 등록된 토큰에서 사용자 정보 조회 |
77 |
- String writer = jwtUtil.getWriter(); |
|
77 |
+ String writer = verificationService.getCurrentUserId(); |
|
78 | 78 |
if (writer == null || writer.isEmpty()) { |
79 | 79 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
80 | 80 |
} |
--- src/main/java/com/takensoft/cms/codeManage/service/Impl/CodeManageServiceImpl.java
+++ src/main/java/com/takensoft/cms/codeManage/service/Impl/CodeManageServiceImpl.java
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 |
import com.takensoft.cms.codeManage.service.CodeManageService; |
5 | 5 |
import com.takensoft.cms.codeManage.vo.CodeManageVO; |
6 | 6 |
import com.takensoft.common.exception.*; |
7 |
-import com.takensoft.common.util.JWTUtil; |
|
7 |
+import com.takensoft.common.service.VerificationService; |
|
8 | 8 |
import com.takensoft.common.HierachyVO; |
9 | 9 |
import lombok.RequiredArgsConstructor; |
10 | 10 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
... | ... | @@ -42,8 +42,8 @@ |
42 | 42 |
public class CodeManageServiceImpl extends EgovAbstractServiceImpl implements CodeManageService { |
43 | 43 |
|
44 | 44 |
private static final Logger LOGGER = LoggerFactory.getLogger(CodeManageServiceImpl.class); |
45 |
- private final JWTUtil jwtUtil; |
|
46 | 45 |
private final CodeManageDAO codeManageDAO; |
46 |
+ private final VerificationService verificationService; |
|
47 | 47 |
|
48 | 48 |
/** |
49 | 49 |
* @param codeManageVO - 공통코드 정보 |
... | ... | @@ -96,7 +96,7 @@ |
96 | 96 |
} |
97 | 97 |
|
98 | 98 |
// 등록된 토큰에서 사용자 정보 조회 |
99 |
- String writer = jwtUtil.getWriter(); |
|
99 |
+ String writer = verificationService.getCurrentUserId(); |
|
100 | 100 |
if (writer == null || writer.isEmpty()) { |
101 | 101 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
102 | 102 |
} |
... | ... | @@ -132,7 +132,7 @@ |
132 | 132 |
public int cdUpdate(CodeManageVO codeManageVO){ |
133 | 133 |
try { |
134 | 134 |
// 등록된 토큰에서 사용자 정보 조회 |
135 |
- String writer = jwtUtil.getWriter(); |
|
135 |
+ String writer = verificationService.getCurrentUserId(); |
|
136 | 136 |
if (writer == null || writer.isEmpty()) { |
137 | 137 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
138 | 138 |
} |
... | ... | @@ -370,7 +370,7 @@ |
370 | 370 |
public int updateList(List<HierachyVO> deptList) { |
371 | 371 |
int result = 0; |
372 | 372 |
// 등록된 토큰에서 사용자 정보 조회 |
373 |
- String writer = jwtUtil.getWriter(); |
|
373 |
+ String writer = verificationService.getCurrentUserId(); |
|
374 | 374 |
if (writer == null || writer.isEmpty()) { |
375 | 375 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
376 | 376 |
} |
--- src/main/java/com/takensoft/cms/contsType/service/Impl/ContsTypeServiceImpl.java
+++ src/main/java/com/takensoft/cms/contsType/service/Impl/ContsTypeServiceImpl.java
... | ... | @@ -12,7 +12,7 @@ |
12 | 12 |
import com.takensoft.common.Pagination; |
13 | 13 |
import com.takensoft.common.exception.*; |
14 | 14 |
import com.takensoft.common.idgen.service.IdgenService; |
15 |
-import com.takensoft.common.util.JWTUtil; |
|
15 |
+import com.takensoft.common.service.VerificationService; |
|
16 | 16 |
import lombok.RequiredArgsConstructor; |
17 | 17 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
18 | 18 |
import org.springframework.cache.annotation.CacheEvict; |
... | ... | @@ -49,9 +49,9 @@ |
49 | 49 |
private final ContsTypeDAO contsTypeDAO; |
50 | 50 |
private final BbsRouterDAO bbsRouterDAO; |
51 | 51 |
private final IdgenService contsTypeIdgn; |
52 |
- private final JWTUtil jwtUtil; |
|
53 | 52 |
private final MenuService menuService; // 메뉴 인터페이스 |
54 | 53 |
private final MenuDAO menuDAO; |
54 |
+ private final VerificationService verificationService; |
|
55 | 55 |
|
56 | 56 |
/** |
57 | 57 |
* @param contsEngNm - 콘텐츠 영문명 |
... | ... | @@ -124,7 +124,7 @@ |
124 | 124 |
contsTypeVO.setContsId(contsId); |
125 | 125 |
|
126 | 126 |
// 등록된 토큰에서 사용자 정보 조회 |
127 |
- String writer = jwtUtil.getWriter(); |
|
127 |
+ String writer = verificationService.getCurrentUserId(); |
|
128 | 128 |
if (writer == null || writer.isEmpty()) { |
129 | 129 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
130 | 130 |
} |
... | ... | @@ -182,7 +182,7 @@ |
182 | 182 |
// 콘텐츠 유형 수정 결과 |
183 | 183 |
int result = 0; |
184 | 184 |
// 등록된 토큰에서 사용자 정보 조회 |
185 |
- String writer = jwtUtil.getWriter(); |
|
185 |
+ String writer = verificationService.getCurrentUserId(); |
|
186 | 186 |
if (writer == null || writer.isEmpty()) { |
187 | 187 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
188 | 188 |
} |
--- src/main/java/com/takensoft/cms/dept/service/Impl/DeptServiceImpl.java
+++ src/main/java/com/takensoft/cms/dept/service/Impl/DeptServiceImpl.java
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 |
import com.takensoft.common.exception.CustomNotFoundException; |
12 | 12 |
import com.takensoft.common.exception.CustomUpdateFailException; |
13 | 13 |
import com.takensoft.common.idgen.service.IdgenService; |
14 |
-import com.takensoft.common.util.JWTUtil; |
|
14 |
+import com.takensoft.common.service.VerificationService; |
|
15 | 15 |
import com.takensoft.common.util.Secret; |
16 | 16 |
import lombok.RequiredArgsConstructor; |
17 | 17 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
... | ... | @@ -44,9 +44,9 @@ |
44 | 44 |
public class DeptServiceImpl extends EgovAbstractServiceImpl implements DeptService { |
45 | 45 |
|
46 | 46 |
private static final Logger LOGGER = LoggerFactory.getLogger(DeptServiceImpl.class); |
47 |
- private final JWTUtil jwtUtil; |
|
48 | 47 |
private final DeptDAO deptDAO; |
49 | 48 |
private final IdgenService deptIdgn; |
49 |
+ private final VerificationService verificationService; |
|
50 | 50 |
|
51 | 51 |
/** |
52 | 52 |
* @param deptVO - 부서 정보 VO |
... | ... | @@ -80,7 +80,7 @@ |
80 | 80 |
} |
81 | 81 |
|
82 | 82 |
// 등록된 토큰에서 사용자 정보 조회 |
83 |
- String writer = jwtUtil.getWriter(); |
|
83 |
+ String writer = verificationService.getCurrentUserId(); |
|
84 | 84 |
if (writer == null || writer.isEmpty()) { |
85 | 85 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
86 | 86 |
} |
... | ... | @@ -132,7 +132,7 @@ |
132 | 132 |
int result = 0; |
133 | 133 |
|
134 | 134 |
// 등록된 토큰에서 사용자 정보 조회 |
135 |
- String writer = jwtUtil.getWriter(); |
|
135 |
+ String writer = verificationService.getCurrentUserId(); |
|
136 | 136 |
if (writer == null || writer.isEmpty()) { |
137 | 137 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
138 | 138 |
} |
... | ... | @@ -256,7 +256,7 @@ |
256 | 256 |
// 부서 정보 수정 결과 |
257 | 257 |
int result = 0; |
258 | 258 |
// 등록된 토큰에서 사용자 정보 조회 |
259 |
- String writer = jwtUtil.getWriter(); |
|
259 |
+ String writer = verificationService.getCurrentUserId(); |
|
260 | 260 |
if (writer == null || writer.isEmpty()) { |
261 | 261 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
262 | 262 |
} |
... | ... | @@ -423,7 +423,7 @@ |
423 | 423 |
try { |
424 | 424 |
int result = 0; |
425 | 425 |
// 등록된 토큰에서 사용자 정보 조회 |
426 |
- String writer = jwtUtil.getWriter(); |
|
426 |
+ String writer = verificationService.getCurrentUserId(); |
|
427 | 427 |
if (writer == null || writer.isEmpty()) { |
428 | 428 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
429 | 429 |
} |
--- src/main/java/com/takensoft/cms/mber/service/Impl/AdmMbrServiceImpl.java
+++ src/main/java/com/takensoft/cms/mber/service/Impl/AdmMbrServiceImpl.java
... | ... | @@ -13,8 +13,8 @@ |
13 | 13 |
import com.takensoft.common.Pagination; |
14 | 14 |
import com.takensoft.common.exception.*; |
15 | 15 |
import com.takensoft.common.idgen.service.IdgenService; |
16 |
+import com.takensoft.common.service.VerificationService; |
|
16 | 17 |
import com.takensoft.common.util.HttpRequestUtil; |
17 |
-import com.takensoft.common.util.JWTUtil; |
|
18 | 18 |
import com.takensoft.common.util.Secret; |
19 | 19 |
import lombok.RequiredArgsConstructor; |
20 | 20 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
... | ... | @@ -41,13 +41,13 @@ |
41 | 41 |
@Service("admMbrService") |
42 | 42 |
@RequiredArgsConstructor |
43 | 43 |
public class AdmMbrServiceImpl extends EgovAbstractServiceImpl implements AdmMbrService { |
44 |
- private final JWTUtil jwtUtil; |
|
45 | 44 |
private final IdgenService mberIdgn; |
46 | 45 |
private final HttpRequestUtil httpRequestUtil; |
47 | 46 |
private final BCryptPasswordEncoder bCryptPasswordEncoder; |
48 | 47 |
private final AdmMbrDAO admMbrDAO; |
49 | 48 |
private final MberService mbrService; |
50 | 49 |
private final DeptService deptService; |
50 |
+ private final VerificationService verificationService; |
|
51 | 51 |
|
52 | 52 |
/** |
53 | 53 |
* @param params - 회원정보 |
... | ... | @@ -162,7 +162,7 @@ |
162 | 162 |
} |
163 | 163 |
|
164 | 164 |
// 등록된 토큰에서 사용자 정보 조회 |
165 |
- String writer = jwtUtil.getWriter(); |
|
165 |
+ String writer = verificationService.getCurrentUserId(); |
|
166 | 166 |
if (writer == null || writer.isEmpty()) { |
167 | 167 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
168 | 168 |
} |
... | ... | @@ -244,7 +244,7 @@ |
244 | 244 |
joinDTO.setFrstRegIp(ip); |
245 | 245 |
|
246 | 246 |
// 등록된 토큰에서 사용자 정보 조회 |
247 |
- String writer = jwtUtil.getWriter(); |
|
247 |
+ String writer = verificationService.getCurrentUserId(); |
|
248 | 248 |
if (writer == null || writer.isEmpty()) { |
249 | 249 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
250 | 250 |
} |
--- src/main/java/com/takensoft/cms/mber/service/Impl/MberServiceImpl.java
+++ src/main/java/com/takensoft/cms/mber/service/Impl/MberServiceImpl.java
... | ... | @@ -8,8 +8,8 @@ |
8 | 8 |
import com.takensoft.cms.mber.vo.MberVO; |
9 | 9 |
import com.takensoft.common.exception.*; |
10 | 10 |
import com.takensoft.common.idgen.service.IdgenService; |
11 |
+import com.takensoft.common.service.VerificationService; |
|
11 | 12 |
import com.takensoft.common.util.HttpRequestUtil; |
12 |
-import com.takensoft.common.util.JWTUtil; |
|
13 | 13 |
import com.takensoft.common.util.Secret; |
14 | 14 |
import lombok.RequiredArgsConstructor; |
15 | 15 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
... | ... | @@ -42,8 +42,8 @@ |
42 | 42 |
private final MberDAO mberDAO; |
43 | 43 |
private final IdgenService mberIdgn; |
44 | 44 |
private final BCryptPasswordEncoder bCryptPasswordEncoder; |
45 |
- private final JWTUtil jwtUtil; |
|
46 | 45 |
private final HttpRequestUtil httpRequestUtil; |
46 |
+ private final VerificationService verificationService; |
|
47 | 47 |
|
48 | 48 |
/** |
49 | 49 |
* @param username -회원이름 |
... | ... | @@ -129,7 +129,7 @@ |
129 | 129 |
joinDTO.setFrstRegIp(httpRequestUtil.getIp(req)); |
130 | 130 |
|
131 | 131 |
// 등록된 토큰에서 사용자 정보 조회 |
132 |
- String writer = jwtUtil.getWriter(); |
|
132 |
+ String writer = verificationService.getCurrentUserId(); |
|
133 | 133 |
if (writer == null || writer.isEmpty()) { |
134 | 134 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
135 | 135 |
} |
... | ... | @@ -182,7 +182,7 @@ |
182 | 182 |
public boolean passwordCheck(PasswordDTO passwordDTO) { |
183 | 183 |
try { |
184 | 184 |
// 등록된 토큰에서 사용자 정보 조회 |
185 |
- String writer = jwtUtil.getWriter(); |
|
185 |
+ String writer = verificationService.getCurrentUserId(); |
|
186 | 186 |
if (writer == null || writer.isEmpty()) { |
187 | 187 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
188 | 188 |
} |
--- src/main/java/com/takensoft/cms/popup/service/Impl/PopupServiceImpl.java
+++ src/main/java/com/takensoft/cms/popup/service/Impl/PopupServiceImpl.java
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 |
import com.takensoft.common.file.service.FileMngService; |
11 | 11 |
import com.takensoft.common.file.vo.FileMngVO; |
12 | 12 |
import com.takensoft.common.idgen.service.IdgenService; |
13 |
-import com.takensoft.common.util.JWTUtil; |
|
13 |
+import com.takensoft.common.service.VerificationService; |
|
14 | 14 |
import lombok.RequiredArgsConstructor; |
15 | 15 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
16 | 16 |
import org.springframework.dao.DataAccessException; |
... | ... | @@ -36,12 +36,11 @@ |
36 | 36 |
@Service("popupService") |
37 | 37 |
@RequiredArgsConstructor |
38 | 38 |
public class PopupServiceImpl extends EgovAbstractServiceImpl implements PopupService { |
39 |
- |
|
40 |
- private final JWTUtil jwtUtil; |
|
41 | 39 |
private final PopupDAO popupDAO; |
42 | 40 |
private final IdgenService popupIdgn; |
43 | 41 |
private final FileMngService fileMngService; |
44 | 42 |
private final CodeManageService codeManageService; |
43 |
+ private final VerificationService verificationService; |
|
45 | 44 |
|
46 | 45 |
/** |
47 | 46 |
* @param popupVO - 팝업 등록 정보를 포함하는 객체 |
... | ... | @@ -64,7 +63,7 @@ |
64 | 63 |
popupVO.setPopupId(popupId); |
65 | 64 |
|
66 | 65 |
// 등록된 토큰에서 사용자 정보 조회 |
67 |
- String writer = jwtUtil.getWriter(); |
|
66 |
+ String writer = verificationService.getCurrentUserId(); |
|
68 | 67 |
if (writer == null || writer.isEmpty()) { |
69 | 68 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
70 | 69 |
} |
... | ... | @@ -220,7 +219,7 @@ |
220 | 219 |
public int popupUpdate(PopupVO popupVO, List<MultipartFile> multipartFileList){ |
221 | 220 |
try { |
222 | 221 |
// 등록된 토큰에서 사용자 정보 조회 |
223 |
- String writer = jwtUtil.getWriter(); |
|
222 |
+ String writer = verificationService.getCurrentUserId(); |
|
224 | 223 |
if (writer == null || writer.isEmpty()) { |
225 | 224 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
226 | 225 |
} |
... | ... | @@ -279,7 +278,7 @@ |
279 | 278 |
public int popupDelete(PopupVO popupVO){ |
280 | 279 |
try { |
281 | 280 |
// 등록된 토큰에서 사용자 정보 조회 |
282 |
- String writer = jwtUtil.getWriter(); |
|
281 |
+ String writer = verificationService.getCurrentUserId(); |
|
283 | 282 |
if (writer == null || writer.isEmpty()) { |
284 | 283 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
285 | 284 |
} |
--- src/main/java/com/takensoft/cms/prvcInqHstry/service/Impl/PrvcInqHstryServiceImpl.java
+++ src/main/java/com/takensoft/cms/prvcInqHstry/service/Impl/PrvcInqHstryServiceImpl.java
... | ... | @@ -7,8 +7,8 @@ |
7 | 7 |
import com.takensoft.cms.prvcInqHstry.vo.PrvcInqHstryVO; |
8 | 8 |
import com.takensoft.common.Pagination; |
9 | 9 |
import com.takensoft.common.exception.*; |
10 |
+import com.takensoft.common.service.VerificationService; |
|
10 | 11 |
import com.takensoft.common.util.HttpRequestUtil; |
11 |
-import com.takensoft.common.util.JWTUtil; |
|
12 | 12 |
import lombok.RequiredArgsConstructor; |
13 | 13 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
14 | 14 |
import org.springframework.dao.DataAccessException; |
... | ... | @@ -37,10 +37,11 @@ |
37 | 37 |
@RequiredArgsConstructor |
38 | 38 |
public class PrvcInqHstryServiceImpl extends EgovAbstractServiceImpl implements PrvcInqHstryService { |
39 | 39 |
|
40 |
- private final JWTUtil jwtUtil; |
|
41 | 40 |
private final HttpRequestUtil httpRequestUtil; |
42 | 41 |
private final PrvcInqHstryDAO prvcInqHstryDAO; |
43 | 42 |
private final CodeManageService codeManageService; |
43 |
+ private final VerificationService verificationService; |
|
44 |
+ |
|
44 | 45 |
|
45 | 46 |
/** |
46 | 47 |
* @param request - HttpServletRequest 객체 |
... | ... | @@ -62,7 +63,7 @@ |
62 | 63 |
prvcInqHstryVO.setInqIp(ipAdd); |
63 | 64 |
|
64 | 65 |
// 등록된 토큰에서 사용자 정보 조회 |
65 |
- String writer = jwtUtil.getWriter(); |
|
66 |
+ String writer = verificationService.getCurrentUserId(); |
|
66 | 67 |
if (writer == null || writer.isEmpty()) { |
67 | 68 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
68 | 69 |
} |
--- src/main/java/com/takensoft/common/config/RedisConfig.java
+++ src/main/java/com/takensoft/common/config/RedisConfig.java
... | ... | @@ -1,12 +1,18 @@ |
1 | 1 |
package com.takensoft.common.config; |
2 | 2 |
|
3 |
+import io.lettuce.core.ClientOptions; |
|
4 |
+import lombok.extern.slf4j.Slf4j; |
|
3 | 5 |
import org.springframework.beans.factory.annotation.Value; |
4 | 6 |
import org.springframework.context.annotation.Bean; |
5 | 7 |
import org.springframework.context.annotation.Configuration; |
6 | 8 |
import org.springframework.data.redis.connection.RedisConnectionFactory; |
9 |
+import org.springframework.data.redis.connection.RedisStandaloneConfiguration; |
|
10 |
+import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration; |
|
7 | 11 |
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; |
8 | 12 |
import org.springframework.data.redis.core.RedisTemplate; |
9 | 13 |
import org.springframework.data.redis.serializer.StringRedisSerializer; |
14 |
+ |
|
15 |
+import java.time.Duration; |
|
10 | 16 |
|
11 | 17 |
/** |
12 | 18 |
* @author takensoft |
... | ... | @@ -17,7 +23,7 @@ |
17 | 23 |
* |
18 | 24 |
* redis 설정을 위한 Config |
19 | 25 |
*/ |
20 |
- |
|
26 |
+@Slf4j |
|
21 | 27 |
@Configuration |
22 | 28 |
public class RedisConfig { |
23 | 29 |
|
... | ... | @@ -25,18 +31,56 @@ |
25 | 31 |
private String redisHost; |
26 | 32 |
@Value("${redis.port}") |
27 | 33 |
private int redisPort; |
34 |
+ @Value("${redis.timeout}") |
|
35 |
+ private int timeout; |
|
36 |
+ @Value("${redis.password}") |
|
37 |
+ private String redisPassword; |
|
38 |
+ |
|
28 | 39 |
|
29 | 40 |
@Bean |
30 | 41 |
public RedisConnectionFactory redisConnectionFactory() { |
31 |
- return new LettuceConnectionFactory(redisHost, redisPort); |
|
42 |
+ RedisStandaloneConfiguration redisConfig = new RedisStandaloneConfiguration(); |
|
43 |
+ redisConfig.setHostName(redisHost); |
|
44 |
+ redisConfig.setPort(redisPort); |
|
45 |
+ |
|
46 |
+ // 비밀번호가 설정되어 있으면 적용 |
|
47 |
+ if (!redisPassword.isEmpty()) { |
|
48 |
+ redisConfig.setPassword(redisPassword); |
|
49 |
+ } |
|
50 |
+ |
|
51 |
+ // Lettuce 클라이언트 설정 |
|
52 |
+ LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder() |
|
53 |
+ .commandTimeout(Duration.ofMillis(timeout)) |
|
54 |
+ .clientOptions(ClientOptions.builder() |
|
55 |
+ .disconnectedBehavior(ClientOptions.DisconnectedBehavior.REJECT_COMMANDS) |
|
56 |
+ .autoReconnect(true) |
|
57 |
+ .build()) |
|
58 |
+ .build(); |
|
59 |
+ |
|
60 |
+ return new LettuceConnectionFactory(redisConfig, clientConfig); |
|
32 | 61 |
} |
33 | 62 |
@Bean |
34 | 63 |
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory redisConnectionFactory) { |
35 |
- RedisTemplate<String, String> redisTemp = new RedisTemplate<>(); |
|
36 |
- redisTemp.setConnectionFactory(redisConnectionFactory); |
|
37 |
- redisTemp.setKeySerializer(new StringRedisSerializer()); |
|
38 |
- redisTemp.setValueSerializer(new StringRedisSerializer()); |
|
39 |
- return redisTemp; |
|
64 |
+ RedisTemplate<String, String> redisTemplate = new RedisTemplate<>(); |
|
65 |
+ redisTemplate.setConnectionFactory(redisConnectionFactory); |
|
66 |
+ redisTemplate.setKeySerializer(new StringRedisSerializer()); |
|
67 |
+ redisTemplate.setValueSerializer(new StringRedisSerializer()); |
|
68 |
+ redisTemplate.setHashKeySerializer(new StringRedisSerializer()); |
|
69 |
+ redisTemplate.setHashValueSerializer(new StringRedisSerializer()); |
|
70 |
+ redisTemplate.afterPropertiesSet(); |
|
71 |
+ |
|
72 |
+ return redisTemplate; |
|
40 | 73 |
} |
41 | 74 |
|
75 |
+ @Bean |
|
76 |
+ public boolean checkRedisConnection(RedisConnectionFactory redisConnectionFactory) { |
|
77 |
+ try { |
|
78 |
+ redisConnectionFactory.getConnection().ping(); |
|
79 |
+ log.info("Redis 연결 성공: {}:{}", redisHost, redisPort); |
|
80 |
+ return true; |
|
81 |
+ } catch (Exception e) { |
|
82 |
+ log.error("Redis 연결 실패: {}", e.getMessage()); |
|
83 |
+ return false; |
|
84 |
+ } |
|
85 |
+ } |
|
42 | 86 |
} |
--- src/main/java/com/takensoft/common/file/service/Impl/FileMngServiceImpl.java
+++ src/main/java/com/takensoft/common/file/service/Impl/FileMngServiceImpl.java
... | ... | @@ -6,9 +6,8 @@ |
6 | 6 |
import com.takensoft.common.file.service.FileService; |
7 | 7 |
import com.takensoft.common.file.vo.FileMngVO; |
8 | 8 |
import com.takensoft.common.idgen.service.IdgenService; |
9 |
-import com.takensoft.common.util.JWTUtil; |
|
9 |
+import com.takensoft.common.service.VerificationService; |
|
10 | 10 |
import lombok.RequiredArgsConstructor; |
11 |
-import org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException; |
|
12 | 11 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
13 | 12 |
import org.springframework.dao.DataAccessException; |
14 | 13 |
import org.springframework.stereotype.Service; |
... | ... | @@ -37,7 +36,7 @@ |
37 | 36 |
private final FileMngDAO fileMngDAO; |
38 | 37 |
private final IdgenService fileMngIdgn; |
39 | 38 |
private final FileService fileService; |
40 |
- private final JWTUtil jwtUtil; |
|
39 |
+ private final VerificationService verificationService; |
|
41 | 40 |
|
42 | 41 |
/** |
43 | 42 |
* @param fileMngVO - 파일매니저 정보 |
... | ... | @@ -65,7 +64,7 @@ |
65 | 64 |
fileMngVO.setFileMngId(fileMngId); |
66 | 65 |
|
67 | 66 |
// 작성자 생성 |
68 |
- String writer = jwtUtil.getWriter(); |
|
67 |
+ String writer = verificationService.getCurrentUserId(); |
|
69 | 68 |
if (writer == null || writer.isEmpty()) { |
70 | 69 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
71 | 70 |
} |
... | ... | @@ -113,7 +112,7 @@ |
113 | 112 |
int result = 0; |
114 | 113 |
|
115 | 114 |
// 수정자 생성 |
116 |
- String writer = jwtUtil.getWriter(); |
|
115 |
+ String writer = verificationService.getCurrentUserId(); |
|
117 | 116 |
if (writer == null || writer.isEmpty()) { |
118 | 117 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
119 | 118 |
} |
--- src/main/java/com/takensoft/common/file/service/Impl/FileServiceImpl.java
+++ src/main/java/com/takensoft/common/file/service/Impl/FileServiceImpl.java
... | ... | @@ -4,8 +4,8 @@ |
4 | 4 |
import com.takensoft.common.file.dao.FileDAO; |
5 | 5 |
import com.takensoft.common.file.service.FileService; |
6 | 6 |
import com.takensoft.common.file.vo.FileVO; |
7 |
+import com.takensoft.common.service.VerificationService; |
|
7 | 8 |
import com.takensoft.common.util.FileUtil; |
8 |
-import com.takensoft.common.util.JWTUtil; |
|
9 | 9 |
import lombok.RequiredArgsConstructor; |
10 | 10 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
11 | 11 |
import org.springframework.beans.factory.annotation.Value; |
... | ... | @@ -42,7 +42,7 @@ |
42 | 42 |
public class FileServiceImpl extends EgovAbstractServiceImpl implements FileService { |
43 | 43 |
|
44 | 44 |
private final FileDAO fileDAO; |
45 |
- private final JWTUtil jwtUtil; |
|
45 |
+ private final VerificationService verificationService; |
|
46 | 46 |
|
47 | 47 |
@Value("${front.url}") |
48 | 48 |
private String frontUrl; |
... | ... | @@ -127,7 +127,7 @@ |
127 | 127 |
fileVO.setExtnNm(extsn); // 확장자 |
128 | 128 |
fileVO.setFileSz(mg); // 크기 |
129 | 129 |
// 등록자 생성 |
130 |
- String writer = jwtUtil.getWriter(); |
|
130 |
+ String writer = verificationService.getCurrentUserId(); |
|
131 | 131 |
if(writer == null || writer.isEmpty()){ |
132 | 132 |
throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
133 | 133 |
} |
--- src/main/java/com/takensoft/common/filter/LoginFilter.java
+++ src/main/java/com/takensoft/common/filter/LoginFilter.java
... | ... | @@ -72,7 +72,7 @@ |
72 | 72 |
* LoginFilter 생성자 |
73 | 73 |
*/ |
74 | 74 |
public LoginFilter(AuthenticationManager authenticationManager, JWTUtil jwtUtil, RefreshTokenService refreshTokenService, LgnHstryService lgnHstryService, HttpRequestUtil httpRequestUtil, |
75 |
- LoginModeService loginModeService,LoginPolicyService loginPolicyService,SessionUtil sessionUtil, @Value("${jwt.accessTime}")long aTime, @Value("${jwt.refreshTime}")long rTime, @Value("${cookie.time}")int ctime, RedisTemplate<String, String> redisTemplate) { |
|
75 |
+ LoginModeService loginModeService,LoginPolicyService loginPolicyService,SessionUtil sessionUtil, @Value("${jwt.accessTime}")long aTime, @Value("${jwt.refreshTime}")long rTime, @Value("${cookie.time}")int ctime, RedisTemplate<String, String> redisTemplate) { |
|
76 | 76 |
this.authenticationManager = authenticationManager; |
77 | 77 |
this.jwtUtil = jwtUtil; |
78 | 78 |
this.refreshTokenService = refreshTokenService; |
+++ src/main/java/com/takensoft/common/service/VerificationService.java
... | ... | @@ -0,0 +1,90 @@ |
1 | +package com.takensoft.common.service; | |
2 | + | |
3 | +import com.takensoft.cms.mber.vo.MberVO; | |
4 | +import com.takensoft.common.exception.CustomAccessDeniedException; | |
5 | +import lombok.RequiredArgsConstructor; | |
6 | +import org.springframework.security.core.Authentication; | |
7 | +import org.springframework.security.core.context.SecurityContextHolder; | |
8 | +import org.springframework.stereotype.Service; | |
9 | + | |
10 | +/** | |
11 | + * @author takensoft | |
12 | + * @since 2025.01.22 | |
13 | + * @modification | |
14 | + * since | author | description | |
15 | + * 2025.01.22 | takensoft | 최초 등록 | |
16 | + * | |
17 | + * 사용자 검증 서비스 | |
18 | + */ | |
19 | +@Service("authorizationService") | |
20 | +@RequiredArgsConstructor | |
21 | +public class VerificationService { | |
22 | + | |
23 | + /** | |
24 | + * @return 현재 인증된 사용자 정보 | |
25 | + * @throws CustomAccessDeniedException 인증되지 않은 경우 예외 발생 | |
26 | + * | |
27 | + * 현재 로그인된 사용자를 가져오는 공통 메서드 | |
28 | + */ | |
29 | + private MberVO getAuthenticatedUser() { | |
30 | + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | |
31 | + if(authentication == null || !authentication.isAuthenticated()) { | |
32 | + throw new CustomAccessDeniedException("접근 권한이 없습니다."); | |
33 | + } | |
34 | + | |
35 | + Object principal = authentication.getPrincipal(); | |
36 | + if(!(principal instanceof MberVO)) { | |
37 | + throw new CustomAccessDeniedException("접근 권한이 없습니다."); | |
38 | + } | |
39 | + return (MberVO) principal; | |
40 | + } | |
41 | + | |
42 | + /** | |
43 | + * @param targetUserId 접근하려는 사용자 ID | |
44 | + * @throws CustomAccessDeniedException - 접근 권한이 없을 경우 예외 발생 | |
45 | + * | |
46 | + * 특정 사용자 ID에 대한 접근 권한 검증 | |
47 | + */ | |
48 | + public void verifyAccess(String targetUserId) { | |
49 | + MberVO user = getAuthenticatedUser(); | |
50 | + // 관리자 권한 여부 | |
51 | + boolean isAdmin = user.getAuthorList().stream() | |
52 | + .anyMatch(auth -> "ROLE_ADMIN".equals(auth.getAuthrtCd())); | |
53 | + // 본인 여부 | |
54 | + boolean isOwner = user.getMbrId().equals(targetUserId); | |
55 | + | |
56 | + if(!isAdmin && !isOwner) { | |
57 | + throw new CustomAccessDeniedException("접근 권한이 없습니다."); | |
58 | + } | |
59 | + } | |
60 | + | |
61 | + /** | |
62 | + * @return 관리자 여부(true, false) | |
63 | + * | |
64 | + * 관리자 여부 검증 | |
65 | + */ | |
66 | + public boolean verifyAdmin() { | |
67 | + MberVO user = getAuthenticatedUser(); | |
68 | + // 관리자 권한 여부 반환 | |
69 | + return user.getAuthorList().stream() | |
70 | + .anyMatch(auth -> "ROLE_ADMIN".equals(auth.getAuthrtCd())); | |
71 | + } | |
72 | + | |
73 | + /** | |
74 | + * @return 현재 로그인된 사용자 ID | |
75 | + * | |
76 | + * 로그인된 사용자 아이디 반환 | |
77 | + * - 등록자, 수정자 입력 시 사용 | |
78 | + */ | |
79 | + public String getCurrentUserId() { | |
80 | + String userId = null; | |
81 | + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | |
82 | + if(authentication != null && authentication.isAuthenticated()) { | |
83 | + Object principal = authentication.getPrincipal(); | |
84 | + if(principal instanceof MberVO) { | |
85 | + userId = ((MberVO) authentication.getPrincipal()).getMbrId(); | |
86 | + } | |
87 | + } | |
88 | + return userId; | |
89 | + } | |
90 | +} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?