
250402 하석형 ContextPath 이력 관리 및 최신 컨텍스트 패스 조회 형식으로 변경, Context Path 필터 추가
@61d379b5708d3e529decaa869e0b34d5ec970338
--- src/main/java/com/takensoft/cms/cntxtPth/dao/CntxtPthDAO.java
+++ src/main/java/com/takensoft/cms/cntxtPth/dao/CntxtPthDAO.java
... | ... | @@ -12,6 +12,7 @@ |
12 | 12 |
* @modification |
13 | 13 |
* since | author | description |
14 | 14 |
* 2025.03.31 | 하석형 | 최초 등록 |
15 |
+ * 2025.04.02 | 하석형 | 이력 관리 및 최신 컨텍스트 패스 조회 형식으로 변경 |
|
15 | 16 |
* |
16 | 17 |
* 컨텍스트 패스 정보 관련 DAO |
17 | 18 |
*/ |
... | ... | @@ -19,28 +20,11 @@ |
19 | 20 |
public interface CntxtPthDAO { |
20 | 21 |
|
21 | 22 |
/** |
22 |
- * @param pagination - 페이징 정보 |
|
23 |
- * @return List<CntxtPthVO> - 컨텍스트 패스 정보를 담고 있는 객체 목록 |
|
23 |
+ * @return String - 컨텍스트 패스 경로 |
|
24 | 24 |
* |
25 |
- * 컨텍스트 패스 목록 조회 |
|
25 |
+ * 최신 컨텍스트 패스 조회 |
|
26 | 26 |
*/ |
27 |
- List<CntxtPthVO> findAll(Pagination pagination); |
|
28 |
- |
|
29 |
- /** |
|
30 |
- * @param pagination - 페이징 정보 |
|
31 |
- * @return int - 컨텍스트 패스 목록 갯수 |
|
32 |
- * |
|
33 |
- * 컨텍스트 패스 목록 갯수 |
|
34 |
- */ |
|
35 |
- int findAllCnt(Pagination pagination); |
|
36 |
- |
|
37 |
- /** |
|
38 |
- * @param cntxtPthId - 컨텍스트 패스 아이디 |
|
39 |
- * @return CntxtPthVO - 컨텍스트 패스 정보를 담고 있는 객체 |
|
40 |
- * |
|
41 |
- * 컨텍스트 패스 상세 조회 |
|
42 |
- */ |
|
43 |
- CntxtPthVO findByCntxtPthId(String cntxtPthId); |
|
27 |
+ String findLatestCntxtPth(); |
|
44 | 28 |
|
45 | 29 |
/** |
46 | 30 |
* @param cntxtPthVO - 컨텍스트 패스 정보 |
... | ... | @@ -49,20 +33,4 @@ |
49 | 33 |
* 컨텍스트 패스 등록 |
50 | 34 |
*/ |
51 | 35 |
int save(CntxtPthVO cntxtPthVO); |
52 |
- |
|
53 |
- /** |
|
54 |
- * @param cntxtPthVO - 컨텍스트 패스 정보 |
|
55 |
- * @return int - 컨텍스트 패스 수정 결과 |
|
56 |
- * |
|
57 |
- * 컨텍스트 패스 수정 |
|
58 |
- */ |
|
59 |
- int update(CntxtPthVO cntxtPthVO); |
|
60 |
- |
|
61 |
- /** |
|
62 |
- * @param cntxtPthId - 컨텍스트 패스 아이디 |
|
63 |
- * @return int - 컨텍스트 패스 삭제 결과 |
|
64 |
- * |
|
65 |
- * 컨텍스트 패스 삭제 |
|
66 |
- */ |
|
67 |
- int delete(String cntxtPthId); |
|
68 | 36 |
} |
--- src/main/java/com/takensoft/cms/cntxtPth/service/CntxtPthService.java
+++ src/main/java/com/takensoft/cms/cntxtPth/service/CntxtPthService.java
... | ... | @@ -16,22 +16,11 @@ |
16 | 16 |
public interface CntxtPthService { |
17 | 17 |
|
18 | 18 |
/** |
19 |
- * @param params - 검색조건 및 페이징 정보 |
|
20 |
- * @return Map<String, Object> |
|
21 |
- * - list : 컨텍스트 패스 목록 |
|
22 |
- * - pagination : 페이징 정보 |
|
19 |
+ * @return String - 컨텍스트 패스 경로 |
|
23 | 20 |
* |
24 |
- * 컨텍스트 패스 목록 조회 |
|
21 |
+ * 최신 컨텍스트 패스 조회 |
|
25 | 22 |
*/ |
26 |
- public Map<String, Object> findAllCntxtPth(Map<String, String> params); |
|
27 |
- |
|
28 |
- /** |
|
29 |
- * @param cntxtPthId - 컨텍스트 패스 아이디 |
|
30 |
- * @return CntxtPthVO - 컨텍스트 패스 정보를 담고 있는 객체 |
|
31 |
- * |
|
32 |
- * 컨텍스트 패스 상세 조회 |
|
33 |
- */ |
|
34 |
- Map<String, Object> findByCntxtPthId(String cntxtPthId); |
|
23 |
+ String findLatestCntxtPth(); |
|
35 | 24 |
|
36 | 25 |
/** |
37 | 26 |
* @param cntxtPthVO - 컨텍스트 패스 정보 |
... | ... | @@ -40,20 +29,4 @@ |
40 | 29 |
* 컨텍스트 패스 등록 |
41 | 30 |
*/ |
42 | 31 |
public int cntxtPthSave(CntxtPthVO cntxtPthVO); |
43 |
- |
|
44 |
- /** |
|
45 |
- * @param cntxtPthVO - 컨텍스트 패스 정보 |
|
46 |
- * @return int - 컨텍스트 패스 수정 결과 |
|
47 |
- * |
|
48 |
- * 컨텍스트 패스 수정 |
|
49 |
- */ |
|
50 |
- public int cntxtPthUpdate(CntxtPthVO cntxtPthVO); |
|
51 |
- |
|
52 |
- /** |
|
53 |
- * @param cntxtPthId - 컨텍스트 패스 아이디 |
|
54 |
- * @return int - 컨텍스트 패스 삭제 결과 |
|
55 |
- * |
|
56 |
- * 컨텍스트 패스 삭제 |
|
57 |
- */ |
|
58 |
- public int cntxtPthDelete(String cntxtPthId); |
|
59 | 32 |
} |
--- src/main/java/com/takensoft/cms/cntxtPth/service/Impl/CntxtPthServiceImpl.java
+++ src/main/java/com/takensoft/cms/cntxtPth/service/Impl/CntxtPthServiceImpl.java
... | ... | @@ -11,6 +11,8 @@ |
11 | 11 |
import com.takensoft.common.util.JWTUtil; |
12 | 12 |
import lombok.RequiredArgsConstructor; |
13 | 13 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
14 |
+import org.springframework.cache.annotation.CacheEvict; |
|
15 |
+import org.springframework.cache.annotation.Cacheable; |
|
14 | 16 |
import org.springframework.dao.DataAccessException; |
15 | 17 |
import org.springframework.stereotype.Service; |
16 | 18 |
import org.springframework.transaction.annotation.Transactional; |
... | ... | @@ -25,6 +27,7 @@ |
25 | 27 |
* @modification |
26 | 28 |
* since | author | description |
27 | 29 |
* 2025.03.31 | 하석형 | 최초 등록 |
30 |
+ * 2025.04.02 | 하석형 | 이력 관리 및 최신 컨텍스트 패스 조회 형식으로 변경 |
|
28 | 31 |
* |
29 | 32 |
* EgovAbstractServiceImpl : 전자정부 상속 |
30 | 33 |
* CntxtPthService : 컨텍스트 패스 정보 관련 인터페이스 상속 |
... | ... | @@ -39,54 +42,22 @@ |
39 | 42 |
private final IdgenService cntxtPthIdgn; |
40 | 43 |
|
41 | 44 |
/** |
42 |
- * @param params - 검색조건 및 페이징 정보 |
|
43 |
- * @return Map<String, Object> |
|
44 |
- * - list : 컨텍스트 패스 목록 |
|
45 |
- * - pagination : 페이징 정보 |
|
46 |
- * @throws DataAccessException - db 관련 예외 발생 시 |
|
47 |
- * @throws Exception - 그 외 예외 발생 시 |
|
48 |
- * |
|
49 |
- * 컨텍스트 패스 목록 조회 |
|
50 |
- */ |
|
51 |
- @Override |
|
52 |
- public Map<String, Object> findAllCntxtPth(Map<String, String> params) { |
|
53 |
- try { |
|
54 |
- Map<String, Object> result = new HashMap<String, Object>(); // 반환 객체 생성 |
|
55 |
- Pagination search = new Pagination(0, params); // 검색조건 객체 생성 |
|
56 |
- int cnt = cntxtPthDAO.findAllCnt(search); // 게시물 갯수 |
|
57 |
- Pagination pagination = new Pagination(cnt, params); // 게시물 갯수 조회 후 검색조건 객체 초기화 |
|
58 |
- List<CntxtPthVO> list = cntxtPthDAO.findAll(pagination); // 목록 조회 |
|
59 |
- |
|
60 |
- result.put("list", list); |
|
61 |
- result.put("pagination", pagination); |
|
62 |
- |
|
63 |
- return result; |
|
64 |
- } catch (DataAccessException dae) { |
|
65 |
- throw dae; |
|
66 |
- } catch (Exception e) { |
|
67 |
- throw e; |
|
68 |
- } |
|
69 |
- } |
|
70 |
- |
|
71 |
- /** |
|
72 |
- * @param cntxtPthId - 컨텍스트 패스 코드 |
|
73 |
- * @return AuthorVO - 컨텍스트 패스 정보를 담고 있는 객체 |
|
45 |
+ * @return String - 컨텍스트 패스 경로 |
|
74 | 46 |
* @throws DataAccessException - db 관련 예외 발생 시 |
75 | 47 |
* @throws Exception - 그 외 예외 발생 시 |
76 | 48 |
* |
77 |
- * 컨텍스트 패스 상세 조회 |
|
49 |
+ * 최신 컨텍스트 패스 조회 |
|
78 | 50 |
*/ |
79 | 51 |
@Override |
80 |
- public Map<String, Object> findByCntxtPthId(String cntxtPthId) { |
|
52 |
+// @Cacheable(value = "cntxtPthInfo", key = "'cntxtPth'") |
|
53 |
+ public String findLatestCntxtPth() { |
|
81 | 54 |
try { |
82 |
- Map<String, Object> result = new HashMap<String, Object>(); // 반환 객체 생성 |
|
83 |
- CntxtPthVO cntxtPth = new CntxtPthVO(); |
|
84 |
- if (cntxtPthId != null && !cntxtPthId.equals("")) { |
|
85 |
- cntxtPth = cntxtPthDAO.findByCntxtPthId(cntxtPthId); |
|
55 |
+ String cntxtPth = cntxtPthDAO.findLatestCntxtPth(); |
|
56 |
+ if (cntxtPth != null && !cntxtPth.equals("")) { |
|
57 |
+ return cntxtPth; |
|
58 |
+ } else { |
|
59 |
+ return "/"; // 기본값 설정 |
|
86 | 60 |
} |
87 |
- result.put("cntxtPth", cntxtPth); |
|
88 |
- |
|
89 |
- return result; |
|
90 | 61 |
} catch (DataAccessException dae) { |
91 | 62 |
throw dae; |
92 | 63 |
} catch (Exception e) { |
... | ... | @@ -104,6 +75,7 @@ |
104 | 75 |
* 컨텍스트 패스 등록 |
105 | 76 |
*/ |
106 | 77 |
@Override |
78 |
+// @CacheEvict(value = "cntxtPthInfo", allEntries = true) |
|
107 | 79 |
@Transactional(rollbackFor = Exception.class) |
108 | 80 |
public int cntxtPthSave(CntxtPthVO cntxtPthVO) { |
109 | 81 |
try { |
... | ... | @@ -113,58 +85,6 @@ |
113 | 85 |
int result = cntxtPthDAO.save(cntxtPthVO); |
114 | 86 |
if(result == 0) { |
115 | 87 |
throw new CustomInsertFailException("컨텍스트 패스 등록에 실패했습니다."); |
116 |
- } |
|
117 |
- |
|
118 |
- return result; |
|
119 |
- } catch (DataAccessException dae) { |
|
120 |
- throw dae; |
|
121 |
- } catch (Exception e) { |
|
122 |
- throw e; |
|
123 |
- } |
|
124 |
- } |
|
125 |
- |
|
126 |
- /** |
|
127 |
- * @param cntxtPthVO - 컨텍스트 패스 정보 |
|
128 |
- * @return int - 컨텍스트 패스 수정 결과 |
|
129 |
- * @throws CustomUpdateFailException - 컨텍스트 패스 수정 예외 발생 시 |
|
130 |
- * @throws DataAccessException - db 관련 예외 발생 시 |
|
131 |
- * @throws Exception - 그 외 예외 발생 시 |
|
132 |
- * |
|
133 |
- * 컨텍스트 패스 수정 |
|
134 |
- */ |
|
135 |
- @Override |
|
136 |
- public int cntxtPthUpdate(CntxtPthVO cntxtPthVO) { |
|
137 |
- try { |
|
138 |
- // 등록된 토큰에서 사용자 정보 조회 |
|
139 |
- cntxtPthVO.setMdfr(jwtUtil.getWriter()); |
|
140 |
- int result = cntxtPthDAO.update(cntxtPthVO); |
|
141 |
- if(result == 0) { |
|
142 |
- throw new CustomUpdateFailException("컨텍스트 패스 수정에 실패했습니다."); |
|
143 |
- } |
|
144 |
- |
|
145 |
- return result; |
|
146 |
- } catch (DataAccessException dae) { |
|
147 |
- throw dae; |
|
148 |
- } catch (Exception e) { |
|
149 |
- throw e; |
|
150 |
- } |
|
151 |
- } |
|
152 |
- |
|
153 |
- /** |
|
154 |
- * @param cntxtPthId - 컨텍스트 패스 정보 |
|
155 |
- * @return int - 컨텍스트 패스 삭제 결과 |
|
156 |
- * @throws CustomDeleteFailException - 컨텍스트 패스 삭제 예외 발생 시 |
|
157 |
- * @throws DataAccessException - db 관련 예외 발생 시 |
|
158 |
- * @throws Exception - 그 외 예외 발생 시 |
|
159 |
- * |
|
160 |
- * 컨텍스트 패스 삭제 |
|
161 |
- */ |
|
162 |
- @Override |
|
163 |
- public int cntxtPthDelete(String cntxtPthId) { |
|
164 |
- try { |
|
165 |
- int result = cntxtPthDAO.delete(cntxtPthId); |
|
166 |
- if(result == 0) { |
|
167 |
- throw new CustomDeleteFailException("컨텍스트 패스 삭제에 실패했습니다."); |
|
168 | 88 |
} |
169 | 89 |
|
170 | 90 |
return result; |
--- src/main/java/com/takensoft/cms/cntxtPth/vo/CntxtPthVO.java
+++ src/main/java/com/takensoft/cms/cntxtPth/vo/CntxtPthVO.java
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 |
* @modification |
12 | 12 |
* since | author | description |
13 | 13 |
* 2025.03.31 | 하석형 | 최초 등록 |
14 |
+ * 2025.04.02 | 하석형 | 이력 관리 및 최신 컨텍스트 패스 조회 형식으로 변경 |
|
14 | 15 |
* |
15 | 16 |
* 컨텍스트 패스 정보 관련 VO |
16 | 17 |
*/ |
... | ... | @@ -22,13 +23,8 @@ |
22 | 23 |
|
23 | 24 |
private String cntxtPthId; // 컨텍스트 패스 아이디 |
24 | 25 |
private String path; // 경로 |
25 |
- private String useYn; // 사용여부 |
|
26 |
- private String sysPvsnYn; // 시스템 제공 여부 ( 0: 시스템, 1: 사용자 ) -> 시스템에서 제공되는 데이터는 사용자가 제거하지 못하도록 하기 위한 설정값 |
|
27 | 26 |
private String rgtr; // 등록자 |
28 | 27 |
private String rgtrNm; // 등록자명 |
29 | 28 |
private String regDt; // 등록일 |
30 |
- private String mdfr; // 수정자 |
|
31 |
- private String mdfrNm; // 수정자명 |
|
32 |
- private String mdfcnDt; // 수정일 |
|
33 | 29 |
|
34 | 30 |
} |
--- src/main/java/com/takensoft/cms/cntxtPth/web/CntxtPthController.java
+++ src/main/java/com/takensoft/cms/cntxtPth/web/CntxtPthController.java
... | ... | @@ -7,10 +7,7 @@ |
7 | 7 |
import lombok.RequiredArgsConstructor; |
8 | 8 |
import lombok.extern.slf4j.Slf4j; |
9 | 9 |
import org.springframework.http.ResponseEntity; |
10 |
-import org.springframework.web.bind.annotation.PostMapping; |
|
11 |
-import org.springframework.web.bind.annotation.RequestBody; |
|
12 |
-import org.springframework.web.bind.annotation.RequestMapping; |
|
13 |
-import org.springframework.web.bind.annotation.RestController; |
|
10 |
+import org.springframework.web.bind.annotation.*; |
|
14 | 11 |
|
15 | 12 |
import java.util.HashMap; |
16 | 13 |
import java.util.List; |
... | ... | @@ -22,6 +19,7 @@ |
22 | 19 |
* @modification |
23 | 20 |
* since | author | description |
24 | 21 |
* 2025.03.31 | 하석형 | 최초 등록 |
22 |
+ * 2025.04.02 | 하석형 | 이력 관리 및 최신 컨텍스트 패스 조회 형식으로 변경 |
|
25 | 23 |
* |
26 | 24 |
* 컨텍스트 패스 정보 관련 컨트롤러 |
27 | 25 |
*/ |
... | ... | @@ -35,6 +33,18 @@ |
35 | 33 |
private final CntxtPthService cntxtPthService; |
36 | 34 |
|
37 | 35 |
/** |
36 |
+ * @return ResponseEntity - 최신 컨텍스트 패스 조회 결과를 포함하는 응답 |
|
37 |
+ * |
|
38 |
+ * 최신 컨텍스트 패스 조회 |
|
39 |
+ */ |
|
40 |
+ @GetMapping("/findLatestCntxtPth.json") |
|
41 |
+ public ResponseEntity<?> findLatestCntxtPth() { |
|
42 |
+ // 최신 컨텍스트 패스 조회 |
|
43 |
+ String ctx = cntxtPthService.findLatestCntxtPth(); |
|
44 |
+ return resUtil.successRes(ctx, MessageCode.COMMON_SUCCESS); |
|
45 |
+ } |
|
46 |
+ |
|
47 |
+ /** |
|
38 | 48 |
* @param cntxtPthVO - 컨텍스트 패스 정보 |
39 | 49 |
* @return ResponseEntity - 컨텍스트 패스 등록 결과를 포함하는 응답 |
40 | 50 |
* |
... | ... | @@ -44,54 +54,6 @@ |
44 | 54 |
public ResponseEntity<?> saveProc(@RequestBody CntxtPthVO cntxtPthVO) { |
45 | 55 |
// 컨텍스트 패스 등록 |
46 | 56 |
int result = cntxtPthService.cntxtPthSave(cntxtPthVO); |
47 |
- return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
48 |
- } |
|
49 |
- |
|
50 |
- /** |
|
51 |
- * @param params - 검색조건 및 페이징 정보 |
|
52 |
- * @return ResponseEntity - 컨텍스트 패스 목록 조회 결과를 포함하는 응답 |
|
53 |
- * |
|
54 |
- * 컨텍스트 패스 목록 조회 |
|
55 |
- */ |
|
56 |
- @PostMapping("/findAll.json") |
|
57 |
- public ResponseEntity<?> findAll(@RequestBody Map<String, String> params) { |
|
58 |
- Map<String, Object> result = cntxtPthService.findAllCntxtPth(params); |
|
59 |
- return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
60 |
- } |
|
61 |
- |
|
62 |
- /** |
|
63 |
- * @param cntxtPthVO - 컨텍스트 패스 정보 |
|
64 |
- * @return ResponseEntity - 컨텍스트 패스 상세 조회 결과를 포함하는 응답 |
|
65 |
- * |
|
66 |
- * 컨텍스트 패스 상세 조회 |
|
67 |
- */ |
|
68 |
- @PostMapping("/findByCntxtPth.json") |
|
69 |
- public ResponseEntity<?> findByCntxtPth(@RequestBody CntxtPthVO cntxtPthVO) { |
|
70 |
- Map<String, Object> result = cntxtPthService.findByCntxtPthId(cntxtPthVO.getCntxtPthId()); |
|
71 |
- return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
72 |
- } |
|
73 |
- |
|
74 |
- /** |
|
75 |
- * @param cntxtPthVO - 컨텍스트 패스 정보 |
|
76 |
- * @return ResponseEntity - 컨텍스트 패스 수정 결과를 포함하는 응답 |
|
77 |
- * |
|
78 |
- * 컨텍스트 패스 수정 |
|
79 |
- */ |
|
80 |
- @PostMapping("/updateProc.json") |
|
81 |
- public ResponseEntity<?> updateProc(@RequestBody CntxtPthVO cntxtPthVO) { |
|
82 |
- int result = cntxtPthService.cntxtPthUpdate(cntxtPthVO); |
|
83 |
- return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
84 |
- } |
|
85 |
- |
|
86 |
- /** |
|
87 |
- * @param cntxtPthVO - 컨텍스트 패스 정보 |
|
88 |
- * @return ResponseEntity - 컨텍스트 패스 삭제 결과를 포함하는 응답 |
|
89 |
- * |
|
90 |
- * 컨텍스트 패스 삭제 |
|
91 |
- */ |
|
92 |
- @PostMapping("/deleteProc.json") |
|
93 |
- public ResponseEntity<?> deleteProc(@RequestBody CntxtPthVO cntxtPthVO) { |
|
94 |
- int result = cntxtPthService.cntxtPthDelete(cntxtPthVO.getCntxtPthId()); |
|
95 | 57 |
return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
96 | 58 |
} |
97 | 59 |
} |
--- src/main/java/com/takensoft/common/config/SecurityConfig.java
+++ src/main/java/com/takensoft/common/config/SecurityConfig.java
... | ... | @@ -1,14 +1,12 @@ |
1 | 1 |
package com.takensoft.common.config; |
2 | 2 |
|
3 | 3 |
import com.takensoft.cms.accesCtrl.service.AccesCtrlService; |
4 |
+import com.takensoft.cms.cntxtPth.service.CntxtPthService; |
|
4 | 5 |
import com.takensoft.cms.loginPolicy.service.LoginModeService; |
5 | 6 |
import com.takensoft.cms.loginPolicy.service.LoginPolicyService; |
6 | 7 |
import com.takensoft.cms.mber.service.LgnHstryService; |
7 | 8 |
import com.takensoft.cms.token.service.RefreshTokenService; |
8 |
-import com.takensoft.common.filter.AccesFilter; |
|
9 |
-import com.takensoft.common.filter.JWTFilter; |
|
10 |
-import com.takensoft.common.filter.LoginFilter; |
|
11 |
-import com.takensoft.common.filter.SessionAuthFilter; |
|
9 |
+import com.takensoft.common.filter.*; |
|
12 | 10 |
import com.takensoft.common.util.HttpRequestUtil; |
13 | 11 |
import com.takensoft.common.exception.CustomAccessDenieHandler; |
14 | 12 |
import com.takensoft.common.exception.CustomAuthenticationEntryPoint; |
... | ... | @@ -26,6 +24,7 @@ |
26 | 24 |
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
27 | 25 |
import org.springframework.security.web.SecurityFilterChain; |
28 | 26 |
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; |
27 |
+import org.springframework.security.web.context.SecurityContextPersistenceFilter; |
|
29 | 28 |
import org.springframework.web.cors.CorsConfiguration; |
30 | 29 |
import org.springframework.web.cors.CorsConfigurationSource; |
31 | 30 |
|
... | ... | @@ -50,6 +49,7 @@ |
50 | 49 |
private final JWTUtil jwtUtil; |
51 | 50 |
private final RefreshTokenService refreshTokenService; |
52 | 51 |
private final LgnHstryService lgnHstryService; |
52 |
+ private final CntxtPthService cntxtPthService; |
|
53 | 53 |
private final AccesCtrlService accesCtrlService; |
54 | 54 |
private final CustomAuthenticationEntryPoint authenticationEntryPoint; |
55 | 55 |
private final CustomAccessDenieHandler accessDenieHandler; |
... | ... | @@ -78,13 +78,14 @@ |
78 | 78 |
* @param redisTemplate |
79 | 79 |
* |
80 | 80 |
*/ |
81 |
- public SecurityConfig(AuthenticationConfiguration authenticationConfiguration, JWTUtil jwtUtil, RefreshTokenService refreshTokenService, AccesCtrlService accesCtrlService, AppConfig appConfig, |
|
81 |
+ public SecurityConfig(AuthenticationConfiguration authenticationConfiguration, JWTUtil jwtUtil, RefreshTokenService refreshTokenService, CntxtPthService cntxtPthService, AccesCtrlService accesCtrlService, AppConfig appConfig, |
|
82 | 82 |
LgnHstryService lgnHstryService, CustomAuthenticationEntryPoint authenticationEntryPoint, CustomAccessDenieHandler accessDenieHandler, HttpRequestUtil httpRequestUtil, |
83 | 83 |
LoginModeService loginModeService, LoginPolicyService loginPolicyService, SessionUtil sessionUtil, @Value("${front.url}") String fUrl, @Value("${jwt.accessTime}") long aTime, @Value("${jwt.refreshTime}") long rTime, @Value("${cookie.time}") int ctime, RedisTemplate<String, String> redisTemplate) { |
84 | 84 |
|
85 | 85 |
this.authenticationConfiguration = authenticationConfiguration; |
86 | 86 |
this.refreshTokenService = refreshTokenService; |
87 | 87 |
this.lgnHstryService = lgnHstryService; |
88 |
+ this.cntxtPthService = cntxtPthService; |
|
88 | 89 |
this.accesCtrlService = accesCtrlService; |
89 | 90 |
this.authenticationEntryPoint = authenticationEntryPoint; |
90 | 91 |
this.accessDenieHandler = accessDenieHandler; |
... | ... | @@ -156,6 +157,9 @@ |
156 | 157 |
// 세션 설정 |
157 | 158 |
http.sessionManagement((session) -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)); |
158 | 159 |
|
160 |
+ // Context Path 검증 필터 |
|
161 |
+ http.addFilterBefore(new ContextPathFilter(cntxtPthService), SecurityContextPersistenceFilter.class); |
|
162 |
+ |
|
159 | 163 |
http.exceptionHandling((exception) -> exception |
160 | 164 |
.authenticationEntryPoint(authenticationEntryPoint) // 접근 권한이 없는 경우에 호출 |
161 | 165 |
.accessDeniedHandler(accessDenieHandler) // 인증되지 않은 상태로 접근 했을 때 호출 |
+++ src/main/java/com/takensoft/common/filter/ContextPathFilter.java
... | ... | @@ -0,0 +1,77 @@ |
1 | +package com.takensoft.common.filter; | |
2 | + | |
3 | +import com.takensoft.cms.cntxtPth.service.CntxtPthService; | |
4 | +import com.takensoft.common.config.AppConfig; | |
5 | +import com.takensoft.common.util.ErrorResponse; | |
6 | +import com.takensoft.common.util.HttpRequestUtil; | |
7 | +import jakarta.servlet.FilterChain; | |
8 | +import jakarta.servlet.RequestDispatcher; | |
9 | +import jakarta.servlet.ServletException; | |
10 | +import jakarta.servlet.http.HttpServletRequest; | |
11 | +import jakarta.servlet.http.HttpServletResponse; | |
12 | +import org.springframework.http.HttpStatus; | |
13 | +import org.springframework.http.MediaType; | |
14 | +import org.springframework.security.web.util.matcher.AntPathRequestMatcher; | |
15 | +import org.springframework.web.filter.OncePerRequestFilter; | |
16 | + | |
17 | +import java.io.IOException; | |
18 | +import java.time.LocalDateTime; | |
19 | +import java.util.List; | |
20 | + | |
21 | +/** | |
22 | + * @author 하석형 | |
23 | + * @since 2025.04.02 | |
24 | + * @modification | |
25 | + * since | author | description | |
26 | + * 2025.04.02 | 하석형 | 최초 등록 | |
27 | + * | |
28 | + * OncePerRequestFilter - 한 번의 요청마다 단 한 번만 필터링 작업을 수행하는 필터를 제공하는 클래스 | |
29 | + * | |
30 | + * Context Path 검증 필터 | |
31 | + */ | |
32 | +public class ContextPathFilter extends OncePerRequestFilter { | |
33 | + | |
34 | + private final CntxtPthService cntxtPthService; | |
35 | + | |
36 | + /** | |
37 | + * @param cntxtPthService 컨텍스트 패스 관련 인터페이스의 인스턴스 | |
38 | + * | |
39 | + * ContextPathFilter 생성자 | |
40 | + */ | |
41 | + public ContextPathFilter(CntxtPthService cntxtPthService) { | |
42 | + this.cntxtPthService = cntxtPthService; | |
43 | + } | |
44 | + /** | |
45 | + * @param request HttpServletRequest 객체 | |
46 | + * @param response HttpServletResponse 객체 | |
47 | + * @param filterChain 필터 체인을 통해 다음 필터로 요청을 전달 | |
48 | + * @throws ServletException 필터 처리 중 발생한 서블릿 예외 | |
49 | + * @throws IOException 필터 처리 중 발생한 IO 예외 | |
50 | + * | |
51 | + * Context Path 검증 및 일반화 | |
52 | + */ | |
53 | + @Override | |
54 | + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { | |
55 | + try { | |
56 | + String uri = request.getRequestURI(); // 요청 URI | |
57 | + | |
58 | + String dbCtx = cntxtPthService.findLatestCntxtPth(); // DB에서 최신 컨텍스트 패스 조회 | |
59 | + | |
60 | + // 요청 URI와 DB에서 가져온 컨텍스트 패스 비교 | |
61 | + if (dbCtx != null && !dbCtx.equals("/") && uri.startsWith(dbCtx)) { | |
62 | + String newUri = uri.substring(dbCtx.length()); // DB에서 가져온 컨텍스트 패스를 제외한 URI | |
63 | + if (newUri.isEmpty()) { | |
64 | + newUri = "/"; | |
65 | + } | |
66 | + RequestDispatcher dispatcher = request.getRequestDispatcher(newUri); // 새로운 URI로 요청을 전달 | |
67 | + dispatcher.forward(request, response); | |
68 | + return; | |
69 | + } | |
70 | + | |
71 | + filterChain.doFilter(request, response); | |
72 | + } catch (Exception e) { | |
73 | + // 시스템 에러 발생 | |
74 | + e.printStackTrace(); | |
75 | + } | |
76 | + } | |
77 | +} |
--- src/main/resources/mybatis/mapper/cntxtPth/cntxtPth-SQL.xml
+++ src/main/resources/mybatis/mapper/cntxtPth/cntxtPth-SQL.xml
... | ... | @@ -7,61 +7,20 @@ |
7 | 7 |
| 수 정 일 | 수 정 자 | 내 용 |
8 | 8 |
======================================================================================================== |
9 | 9 |
| 2025.03.31 | 하석형 | - 최초 등록 |
10 |
+ | 2025.04.02 | 하석형 | - 이력 관리 및 최신 컨텍스트 패스 조회 형식으로 변경 |
|
10 | 11 |
======================================================================================================== |
11 | 12 |
--> |
12 | 13 |
<mapper namespace="com.takensoft.cms.cntxtPth.dao.CntxtPthDAO"> |
13 |
- <sql id="selectCntxtPth"> |
|
14 |
- SELECT cpm.cntxt_pth_id |
|
15 |
- , cpm.path |
|
16 |
- , cpm.use_yn |
|
17 |
- , cpm.sys_pvsn_yn |
|
18 |
- , cpm.rgtr |
|
19 |
- , (SELECT mbr_nm FROM mbr_info WHERE mbr_id = cpm.rgtr) AS rgtr_nm |
|
20 |
- , TO_CHAR(cpm.reg_dt, 'YYYY-MM-DD HH24:MI') AS reg_dt |
|
21 |
- , cpm.mdfr |
|
22 |
- , (SELECT mbr_nm FROM mbr_info WHERE mbr_id = cpm.mdfr) AS mdfr_nm |
|
23 |
- , TO_CHAR(cpm.mdfcn_dt, 'YYYY-MM-DD HH24:MI') AS mdfcn_dt |
|
24 |
- FROM cntxt_pth_mng cpm |
|
25 |
- </sql> |
|
26 |
- |
|
27 |
- <sql id="selectRequirement"> |
|
28 |
- <if test="searchText != null and searchText != ''"> |
|
29 |
- AND cpm.path LIKE '%' || #{searchText} || '%' |
|
30 |
- </if> |
|
31 |
- </sql> |
|
32 |
- |
|
33 | 14 |
<!-- |
34 | 15 |
작 성 자 : 하석형 |
35 |
- 작 성 일 : 2025.03.31 |
|
36 |
- 내 용 : 컨텍스트 패스 목록 조회 |
|
16 |
+ 작 성 일 : 2025.04.02 |
|
17 |
+ 내 용 : 최신 컨텍스트 패스 조회 |
|
37 | 18 |
--> |
38 |
- <select id="findAll" parameterType="Pagination" resultType="CntxtPthVO"> |
|
39 |
- <include refid="selectCntxtPth" /> |
|
40 |
- WHERE 1=1 |
|
41 |
- <include refid="selectRequirement" /> |
|
42 |
- LIMIT #{recordSize} OFFSET #{limitStart} |
|
43 |
- </select> |
|
44 |
- |
|
45 |
- <!-- |
|
46 |
- 작 성 자 : 하석형 |
|
47 |
- 작 성 일 : 2025.03.31 |
|
48 |
- 내 용 : 컨텍스트 패스 목록 갯수 조회 |
|
49 |
- --> |
|
50 |
- <select id="findAllCnt" parameterType="Pagination" resultType="Integer"> |
|
51 |
- SELECT COUNT(cpm.cntxt_pth_id) |
|
52 |
- FROM cntxt_pth_mng cpm |
|
53 |
- WHERE 1=1 |
|
54 |
- <include refid="selectRequirement" /> |
|
55 |
- </select> |
|
56 |
- |
|
57 |
- <!-- |
|
58 |
- 작 성 자 : 하석형 |
|
59 |
- 작 성 일 : 2025.03.31 |
|
60 |
- 내 용 : 컨텍스트 패스 상세 조회 |
|
61 |
- --> |
|
62 |
- <select id="findByCntxtPthCode" parameterType="String" resultType="CntxtPthVO"> |
|
63 |
- <include refid="selectCntxtPth" /> |
|
64 |
- WHERE cpm.cntxt_pth_id = #{cntxtPthId} |
|
19 |
+ <select id="findLatestCntxtPth" resultType="String"> |
|
20 |
+ SELECT path |
|
21 |
+ FROM cntxt_pth_mng cpm |
|
22 |
+ ORDER BY reg_dt DESC |
|
23 |
+ LIMIT 1 |
|
65 | 24 |
</select> |
66 | 25 |
|
67 | 26 |
<!-- |
... | ... | @@ -73,41 +32,13 @@ |
73 | 32 |
INSERT INTO cntxt_pth_mng ( |
74 | 33 |
cntxt_pth_id |
75 | 34 |
, path |
76 |
- , use_yn |
|
77 |
- , sys_pvsn_yn |
|
78 | 35 |
, rgtr |
79 | 36 |
, reg_dt |
80 | 37 |
) VALUES ( |
81 | 38 |
#{cntxtPthId} |
82 | 39 |
, #{path} |
83 |
- , 'Y' |
|
84 |
- , 1 |
|
85 | 40 |
, #{rgtr} |
86 | 41 |
, NOW() |
87 | 42 |
) |
88 | 43 |
</insert> |
89 |
- |
|
90 |
- <!-- |
|
91 |
- 작 성 자 : 하석형 |
|
92 |
- 작 성 일 : 2025.03.31 |
|
93 |
- 내 용 : 컨텍스트 패스 수정 |
|
94 |
- --> |
|
95 |
- <update id="update" parameterType="CntxtPthVO"> |
|
96 |
- UPDATE cntxt_pth_mng |
|
97 |
- SET path = #{path} |
|
98 |
- , use_yn = #{useYn} |
|
99 |
- , mdfr = #{mdfr} |
|
100 |
- , mdfcn_dt = NOW() |
|
101 |
- WHERE cntxt_pth_id = #{cntxtPthId} |
|
102 |
- </update> |
|
103 |
- |
|
104 |
- <!-- |
|
105 |
- 작 성 자 : 하석형 |
|
106 |
- 작 성 일 : 2025.03.31 |
|
107 |
- 내 용 : 컨텍스트 패스 삭제 |
|
108 |
- --> |
|
109 |
- <delete id="delete" parameterType="String"> |
|
110 |
- DELETE FROM cntxt_pth_mng |
|
111 |
- WHERE cntxt_pth_id = #{cntxtPthId} |
|
112 |
- </delete> |
|
113 | 44 |
</mapper>(파일 끝에 줄바꿈 문자 없음) |
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?