IPIgnore Interceptor 헤더 아이피 조작에 따른 아이피 패턴 검사 로직 추가 - 아이피 검사 실패(오류) 발생 혹은 아이피 범위가 아닌 경우 오류 발생 처리
- 아이피 검사 실패(오류) 발생 혹은 아이피 범위가 아닌 경우 오류 발생 처리
@bbc45b7a3982e43871350df5cd28bd8758382642
--- src/main/java/itn/com/cmm/interceptor/IPIgnoreInterceptorHandler.java
+++ src/main/java/itn/com/cmm/interceptor/IPIgnoreInterceptorHandler.java
... | ... | @@ -84,6 +84,48 @@ |
| 84 | 84 |
|
| 85 | 85 |
HackIpVO hackIpVO = new HackIpVO(); |
| 86 | 86 |
hackIpVO.setIgnoreIp(userIP); |
| 87 |
+ |
|
| 88 |
+ /* |
|
| 89 |
+ * 헤더 아이피 체크 해주기 |
|
| 90 |
+ * "." 기준으로 문자열 분할 후 0 ~ 255 사이 값인지 체크 |
|
| 91 |
+ * 범위 값이 아닌경우 오류 처리 |
|
| 92 |
+ * |
|
| 93 |
+ * */ |
|
| 94 |
+ String[] checkIP = userIP.split("\\.");
|
|
| 95 |
+ boolean ipCheckType = false; |
|
| 96 |
+ |
|
| 97 |
+ if(checkIP.length < 4 || checkIP == null) {
|
|
| 98 |
+ |
|
| 99 |
+ System.out.println("IPIgnoreInterceptorHandler-preHandle Header IP Check ERROR !!! ");
|
|
| 100 |
+ System.out.println("userIP ::: "+userIP);
|
|
| 101 |
+ response.sendRedirect(request.getContextPath() + "/"); |
|
| 102 |
+ return true; |
|
| 103 |
+ |
|
| 104 |
+ }else {
|
|
| 105 |
+ |
|
| 106 |
+ for(String tmp : checkIP) {
|
|
| 107 |
+ |
|
| 108 |
+ int ipNum = Integer.parseInt(tmp); |
|
| 109 |
+ |
|
| 110 |
+ if(ipNum >=0 && ipNum <= 255) {
|
|
| 111 |
+ |
|
| 112 |
+ ipCheckType = true; |
|
| 113 |
+ |
|
| 114 |
+ } |
|
| 115 |
+ |
|
| 116 |
+ } |
|
| 117 |
+ |
|
| 118 |
+ } |
|
| 119 |
+ |
|
| 120 |
+ |
|
| 121 |
+ if(!ipCheckType) {
|
|
| 122 |
+ |
|
| 123 |
+ System.out.println("IPIgnoreInterceptorHandler-preHandle Header IP Check ERROR !!! ");
|
|
| 124 |
+ System.out.println("userIP ::: "+userIP);
|
|
| 125 |
+ response.sendRedirect(request.getContextPath() + "/"); |
|
| 126 |
+ return true; |
|
| 127 |
+ |
|
| 128 |
+ } |
|
| 87 | 129 |
|
| 88 | 130 |
int i_ignoreCnt = hackIpService.selectIgnoreIpCnt(hackIpVO); |
| 89 | 131 |
|
... | ... | @@ -151,7 +193,11 @@ |
| 151 | 193 |
loginLogService.logInsertLoginLog4Ajax(loginLog); |
| 152 | 194 |
|
| 153 | 195 |
}catch(Exception ex) {
|
| 154 |
- ex.printStackTrace(); |
|
| 196 |
+ //ex.printStackTrace(); |
|
| 197 |
+ System.out.println("IPIgnoreInterceptorHandler-preHandle Error !!! " + ex);
|
|
| 198 |
+ //오류가 발생하면 메일화면으로 이동 시킨다. |
|
| 199 |
+ response.sendRedirect(request.getContextPath() + "/"); |
|
| 200 |
+ return true; |
|
| 155 | 201 |
|
| 156 | 202 |
} |
| 157 | 203 |
} |
... | ... | @@ -163,11 +209,13 @@ |
| 163 | 209 |
|
| 164 | 210 |
|
| 165 | 211 |
}catch(Exception ex) {
|
| 166 |
- ex.printStackTrace(); |
|
| 212 |
+ //ex.printStackTrace(); |
|
| 213 |
+ System.out.println("IPIgnoreInterceptorHandler-preHandle Error !!! " + ex);
|
|
| 214 |
+ //오류가 발생하면 경로 오류를 발생 시킨다. |
|
| 215 |
+ response.sendRedirect(request.getContextPath() + "/"); |
|
| 216 |
+ return true; |
|
| 167 | 217 |
} |
| 168 | 218 |
|
| 169 |
- |
|
| 170 |
- |
|
| 171 | 219 |
return v_ret; |
| 172 | 220 |
} |
| 173 | 221 |
|
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?