IPIgnore Interceptor IPv4/IPv6 모두 체크되도록 기능 수정
@82380a5188e2c2f95dcfc7441914d7592d654a46
--- src/main/java/itn/com/cmm/interceptor/IPIgnoreInterceptorHandler.java
+++ src/main/java/itn/com/cmm/interceptor/IPIgnoreInterceptorHandler.java
... | ... | @@ -13,6 +13,8 @@ |
| 13 | 13 |
import org.springframework.web.servlet.ModelAndView; |
| 14 | 14 |
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; |
| 15 | 15 |
|
| 16 |
+import com.google.common.net.InetAddresses; |
|
| 17 |
+ |
|
| 16 | 18 |
import egovframework.rte.fdl.security.userdetails.util.EgovUserDetailsHelper; |
| 17 | 19 |
import itn.com.cmm.LoginVO; |
| 18 | 20 |
import itn.com.uss.olh.hpc.service.HackIpService; |
... | ... | @@ -91,32 +93,12 @@ |
| 91 | 93 |
* 범위 값이 아닌경우 오류 처리 |
| 92 | 94 |
* |
| 93 | 95 |
* */ |
| 94 |
- String[] checkIP = userIP.split("\\.");
|
|
| 96 |
+ |
|
| 95 | 97 |
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 |
- |
|
| 98 |
+ //IPv4, IPv6 모두 체크 해줌 |
|
| 99 |
+ if(InetAddresses.isInetAddress(userIP)) {
|
|
| 100 |
+ ipCheckType = true; |
|
| 118 | 101 |
} |
| 119 |
- |
|
| 120 | 102 |
|
| 121 | 103 |
if(!ipCheckType) {
|
| 122 | 104 |
|
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?