--- pom.xml
+++ pom.xml
... | ... | @@ -477,12 +477,19 @@ |
| 477 | 477 |
</dependency> |
| 478 | 478 |
|
| 479 | 479 |
<!-- kmc 본인인증 --> |
| 480 |
- <dependency> |
|
| 480 |
+ <!-- <dependency> |
|
| 481 | 481 |
<groupId>kmc</groupId> |
| 482 | 482 |
<artifactId>ICERTSecu_JDK18</artifactId> |
| 483 | 483 |
<version>1</version> |
| 484 | 484 |
<scope>system</scope> |
| 485 | 485 |
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/ICERTSecu_JDK18.jar</systemPath>
|
| 486 |
+ </dependency> --> |
|
| 487 |
+ |
|
| 488 |
+ <!-- kmc 본인인증 ver 2 암호화 모듈 추가 버전 --> |
|
| 489 |
+ <dependency> |
|
| 490 |
+ <groupId>kmc</groupId> |
|
| 491 |
+ <artifactId>ICERTSecu</artifactId> |
|
| 492 |
+ <version>JDK18_v2</version> |
|
| 486 | 493 |
</dependency> |
| 487 | 494 |
|
| 488 | 495 |
|
--- src/main/java/itn/let/cert/phone/web/CertPhoneWebController.java
+++ src/main/java/itn/let/cert/phone/web/CertPhoneWebController.java
... | ... | @@ -34,12 +34,11 @@ |
| 34 | 34 |
|
| 35 | 35 |
@RequestMapping(value = {"/web/cert/log/insertCertLog.do"})
|
| 36 | 36 |
public ResponseEntity<StatusResponse> insertCertLog(HttpServletRequest request) throws Exception {
|
| 37 |
- |
|
| 38 |
- |
|
| 39 |
- |
|
| 40 |
- |
|
| 41 |
- |
|
| 42 |
- |
|
| 43 | 37 |
return ResponseEntity.ok().body(new StatusResponse(HttpStatus.OK, certPhoneService.insertCertLog(request), LocalDateTime.now())); |
| 44 |
- } |
|
| 38 |
+ } |
|
| 39 |
+ |
|
| 40 |
+ @RequestMapping(value = {"/web/cert/log/kmcErrorPage.do"})
|
|
| 41 |
+ public String kmcErrorPage() throws Exception {
|
|
| 42 |
+ return "web/cop/kmc/certResultError"; |
|
| 43 |
+ } |
|
| 45 | 44 |
}(No newline at end of file) |
--- src/main/java/itn/let/mjo/pay/service/KmcVO.java
+++ src/main/java/itn/let/mjo/pay/service/KmcVO.java
... | ... | @@ -226,6 +226,4 @@ |
| 226 | 226 |
this.certType = certType; |
| 227 | 227 |
} |
| 228 | 228 |
|
| 229 |
- |
|
| 230 |
- |
|
| 231 | 229 |
} |
--- src/main/java/itn/let/mjo/pay/web/MjonPayController.java
+++ src/main/java/itn/let/mjo/pay/web/MjonPayController.java
... | ... | @@ -91,6 +91,7 @@ |
| 91 | 91 |
import itn.let.sym.site.service.EgovSiteManagerService; |
| 92 | 92 |
import itn.let.sym.site.service.JoinSettingVO; |
| 93 | 93 |
import itn.let.uat.uia.service.AuthCertVO; |
| 94 |
+import itn.let.uat.uia.web.KmcCertChecker; |
|
| 94 | 95 |
import itn.let.uss.umt.service.EgovMberManageService; |
| 95 | 96 |
import itn.let.uss.umt.service.EgovUserManageService; |
| 96 | 97 |
import itn.let.uss.umt.service.MberManageVO; |
... | ... | @@ -165,7 +166,10 @@ |
| 165 | 166 |
EgovSiteManagerService egovSiteManagerService; |
| 166 | 167 |
|
| 167 | 168 |
@Resource(name = "mberGrdService") |
| 168 |
- MberGrdService mberGrdService; |
|
| 169 |
+ MberGrdService mberGrdService; |
|
| 170 |
+ |
|
| 171 |
+ @Resource(name = "KmcCertChecker") |
|
| 172 |
+ KmcCertChecker kmcCertChecker; |
|
| 169 | 173 |
|
| 170 | 174 |
//배열 정의{"컬럼순차번호, 컬럼이름, 컬럼내용, 컬럼이름에 붙여야할 내용(엑셀코드양식다운로드시 필요)"}
|
| 171 | 175 |
private String[][] sendPayExcelValue ={
|
... | ... | @@ -930,7 +934,7 @@ |
| 930 | 934 |
} |
| 931 | 935 |
|
| 932 | 936 |
/** |
| 933 |
- * 나이스페이(PG사 전송화면) |
|
| 937 |
+ * 회원가입 본인인증 |
|
| 934 | 938 |
* |
| 935 | 939 |
* @param |
| 936 | 940 |
* @return |
... | ... | @@ -941,253 +945,7 @@ |
| 941 | 945 |
ModelMap model , @RequestParam Map<String, Object> commandMap, |
| 942 | 946 |
@ModelAttribute("searchVO") KmcVO kmcVO) throws Exception {
|
| 943 | 947 |
|
| 944 |
- //크롬 SameSite정책 방지 - 도메인이 다른 타사로 이동 시 크롬 정책에 의해 세션 유실이 일어나는 경우가 있는데, 이를 방지하기 위해 samesite 보안을 none처리 |
|
| 945 |
- response.setHeader("Set-Cookie", "mberSession=mberSession; Secure; SameSite=None");
|
|
| 946 |
- |
|
| 947 |
- System.out.println("++++++++++++ 세션체크 ::: "+ session.getAttribute("mberSession"));
|
|
| 948 |
- |
|
| 949 |
- String errMessage = ""; //에러메세지 |
|
| 950 |
- |
|
| 951 |
- String rec_cert = ""; // 결과값(암호화) |
|
| 952 |
- String certNum = ""; // certNum |
|
| 953 |
- |
|
| 954 |
- rec_cert = request.getParameter("rec_cert").trim();
|
|
| 955 |
- certNum = request.getParameter("certNum").trim();
|
|
| 956 |
- |
|
| 957 |
- kmcVO.setRecCert(rec_cert); |
|
| 958 |
- kmcVO.setCertNum(certNum); |
|
| 959 |
- // 파라미터 유효성 검증 |
|
| 960 |
- if( rec_cert.length() == 0 || certNum.length() == 0 ){
|
|
| 961 |
- errMessage = "비정상"; |
|
| 962 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 963 |
- } |
|
| 964 |
- |
|
| 965 |
- |
|
| 966 |
- // 변수선언 -------------------------------------------------------------------------------------------------------- |
|
| 967 |
- String k_certNum = ""; // 파라미터로 수신한 요청번호 |
|
| 968 |
- k_certNum = certNum; |
|
| 969 |
- String date = ""; // 요청일시 |
|
| 970 |
- String CI = ""; // 연계정보(CI) |
|
| 971 |
- String DI = ""; // 중복가입확인정보(DI) |
|
| 972 |
- String phoneNo = ""; // 휴대폰번호 |
|
| 973 |
- String phoneCorp = ""; // 이동통신사 |
|
| 974 |
- String birthDay = ""; // 생년월일 |
|
| 975 |
- String gender = ""; // 성별 |
|
| 976 |
- String nation = ""; // 내국인 |
|
| 977 |
- String name = ""; // 성명 |
|
| 978 |
- String M_name = ""; // 미성년자 성명 |
|
| 979 |
- String M_birthDay = ""; // 미성년자 생년월일 |
|
| 980 |
- String M_Gender = ""; // 미성년자 성별 |
|
| 981 |
- String M_nation = ""; // 미성년자 내외국인 |
|
| 982 |
- String result = ""; // 결과값 |
|
| 983 |
- |
|
| 984 |
- String certMet = ""; // 인증방법 |
|
| 985 |
- String ip = ""; // ip주소 |
|
| 986 |
- String plusInfo = ""; |
|
| 987 |
- |
|
| 988 |
- String encPara = ""; |
|
| 989 |
- String encMsg1 = ""; |
|
| 990 |
- String encMsg2 = ""; |
|
| 991 |
- String msgChk = ""; |
|
| 992 |
- |
|
| 993 |
- com.icert.comm.secu.IcertSecuManager seed = new com.icert.comm.secu.IcertSecuManager(); |
|
| 994 |
- |
|
| 995 |
- //02. 1차 복호화 |
|
| 996 |
- //수신된 certNum를 이용하여 복호화 |
|
| 997 |
- rec_cert = seed.getDec(rec_cert, k_certNum); |
|
| 998 |
- |
|
| 999 |
- //03. 1차 파싱 |
|
| 1000 |
- int inf1 = rec_cert.indexOf("/",0);
|
|
| 1001 |
- int inf2 = rec_cert.indexOf("/",inf1+1);
|
|
| 1002 |
- |
|
| 1003 |
- encPara = rec_cert.substring(0,inf1); //암호화된 통합 파라미터 |
|
| 1004 |
- encMsg1 = rec_cert.substring(inf1+1,inf2); //암호화된 통합 파라미터의 Hash값 |
|
| 1005 |
- |
|
| 1006 |
- //04. 위변조 검증 |
|
| 1007 |
- encMsg2 = seed.getMsg(encPara); |
|
| 1008 |
- kmcVO.setEncMsg2(encMsg2); |
|
| 1009 |
- if(encMsg2.equals(encMsg1)){
|
|
| 1010 |
- msgChk="Y"; |
|
| 1011 |
- } |
|
| 1012 |
- |
|
| 1013 |
- if(!"Y".equals(msgChk)) {
|
|
| 1014 |
- errMessage = "비정상접근입니다."; |
|
| 1015 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1016 |
- } |
|
| 1017 |
- |
|
| 1018 |
- //05. 2차 복호화 |
|
| 1019 |
- rec_cert = seed.getDec(encPara, k_certNum); |
|
| 1020 |
- kmcVO.setRecCert(rec_cert); |
|
| 1021 |
- //06. 2차 파싱 |
|
| 1022 |
- int info1 = rec_cert.indexOf("/",0);
|
|
| 1023 |
- int info2 = rec_cert.indexOf("/",info1+1);
|
|
| 1024 |
- int info3 = rec_cert.indexOf("/",info2+1);
|
|
| 1025 |
- int info4 = rec_cert.indexOf("/",info3+1);
|
|
| 1026 |
- int info5 = rec_cert.indexOf("/",info4+1);
|
|
| 1027 |
- int info6 = rec_cert.indexOf("/",info5+1);
|
|
| 1028 |
- int info7 = rec_cert.indexOf("/",info6+1);
|
|
| 1029 |
- int info8 = rec_cert.indexOf("/",info7+1);
|
|
| 1030 |
- int info9 = rec_cert.indexOf("/",info8+1);
|
|
| 1031 |
- int info10 = rec_cert.indexOf("/",info9+1);
|
|
| 1032 |
- int info11 = rec_cert.indexOf("/",info10+1);
|
|
| 1033 |
- int info12 = rec_cert.indexOf("/",info11+1);
|
|
| 1034 |
- int info13 = rec_cert.indexOf("/",info12+1);
|
|
| 1035 |
- int info14 = rec_cert.indexOf("/",info13+1);
|
|
| 1036 |
- int info15 = rec_cert.indexOf("/",info14+1);
|
|
| 1037 |
- int info16 = rec_cert.indexOf("/",info15+1);
|
|
| 1038 |
- int info17 = rec_cert.indexOf("/",info16+1);
|
|
| 1039 |
- int info18 = rec_cert.indexOf("/",info17+1);
|
|
| 1040 |
- |
|
| 1041 |
- certNum = rec_cert.substring(0,info1); kmcVO.setCertNum(certNum); |
|
| 1042 |
- date = rec_cert.substring(info1+1,info2); kmcVO.setDate(date); |
|
| 1043 |
- CI = rec_cert.substring(info2+1,info3); kmcVO.setCI(CI); |
|
| 1044 |
- phoneNo = rec_cert.substring(info3+1,info4); kmcVO.setPhoneNo(phoneNo); |
|
| 1045 |
- phoneCorp = rec_cert.substring(info4+1,info5); kmcVO.setPhoneCorp(phoneCorp); |
|
| 1046 |
- birthDay = rec_cert.substring(info5+1,info6); kmcVO.setBirthDay(birthDay); |
|
| 1047 |
- gender = rec_cert.substring(info6+1,info7); kmcVO.setGender(gender); |
|
| 1048 |
- nation = rec_cert.substring(info7+1,info8); kmcVO.setNation(nation); |
|
| 1049 |
- name = rec_cert.substring(info8+1,info9); kmcVO.setName(name); |
|
| 1050 |
- result = rec_cert.substring(info9+1,info10); kmcVO.setResult(result); |
|
| 1051 |
- certMet = rec_cert.substring(info10+1,info11); kmcVO.setCertMet(certMet); |
|
| 1052 |
- ip = rec_cert.substring(info11+1,info12); kmcVO.setIp(ip); |
|
| 1053 |
- M_name = rec_cert.substring(info12+1,info13); kmcVO.setMName(M_name); |
|
| 1054 |
- M_birthDay = rec_cert.substring(info13+1,info14); kmcVO.setMBirthDay(M_birthDay); |
|
| 1055 |
- M_Gender = rec_cert.substring(info14+1,info15); kmcVO.setMGender(M_Gender); |
|
| 1056 |
- M_nation = rec_cert.substring(info15+1,info16); kmcVO.setMNation(M_nation); |
|
| 1057 |
- plusInfo = rec_cert.substring(info16+1,info17); kmcVO.setPlusInfo(plusInfo); |
|
| 1058 |
- DI = rec_cert.substring(info17+1,info18); kmcVO.setDI(DI); |
|
| 1059 |
- |
|
| 1060 |
- //07. CI, DI 복호화 |
|
| 1061 |
- CI = seed.getDec(CI, k_certNum); kmcVO.setCI(CI); |
|
| 1062 |
- DI = seed.getDec(DI, k_certNum); kmcVO.setDI(DI); |
|
| 1063 |
- |
|
| 1064 |
- if("Y".equals(result)) {
|
|
| 1065 |
- |
|
| 1066 |
- } |
|
| 1067 |
- |
|
| 1068 |
- //-------------------------------------------------------------- |
|
| 1069 |
- String regex = ""; |
|
| 1070 |
- if( certNum.length() == 0 || certNum.length() > 40){
|
|
| 1071 |
- errMessage = "요청번호 비정상."; |
|
| 1072 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1073 |
- } |
|
| 1074 |
- |
|
| 1075 |
- regex = "[0-9]*"; |
|
| 1076 |
- if( date.length() != 14 || !paramChk(regex, date) ){
|
|
| 1077 |
- errMessage = "요청일시"; |
|
| 1078 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1079 |
- } |
|
| 1080 |
- |
|
| 1081 |
- regex = "[A-Z]*"; |
|
| 1082 |
- if( certMet.length() != 1 || !paramChk(regex, certMet) ){
|
|
| 1083 |
- errMessage = "본인인증방법 비정상" + certMet; |
|
| 1084 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1085 |
- } |
|
| 1086 |
- |
|
| 1087 |
- |
|
| 1088 |
- regex = "[0-9]*"; |
|
| 1089 |
- if( (phoneNo.length() != 10 && phoneNo.length() != 11) || !paramChk(regex, phoneNo) ){
|
|
| 1090 |
- errMessage = "휴대폰번호 비정상" ; |
|
| 1091 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1092 |
- } |
|
| 1093 |
- |
|
| 1094 |
- regex = "[A-Z]*"; |
|
| 1095 |
- if( phoneCorp.length() != 3 || !paramChk(regex, phoneCorp) ){
|
|
| 1096 |
- errMessage = "이동통신사 비정상"; |
|
| 1097 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1098 |
- } |
|
| 1099 |
- |
|
| 1100 |
- regex = "[0-9]*"; |
|
| 1101 |
- if( birthDay.length() != 8 || !paramChk(regex, birthDay) ){
|
|
| 1102 |
- errMessage = "생년월일 비정상"; |
|
| 1103 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1104 |
- } |
|
| 1105 |
- |
|
| 1106 |
- regex = "[0-9]*"; |
|
| 1107 |
- if( gender.length() != 1 || !paramChk(regex, gender) ){
|
|
| 1108 |
- errMessage = "성별 비정상"; |
|
| 1109 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1110 |
- } |
|
| 1111 |
- |
|
| 1112 |
- regex = "[0-9]*"; |
|
| 1113 |
- if( nation.length() != 1 || !paramChk(regex, nation) ){
|
|
| 1114 |
- errMessage = "내/외국인 비정상"; |
|
| 1115 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1116 |
- } |
|
| 1117 |
- |
|
| 1118 |
- regex = "[\\sA-Za-z가-�R.,-]*"; |
|
| 1119 |
- if( name.length() > 60 || !paramChk(regex, name) ){
|
|
| 1120 |
- errMessage = "성명 비정상"; |
|
| 1121 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1122 |
- } |
|
| 1123 |
- |
|
| 1124 |
- regex = "[A-Z]*"; |
|
| 1125 |
- if( result.length() != 1 || !paramChk(regex, result) ){
|
|
| 1126 |
- errMessage = "결과값 비정상"; |
|
| 1127 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1128 |
- } |
|
| 1129 |
- |
|
| 1130 |
- regex = "[\\sA-Za-z가-?.,-]*"; |
|
| 1131 |
- if( M_name.length() != 0 ){
|
|
| 1132 |
- if( M_name.length() > 60 || !paramChk(regex, M_name) ){
|
|
| 1133 |
- errMessage = "미성년자 성명 비정상"; |
|
| 1134 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1135 |
- } |
|
| 1136 |
- } |
|
| 1137 |
- |
|
| 1138 |
- regex = "[0-9]*"; |
|
| 1139 |
- if( M_birthDay.length() != 0 ){
|
|
| 1140 |
- if( M_birthDay.length() != 8 || !paramChk(regex, M_birthDay) ){
|
|
| 1141 |
- errMessage = "미성년자 생년월일 비정상"; |
|
| 1142 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1143 |
- } |
|
| 1144 |
- } |
|
| 1145 |
- |
|
| 1146 |
- regex = "[0-9]*"; |
|
| 1147 |
- if( M_Gender.length() != 0 ){
|
|
| 1148 |
- if( M_Gender.length() != 1 || !paramChk(regex, M_Gender) ){
|
|
| 1149 |
- errMessage = "미성년자 성별 비정상"; |
|
| 1150 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1151 |
- } |
|
| 1152 |
- } |
|
| 1153 |
- |
|
| 1154 |
- regex = "[0-9]*"; |
|
| 1155 |
- if( M_nation.length() != 0 ){
|
|
| 1156 |
- if( M_nation.length() != 1 || !paramChk(regex, M_nation) ){
|
|
| 1157 |
- errMessage = "미성년자 내/외국인 비정상"; |
|
| 1158 |
- return returnPage(model , errMessage , kmcVO) ; |
|
| 1159 |
- } |
|
| 1160 |
- } |
|
| 1161 |
- |
|
| 1162 |
- //본인인증 결과 내용 저장하기. |
|
| 1163 |
- /*System.out.println("+++++++++++++ getCertNum ::: "+kmcVO.getCertNum());
|
|
| 1164 |
- System.out.println("+++++++++++++ getDate ::: "+kmcVO.getDate());
|
|
| 1165 |
- System.out.println("+++++++++++++ getDI ::: "+kmcVO.getDI());
|
|
| 1166 |
- System.out.println("+++++++++++++ getPhoneNo ::: "+kmcVO.getPhoneNo());
|
|
| 1167 |
- System.out.println("+++++++++++++ getNation ::: "+kmcVO.getNation());
|
|
| 1168 |
- System.out.println("+++++++++++++ getName ::: "+kmcVO.getName());
|
|
| 1169 |
- System.out.println("+++++++++++++ getResult ::: "+kmcVO.getResult());
|
|
| 1170 |
- System.out.println("+++++++++++++ getCertMet ::: "+kmcVO.getCertMet());
|
|
| 1171 |
- System.out.println("+++++++++++++ getIp ::: "+kmcVO.getIp());*/
|
|
| 1172 |
- |
|
| 1173 |
- //KMC 본인인증 정보를 세션에 담아준다. |
|
| 1174 |
- /*AuthCertVO certVO = new AuthCertVO(); |
|
| 1175 |
- certVO.setCertNum(kmcVO.getCertNum()); |
|
| 1176 |
- certVO.setCertDate(kmcVO.getDate()); |
|
| 1177 |
- certVO.setCertDi(kmcVO.getDI()); |
|
| 1178 |
- certVO.setCertPhone(kmcVO.getPhoneNo()); |
|
| 1179 |
- certVO.setCertNation(kmcVO.getNation()); |
|
| 1180 |
- certVO.setCertName(kmcVO.getName()); |
|
| 1181 |
- certVO.setCertResult(kmcVO.getResult()); |
|
| 1182 |
- certVO.setCertType("KMC문자인증");
|
|
| 1183 |
- certVO.setCertIpaddr(kmcVO.getIp()); |
|
| 1184 |
- certVO.setBirthDay(kmcVO.getBirthDay()); |
|
| 1185 |
- certVO.setSexdstnCode(kmcVO.getGender());*/ |
|
| 1186 |
- |
|
| 1187 |
- /*request.getSession().setAttribute("AuthKmcCertVO", certVO);*/
|
|
| 1188 |
- |
|
| 1189 |
- /*System.out.println("++++++++++++ 세션체크22 ::: "+(MberManageVO) session.getAttribute("mberSession"));*/
|
|
| 1190 |
- |
|
| 948 |
+ kmcVO = kmcCertChecker.authCertResult(request, response, model); |
|
| 1191 | 949 |
//KMC 본인인증 로그 insert |
| 1192 | 950 |
AuthCertVO certVO = new AuthCertVO(); |
| 1193 | 951 |
certVO.setMberId(kmcVO.getPlusInfo()); |
... | ... | @@ -6178,5 +5936,298 @@ |
| 6178 | 5936 |
|
| 6179 | 5937 |
return p_response; |
| 6180 | 5938 |
} |
| 5939 |
+ |
|
| 5940 |
+ |
|
| 5941 |
+ |
|
| 5942 |
+ |
|
| 5943 |
+ /** |
|
| 5944 |
+ * 회원가입 본인인증 |
|
| 5945 |
+ * |
|
| 5946 |
+ * @param |
|
| 5947 |
+ * @return |
|
| 5948 |
+ * @throws Exception |
|
| 5949 |
+ */ |
|
| 5950 |
+ @RequestMapping("/web/cop/kmc/authRequestAjax_back.do")
|
|
| 5951 |
+ public String authRequestAjax_back(HttpServletRequest request, HttpSession session, HttpServletResponse response, |
|
| 5952 |
+ ModelMap model , @RequestParam Map<String, Object> commandMap, |
|
| 5953 |
+ @ModelAttribute("searchVO") KmcVO kmcVO) throws Exception {
|
|
| 5954 |
+ |
|
| 5955 |
+ //크롬 SameSite정책 방지 - 도메인이 다른 타사로 이동 시 크롬 정책에 의해 세션 유실이 일어나는 경우가 있는데, 이를 방지하기 위해 samesite 보안을 none처리 |
|
| 5956 |
+ response.setHeader("Set-Cookie", "mberSession=mberSession; Secure; SameSite=None");
|
|
| 5957 |
+ |
|
| 5958 |
+ System.out.println("++++++++++++ 세션체크 ::: "+ session.getAttribute("mberSession"));
|
|
| 5959 |
+ |
|
| 5960 |
+ String errMessage = ""; //에러메세지 |
|
| 5961 |
+ |
|
| 5962 |
+ String rec_cert = ""; // 결과값(암호화) |
|
| 5963 |
+ String certNum = ""; // certNum |
|
| 5964 |
+ |
|
| 5965 |
+ rec_cert = request.getParameter("rec_cert").trim();
|
|
| 5966 |
+ certNum = request.getParameter("certNum").trim();
|
|
| 5967 |
+ |
|
| 5968 |
+ kmcVO.setRecCert(rec_cert); |
|
| 5969 |
+ kmcVO.setCertNum(certNum); |
|
| 5970 |
+ // 파라미터 유효성 검증 |
|
| 5971 |
+ if( rec_cert.length() == 0 || certNum.length() == 0 ){
|
|
| 5972 |
+ errMessage = "비정상"; |
|
| 5973 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 5974 |
+ } |
|
| 5975 |
+ |
|
| 5976 |
+ |
|
| 5977 |
+ // 변수선언 -------------------------------------------------------------------------------------------------------- |
|
| 5978 |
+ String k_certNum = ""; // 파라미터로 수신한 요청번호 |
|
| 5979 |
+ k_certNum = certNum; |
|
| 5980 |
+ String date = ""; // 요청일시 |
|
| 5981 |
+ String CI = ""; // 연계정보(CI) |
|
| 5982 |
+ String DI = ""; // 중복가입확인정보(DI) |
|
| 5983 |
+ String phoneNo = ""; // 휴대폰번호 |
|
| 5984 |
+ String phoneCorp = ""; // 이동통신사 |
|
| 5985 |
+ String birthDay = ""; // 생년월일 |
|
| 5986 |
+ String gender = ""; // 성별 |
|
| 5987 |
+ String nation = ""; // 내국인 |
|
| 5988 |
+ String name = ""; // 성명 |
|
| 5989 |
+ String M_name = ""; // 미성년자 성명 |
|
| 5990 |
+ String M_birthDay = ""; // 미성년자 생년월일 |
|
| 5991 |
+ String M_Gender = ""; // 미성년자 성별 |
|
| 5992 |
+ String M_nation = ""; // 미성년자 내외국인 |
|
| 5993 |
+ String result = ""; // 결과값 |
|
| 5994 |
+ |
|
| 5995 |
+ String certMet = ""; // 인증방법 |
|
| 5996 |
+ String ip = ""; // ip주소 |
|
| 5997 |
+ String plusInfo = ""; |
|
| 5998 |
+ |
|
| 5999 |
+ String encPara = ""; |
|
| 6000 |
+ String encMsg1 = ""; |
|
| 6001 |
+ String encMsg2 = ""; |
|
| 6002 |
+ String msgChk = ""; |
|
| 6003 |
+ |
|
| 6004 |
+ com.icert.comm.secu.IcertSecuManager seed = new com.icert.comm.secu.IcertSecuManager(); |
|
| 6005 |
+ |
|
| 6006 |
+ //02. 1차 복호화 |
|
| 6007 |
+ //수신된 certNum를 이용하여 복호화 |
|
| 6008 |
+ rec_cert = seed.getDec(rec_cert, k_certNum); |
|
| 6009 |
+ |
|
| 6010 |
+ //03. 1차 파싱 |
|
| 6011 |
+ int inf1 = rec_cert.indexOf("/",0);
|
|
| 6012 |
+ int inf2 = rec_cert.indexOf("/",inf1+1);
|
|
| 6013 |
+ |
|
| 6014 |
+ encPara = rec_cert.substring(0,inf1); //암호화된 통합 파라미터 |
|
| 6015 |
+ encMsg1 = rec_cert.substring(inf1+1,inf2); //암호화된 통합 파라미터의 Hash값 |
|
| 6016 |
+ |
|
| 6017 |
+ //04. 위변조 검증 |
|
| 6018 |
+ encMsg2 = seed.getMsg(encPara); |
|
| 6019 |
+ kmcVO.setEncMsg2(encMsg2); |
|
| 6020 |
+ if(encMsg2.equals(encMsg1)){
|
|
| 6021 |
+ msgChk="Y"; |
|
| 6022 |
+ } |
|
| 6023 |
+ |
|
| 6024 |
+ if(!"Y".equals(msgChk)) {
|
|
| 6025 |
+ errMessage = "비정상접근입니다."; |
|
| 6026 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6027 |
+ } |
|
| 6028 |
+ |
|
| 6029 |
+ //05. 2차 복호화 |
|
| 6030 |
+ rec_cert = seed.getDec(encPara, k_certNum); |
|
| 6031 |
+ kmcVO.setRecCert(rec_cert); |
|
| 6032 |
+ //06. 2차 파싱 |
|
| 6033 |
+ int info1 = rec_cert.indexOf("/",0);
|
|
| 6034 |
+ int info2 = rec_cert.indexOf("/",info1+1);
|
|
| 6035 |
+ int info3 = rec_cert.indexOf("/",info2+1);
|
|
| 6036 |
+ int info4 = rec_cert.indexOf("/",info3+1);
|
|
| 6037 |
+ int info5 = rec_cert.indexOf("/",info4+1);
|
|
| 6038 |
+ int info6 = rec_cert.indexOf("/",info5+1);
|
|
| 6039 |
+ int info7 = rec_cert.indexOf("/",info6+1);
|
|
| 6040 |
+ int info8 = rec_cert.indexOf("/",info7+1);
|
|
| 6041 |
+ int info9 = rec_cert.indexOf("/",info8+1);
|
|
| 6042 |
+ int info10 = rec_cert.indexOf("/",info9+1);
|
|
| 6043 |
+ int info11 = rec_cert.indexOf("/",info10+1);
|
|
| 6044 |
+ int info12 = rec_cert.indexOf("/",info11+1);
|
|
| 6045 |
+ int info13 = rec_cert.indexOf("/",info12+1);
|
|
| 6046 |
+ int info14 = rec_cert.indexOf("/",info13+1);
|
|
| 6047 |
+ int info15 = rec_cert.indexOf("/",info14+1);
|
|
| 6048 |
+ int info16 = rec_cert.indexOf("/",info15+1);
|
|
| 6049 |
+ int info17 = rec_cert.indexOf("/",info16+1);
|
|
| 6050 |
+ int info18 = rec_cert.indexOf("/",info17+1);
|
|
| 6051 |
+ |
|
| 6052 |
+ certNum = rec_cert.substring(0,info1); kmcVO.setCertNum(certNum); |
|
| 6053 |
+ date = rec_cert.substring(info1+1,info2); kmcVO.setDate(date); |
|
| 6054 |
+ CI = rec_cert.substring(info2+1,info3); kmcVO.setCI(CI); |
|
| 6055 |
+ phoneNo = rec_cert.substring(info3+1,info4); kmcVO.setPhoneNo(phoneNo); |
|
| 6056 |
+ phoneCorp = rec_cert.substring(info4+1,info5); kmcVO.setPhoneCorp(phoneCorp); |
|
| 6057 |
+ birthDay = rec_cert.substring(info5+1,info6); kmcVO.setBirthDay(birthDay); |
|
| 6058 |
+ gender = rec_cert.substring(info6+1,info7); kmcVO.setGender(gender); |
|
| 6059 |
+ nation = rec_cert.substring(info7+1,info8); kmcVO.setNation(nation); |
|
| 6060 |
+ name = rec_cert.substring(info8+1,info9); kmcVO.setName(name); |
|
| 6061 |
+ result = rec_cert.substring(info9+1,info10); kmcVO.setResult(result); |
|
| 6062 |
+ certMet = rec_cert.substring(info10+1,info11); kmcVO.setCertMet(certMet); |
|
| 6063 |
+ ip = rec_cert.substring(info11+1,info12); kmcVO.setIp(ip); |
|
| 6064 |
+ M_name = rec_cert.substring(info12+1,info13); kmcVO.setMName(M_name); |
|
| 6065 |
+ M_birthDay = rec_cert.substring(info13+1,info14); kmcVO.setMBirthDay(M_birthDay); |
|
| 6066 |
+ M_Gender = rec_cert.substring(info14+1,info15); kmcVO.setMGender(M_Gender); |
|
| 6067 |
+ M_nation = rec_cert.substring(info15+1,info16); kmcVO.setMNation(M_nation); |
|
| 6068 |
+ plusInfo = rec_cert.substring(info16+1,info17); kmcVO.setPlusInfo(plusInfo); |
|
| 6069 |
+ DI = rec_cert.substring(info17+1,info18); kmcVO.setDI(DI); |
|
| 6070 |
+ |
|
| 6071 |
+ //07. CI, DI 복호화 |
|
| 6072 |
+ CI = seed.getDec(CI, k_certNum); kmcVO.setCI(CI); |
|
| 6073 |
+ DI = seed.getDec(DI, k_certNum); kmcVO.setDI(DI); |
|
| 6074 |
+ |
|
| 6075 |
+ if("Y".equals(result)) {
|
|
| 6076 |
+ |
|
| 6077 |
+ } |
|
| 6078 |
+ |
|
| 6079 |
+ //-------------------------------------------------------------- |
|
| 6080 |
+ String regex = ""; |
|
| 6081 |
+ if( certNum.length() == 0 || certNum.length() > 40){
|
|
| 6082 |
+ errMessage = "요청번호 비정상."; |
|
| 6083 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6084 |
+ } |
|
| 6085 |
+ |
|
| 6086 |
+ regex = "[0-9]*"; |
|
| 6087 |
+ if( date.length() != 14 || !paramChk(regex, date) ){
|
|
| 6088 |
+ errMessage = "요청일시"; |
|
| 6089 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6090 |
+ } |
|
| 6091 |
+ |
|
| 6092 |
+ regex = "[A-Z]*"; |
|
| 6093 |
+ if( certMet.length() != 1 || !paramChk(regex, certMet) ){
|
|
| 6094 |
+ errMessage = "본인인증방법 비정상" + certMet; |
|
| 6095 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6096 |
+ } |
|
| 6097 |
+ |
|
| 6098 |
+ |
|
| 6099 |
+ regex = "[0-9]*"; |
|
| 6100 |
+ if( (phoneNo.length() != 10 && phoneNo.length() != 11) || !paramChk(regex, phoneNo) ){
|
|
| 6101 |
+ errMessage = "휴대폰번호 비정상" ; |
|
| 6102 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6103 |
+ } |
|
| 6104 |
+ |
|
| 6105 |
+ regex = "[A-Z]*"; |
|
| 6106 |
+ if( phoneCorp.length() != 3 || !paramChk(regex, phoneCorp) ){
|
|
| 6107 |
+ errMessage = "이동통신사 비정상"; |
|
| 6108 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6109 |
+ } |
|
| 6110 |
+ |
|
| 6111 |
+ regex = "[0-9]*"; |
|
| 6112 |
+ if( birthDay.length() != 8 || !paramChk(regex, birthDay) ){
|
|
| 6113 |
+ errMessage = "생년월일 비정상"; |
|
| 6114 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6115 |
+ } |
|
| 6116 |
+ |
|
| 6117 |
+ regex = "[0-9]*"; |
|
| 6118 |
+ if( gender.length() != 1 || !paramChk(regex, gender) ){
|
|
| 6119 |
+ errMessage = "성별 비정상"; |
|
| 6120 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6121 |
+ } |
|
| 6122 |
+ |
|
| 6123 |
+ regex = "[0-9]*"; |
|
| 6124 |
+ if( nation.length() != 1 || !paramChk(regex, nation) ){
|
|
| 6125 |
+ errMessage = "내/외국인 비정상"; |
|
| 6126 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6127 |
+ } |
|
| 6128 |
+ |
|
| 6129 |
+ regex = "[\\sA-Za-z가-�R.,-]*"; |
|
| 6130 |
+ if( name.length() > 60 || !paramChk(regex, name) ){
|
|
| 6131 |
+ errMessage = "성명 비정상"; |
|
| 6132 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6133 |
+ } |
|
| 6134 |
+ |
|
| 6135 |
+ regex = "[A-Z]*"; |
|
| 6136 |
+ if( result.length() != 1 || !paramChk(regex, result) ){
|
|
| 6137 |
+ errMessage = "결과값 비정상"; |
|
| 6138 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6139 |
+ } |
|
| 6140 |
+ |
|
| 6141 |
+ regex = "[\\sA-Za-z가-?.,-]*"; |
|
| 6142 |
+ if( M_name.length() != 0 ){
|
|
| 6143 |
+ if( M_name.length() > 60 || !paramChk(regex, M_name) ){
|
|
| 6144 |
+ errMessage = "미성년자 성명 비정상"; |
|
| 6145 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6146 |
+ } |
|
| 6147 |
+ } |
|
| 6148 |
+ |
|
| 6149 |
+ regex = "[0-9]*"; |
|
| 6150 |
+ if( M_birthDay.length() != 0 ){
|
|
| 6151 |
+ if( M_birthDay.length() != 8 || !paramChk(regex, M_birthDay) ){
|
|
| 6152 |
+ errMessage = "미성년자 생년월일 비정상"; |
|
| 6153 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6154 |
+ } |
|
| 6155 |
+ } |
|
| 6156 |
+ |
|
| 6157 |
+ regex = "[0-9]*"; |
|
| 6158 |
+ if( M_Gender.length() != 0 ){
|
|
| 6159 |
+ if( M_Gender.length() != 1 || !paramChk(regex, M_Gender) ){
|
|
| 6160 |
+ errMessage = "미성년자 성별 비정상"; |
|
| 6161 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6162 |
+ } |
|
| 6163 |
+ } |
|
| 6164 |
+ |
|
| 6165 |
+ regex = "[0-9]*"; |
|
| 6166 |
+ if( M_nation.length() != 0 ){
|
|
| 6167 |
+ if( M_nation.length() != 1 || !paramChk(regex, M_nation) ){
|
|
| 6168 |
+ errMessage = "미성년자 내/외국인 비정상"; |
|
| 6169 |
+ return returnPage(model , errMessage , kmcVO) ; |
|
| 6170 |
+ } |
|
| 6171 |
+ } |
|
| 6172 |
+ |
|
| 6173 |
+ //본인인증 결과 내용 저장하기. |
|
| 6174 |
+ /*System.out.println("+++++++++++++ getCertNum ::: "+kmcVO.getCertNum());
|
|
| 6175 |
+ System.out.println("+++++++++++++ getDate ::: "+kmcVO.getDate());
|
|
| 6176 |
+ System.out.println("+++++++++++++ getDI ::: "+kmcVO.getDI());
|
|
| 6177 |
+ System.out.println("+++++++++++++ getPhoneNo ::: "+kmcVO.getPhoneNo());
|
|
| 6178 |
+ System.out.println("+++++++++++++ getNation ::: "+kmcVO.getNation());
|
|
| 6179 |
+ System.out.println("+++++++++++++ getName ::: "+kmcVO.getName());
|
|
| 6180 |
+ System.out.println("+++++++++++++ getResult ::: "+kmcVO.getResult());
|
|
| 6181 |
+ System.out.println("+++++++++++++ getCertMet ::: "+kmcVO.getCertMet());
|
|
| 6182 |
+ System.out.println("+++++++++++++ getIp ::: "+kmcVO.getIp());*/
|
|
| 6183 |
+ |
|
| 6184 |
+ //KMC 본인인증 정보를 세션에 담아준다. |
|
| 6185 |
+ /*AuthCertVO certVO = new AuthCertVO(); |
|
| 6186 |
+ certVO.setCertNum(kmcVO.getCertNum()); |
|
| 6187 |
+ certVO.setCertDate(kmcVO.getDate()); |
|
| 6188 |
+ certVO.setCertDi(kmcVO.getDI()); |
|
| 6189 |
+ certVO.setCertPhone(kmcVO.getPhoneNo()); |
|
| 6190 |
+ certVO.setCertNation(kmcVO.getNation()); |
|
| 6191 |
+ certVO.setCertName(kmcVO.getName()); |
|
| 6192 |
+ certVO.setCertResult(kmcVO.getResult()); |
|
| 6193 |
+ certVO.setCertType("KMC문자인증");
|
|
| 6194 |
+ certVO.setCertIpaddr(kmcVO.getIp()); |
|
| 6195 |
+ certVO.setBirthDay(kmcVO.getBirthDay()); |
|
| 6196 |
+ certVO.setSexdstnCode(kmcVO.getGender());*/ |
|
| 6197 |
+ |
|
| 6198 |
+ /*request.getSession().setAttribute("AuthKmcCertVO", certVO);*/
|
|
| 6199 |
+ |
|
| 6200 |
+ /*System.out.println("++++++++++++ 세션체크22 ::: "+(MberManageVO) session.getAttribute("mberSession"));*/
|
|
| 6201 |
+ |
|
| 6202 |
+ //KMC 본인인증 로그 insert |
|
| 6203 |
+ AuthCertVO certVO = new AuthCertVO(); |
|
| 6204 |
+ certVO.setMberId(kmcVO.getPlusInfo()); |
|
| 6205 |
+ certVO.setCertNum(kmcVO.getCertNum()); |
|
| 6206 |
+ certVO.setCertDate(kmcVO.getDate()); |
|
| 6207 |
+ certVO.setCertDi(kmcVO.getDI()); |
|
| 6208 |
+ certVO.setCertPhone(kmcVO.getPhoneNo()); |
|
| 6209 |
+ certVO.setCertNation(kmcVO.getNation()); |
|
| 6210 |
+ certVO.setCertName(kmcVO.getName()); |
|
| 6211 |
+ certVO.setCertResult(kmcVO.getResult()); |
|
| 6212 |
+ certVO.setCertType("KMC_회원가입 인증");
|
|
| 6213 |
+ certVO.setCertIpaddr(kmcVO.getIp()); |
|
| 6214 |
+ certVO.setBirthDay(kmcVO.getBirthDay()); |
|
| 6215 |
+ certVO.setSexdstnCode(kmcVO.getGender()); |
|
| 6216 |
+ |
|
| 6217 |
+ //디비 테이블에 저장하기 |
|
| 6218 |
+ mberManageService.insertCertInfoLog(certVO); |
|
| 6219 |
+ |
|
| 6220 |
+ kmcVO.setIdx(certVO.getIdx()); //본인인증 로그 Idx - 로그 insert 후 idx selectKey |
|
| 6221 |
+ model.addAttribute("kmcVO", kmcVO);
|
|
| 6222 |
+ return "web/cop/kmc/authRequestAjax"; |
|
| 6223 |
+ } |
|
| 6224 |
+ |
|
| 6225 |
+ |
|
| 6226 |
+ |
|
| 6227 |
+ |
|
| 6228 |
+ |
|
| 6229 |
+ |
|
| 6230 |
+ |
|
| 6231 |
+ |
|
| 6181 | 6232 |
} |
| 6182 | 6233 |
|
--- src/main/java/itn/let/uat/uia/web/KmcCertChecker.java
+++ src/main/java/itn/let/uat/uia/web/KmcCertChecker.java
... | ... | @@ -1,23 +1,34 @@ |
| 1 | 1 |
package itn.let.uat.uia.web; |
| 2 | 2 |
|
| 3 |
+import java.io.BufferedReader; |
|
| 4 |
+import java.io.IOException; |
|
| 5 |
+import java.io.InputStreamReader; |
|
| 6 |
+import java.io.OutputStream; |
|
| 7 |
+import java.net.HttpURLConnection; |
|
| 8 |
+import java.net.URL; |
|
| 3 | 9 |
import java.text.SimpleDateFormat; |
| 4 | 10 |
import java.util.Calendar; |
| 5 |
-import java.util.Map; |
|
| 6 | 11 |
import java.util.Random; |
| 7 | 12 |
|
| 8 | 13 |
import javax.annotation.Resource; |
| 9 | 14 |
import javax.servlet.http.HttpServletRequest; |
| 15 |
+import javax.servlet.http.HttpServletResponse; |
|
| 10 | 16 |
|
| 11 |
-import org.apache.commons.lang3.StringUtils; |
|
| 17 |
+import org.json.simple.JSONObject; |
|
| 18 |
+import org.json.simple.parser.JSONParser; |
|
| 19 |
+import org.json.simple.parser.ParseException; |
|
| 12 | 20 |
import org.springframework.stereotype.Component; |
| 13 | 21 |
import org.springframework.ui.ModelMap; |
| 22 |
+import org.springframework.web.servlet.FlashMap; |
|
| 23 |
+import org.springframework.web.servlet.FlashMapManager; |
|
| 24 |
+import org.springframework.web.servlet.support.RequestContextUtils; |
|
| 14 | 25 |
|
| 15 | 26 |
import com.icert.comm.secu.IcertSecuManager; |
| 16 | 27 |
|
| 17 | 28 |
import itn.let.cert.phone.service.CertPhoneService; |
| 18 | 29 |
import itn.let.cert.phone.service.MberCertPhoneVO; |
| 30 |
+import itn.let.mjo.pay.service.KmcVO; |
|
| 19 | 31 |
import itn.let.uat.uia.service.AuthCertVO; |
| 20 |
-import itn.let.uss.umt.service.MberManageVO; |
|
| 21 | 32 |
|
| 22 | 33 |
@Component("KmcCertChecker")
|
| 23 | 34 |
public class KmcCertChecker {
|
... | ... | @@ -64,11 +75,13 @@ |
| 64 | 75 |
String tr_add = "N"; // IFrame사용여부 |
| 65 | 76 |
|
| 66 | 77 |
//01. 한국모바일인증(주) 암호화 모듈 선언 |
| 67 |
- IcertSecuManager seed = new IcertSecuManager(); |
|
| 78 |
+// IcertSecuManager seed = new IcertSecuManager(); |
|
| 79 |
+ com.icert.comm.secu.IcertSecuManager seed = new com.icert.comm.secu.IcertSecuManager(); |
|
| 68 | 80 |
|
| 69 | 81 |
//02. 1차 암호화 (tr_cert 데이터변수 조합 후 암호화) |
| 70 | 82 |
String enc_tr_cert = ""; |
| 71 |
- tr_cert = cpId +"/"+ urlCode +"/"+ certNum +"/"+ date +"/"+ certMet +"/"+ birthDay +"/"+ gender +"/"+ name +"/"+ phoneNo +"/"+ phoneCorp +"/"+ nation +"/"+ plusInfo +"/"+ extendVar; |
|
| 83 |
+// tr_cert = cpId +"/"+ urlCode +"/"+ certNum +"/"+ date +"/"+ certMet +"/"+ birthDay +"/"+ gender +"/"+ name +"/"+ phoneNo +"/"+ phoneCorp +"/"+ nation +"/"+ plusInfo +"/"+ extendVar; |
|
| 84 |
+ tr_cert = cpId +"/"+ urlCode +"/"+ certNum +"/"+ date +"/"+ certMet +"///////"+ plusInfo +"/"+ extendVar; |
|
| 72 | 85 |
enc_tr_cert = seed.getEnc(tr_cert, ""); |
| 73 | 86 |
|
| 74 | 87 |
//03. 1차 암호화 데이터에 대한 위변조 검증값 생성 (HMAC) |
... | ... | @@ -85,6 +98,292 @@ |
| 85 | 98 |
authCertVO.setTr_add(tr_add); |
| 86 | 99 |
|
| 87 | 100 |
return authCertVO; |
| 101 |
+ } |
|
| 102 |
+ |
|
| 103 |
+ public KmcVO authCertResult( |
|
| 104 |
+ HttpServletRequest request |
|
| 105 |
+ , HttpServletResponse response |
|
| 106 |
+ , ModelMap model |
|
| 107 |
+ ) throws IOException {
|
|
| 108 |
+ |
|
| 109 |
+ //크롬 SameSite정책 방지 - 도메인이 다른 타사로 이동 시 크롬 정책에 의해 세션 유실이 일어나는 경우가 있는데, 이를 방지하기 위해 samesite 보안을 none처리 |
|
| 110 |
+ response.setHeader("Set-Cookie", "mberSession=mberSession; Secure; SameSite=None");
|
|
| 111 |
+ |
|
| 112 |
+ KmcVO kmcVO = new KmcVO(); //return VO |
|
| 113 |
+ |
|
| 114 |
+ // 변수 ------------------------------------------------------------------------------------------------------------- |
|
| 115 |
+ String api_token = ""; // 토큰값(암호화) |
|
| 116 |
+ String api_certNum = ""; // 요청번호(암호화) |
|
| 117 |
+ |
|
| 118 |
+ String message = ""; // JSON 전문 |
|
| 119 |
+ String result_cd = ""; // JSON 결과코드 |
|
| 120 |
+ String result_msg = ""; // JSON 결과-상세 |
|
| 121 |
+ String strResult = ""; // JSON 결과 |
|
| 122 |
+ String apiRecCert = ""; // JSON 전송 데이터 |
|
| 123 |
+ String apiCertNum = ""; // JSON 전송 데이터 |
|
| 124 |
+ |
|
| 125 |
+ String rec_cert = ""; // 결과수신DATA |
|
| 126 |
+ String k_certNum = ""; // 파라미터로 수신한 요청번호 |
|
| 127 |
+ String certNum = ""; // 요청번호 |
|
| 128 |
+ String date = ""; // 요청일시 |
|
| 129 |
+ String CI = ""; // 연계정보(CI) |
|
| 130 |
+ String DI = ""; // 중복가입확인정보(DI) |
|
| 131 |
+ String phoneNo = ""; // 휴대폰번호 |
|
| 132 |
+ String phoneCorp = ""; // 이동통신사 |
|
| 133 |
+ String birth = ""; // 생년월일 |
|
| 134 |
+ String gender = ""; // 성별 |
|
| 135 |
+ String nation = ""; // 내국인 |
|
| 136 |
+ String name = ""; // 성명 |
|
| 137 |
+ String reserve1 = ""; // 예비필드 |
|
| 138 |
+ String reserve2 = ""; // 예비필드 |
|
| 139 |
+ String reserve3 = ""; // 예비필드 |
|
| 140 |
+ String reserve4 = ""; // 예비필드 |
|
| 141 |
+ String result = ""; // 결과값 |
|
| 142 |
+ |
|
| 143 |
+ String certMet = ""; // 인증방법 |
|
| 144 |
+ String ip = ""; // ip주소 |
|
| 145 |
+ String plusInfo = ""; |
|
| 146 |
+ |
|
| 147 |
+ String encPara = ""; |
|
| 148 |
+ String encMsg1 = ""; |
|
| 149 |
+ String encMsg2 = ""; |
|
| 150 |
+ String msgChk = ""; |
|
| 151 |
+ //----------------------------------------------------------------------------------------------------------------- |
|
| 152 |
+ try{
|
|
| 153 |
+ // Parameter 수신 -------------------------------------------------------------------- |
|
| 154 |
+ api_token = request.getParameter("apiToken").trim();
|
|
| 155 |
+ api_certNum = request.getParameter("certNum");
|
|
| 156 |
+ |
|
| 157 |
+ // 파라미터 유효성 검증 |
|
| 158 |
+ if( api_token.length() == 0 ){
|
|
| 159 |
+ goErrorPage("토큰값 비정상", request, response);
|
|
| 160 |
+ return kmcVO; |
|
| 161 |
+ } |
|
| 162 |
+ if( api_certNum.length() == 0 ){
|
|
| 163 |
+ goErrorPage("요청번호 비정상", request, response);
|
|
| 164 |
+ return kmcVO; |
|
| 165 |
+ } |
|
| 166 |
+ |
|
| 167 |
+ //현재시각 세팅(YYYYMMDDHI24MISS) |
|
| 168 |
+ Calendar today = Calendar.getInstance(); |
|
| 169 |
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
| 170 |
+ String api_date = sdf.format(today.getTime()); |
|
| 171 |
+ |
|
| 172 |
+ //01. 암호화 모듈 (jar) Loading |
|
| 173 |
+ com.icert.comm.secu.IcertSecuManager seed = new com.icert.comm.secu.IcertSecuManager(); |
|
| 174 |
+ |
|
| 175 |
+ //api_token, api_certNum 복호화 |
|
| 176 |
+ api_token = seed.getDec(api_token, ""); |
|
| 177 |
+ api_certNum = seed.getDec(api_certNum, ""); |
|
| 178 |
+ |
|
| 179 |
+ // 파라미터 유효성 검증 |
|
| 180 |
+ if( api_token.length() == 0 ){
|
|
| 181 |
+ goErrorPage("토큰값 비정상(복호화 후)", request, response);
|
|
| 182 |
+ return kmcVO; |
|
| 183 |
+ } |
|
| 184 |
+ if( api_certNum.length() == 0 ){
|
|
| 185 |
+ goErrorPage("요청번호 비정상(복호화 후)", request, response);
|
|
| 186 |
+ return kmcVO; |
|
| 187 |
+ } |
|
| 188 |
+ |
|
| 189 |
+ // 1. URL 설정 |
|
| 190 |
+ String serverURL = "https://www.kmcert.com/kmcis/api/kmcisToken_api.jsp"; |
|
| 191 |
+ |
|
| 192 |
+ // 2. 연결 생성 |
|
| 193 |
+ URL url = new URL(serverURL); |
|
| 194 |
+ |
|
| 195 |
+ // 3. HttpURLConnection 객체 생성. |
|
| 196 |
+ HttpURLConnection con = null; |
|
| 197 |
+ OutputStream wr = null; |
|
| 198 |
+ BufferedReader bufferedReader = null; |
|
| 199 |
+ |
|
| 200 |
+ // 4. URL 연결 (웹페이지 URL 연결.) |
|
| 201 |
+ con = (HttpURLConnection)url.openConnection(); |
|
| 202 |
+ |
|
| 203 |
+ con.setConnectTimeout(20000); // TimeOut 시간 (서버 접속시 연결 시간 - 20초) |
|
| 204 |
+ con.setReadTimeout(20000); // TimeOut 시간 (Read시 연결 시간 - 20초) |
|
| 205 |
+ con.setDoOutput(true); // OutputStream으로 POST 데이터를 넘겨주겠다는 옵션. |
|
| 206 |
+ |
|
| 207 |
+ con.setRequestProperty("Content-Type", "application/json;charset=utf-8"); // 타입설정(application/json) 형식으로 전송 (Request Body 전달시 application/json로 서버에 전달.)
|
|
| 208 |
+ con.setRequestProperty("Accept", "application/json"); // 서버 Response Data를 JSON 형식의 타입으로 요청.
|
|
| 209 |
+ con.setRequestMethod("POST"); // 요청 방식 선택 (POST)
|
|
| 210 |
+ |
|
| 211 |
+ // 5. JSON 전문 구성 |
|
| 212 |
+ |
|
| 213 |
+ JSONObject jsonData = new JSONObject(); |
|
| 214 |
+ |
|
| 215 |
+ jsonData.put("apiToken", api_token);
|
|
| 216 |
+ jsonData.put("apiDate", api_date);
|
|
| 217 |
+ |
|
| 218 |
+ message = jsonData.toString(); |
|
| 219 |
+ |
|
| 220 |
+ // 6. 전송 |
|
| 221 |
+ // Request Body에 Data를 담기위해 OutputStream 객체를 생성. |
|
| 222 |
+ wr = con.getOutputStream(); |
|
| 223 |
+ |
|
| 224 |
+ // Request Body에 Data 셋팅.(한글깨짐 방지를 위해 utf-8인코딩 처리 |
|
| 225 |
+ wr.write(message.getBytes("utf-8"));
|
|
| 226 |
+ wr.flush(); |
|
| 227 |
+ wr.close(); |
|
| 228 |
+ |
|
| 229 |
+ // 실제 서버로 Request 요청 하는 부분. (응답 코드를 받는다. 200 성공, 나머지 에러) |
|
| 230 |
+ int responseCode = con.getResponseCode(); |
|
| 231 |
+ |
|
| 232 |
+ // 4. 결과 수신 |
|
| 233 |
+ if(responseCode == 200){
|
|
| 234 |
+ bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8")); |
|
| 235 |
+ }else{
|
|
| 236 |
+ bufferedReader = new BufferedReader(new InputStreamReader(con.getErrorStream(), "UTF-8")); |
|
| 237 |
+ } |
|
| 238 |
+ |
|
| 239 |
+ if(bufferedReader != null){
|
|
| 240 |
+ |
|
| 241 |
+ StringBuilder stringBuilder = new StringBuilder(); |
|
| 242 |
+ String line = ""; |
|
| 243 |
+ |
|
| 244 |
+ while((line = bufferedReader.readLine()) != null){
|
|
| 245 |
+ stringBuilder.append(line); |
|
| 246 |
+ } |
|
| 247 |
+ bufferedReader.close(); |
|
| 248 |
+ |
|
| 249 |
+ String stringRet = stringBuilder.toString(); |
|
| 250 |
+ |
|
| 251 |
+ // 5. 넘어온 문자열을 JSON 객체로 변환 |
|
| 252 |
+ JSONParser jsonParser = new JSONParser(); |
|
| 253 |
+ |
|
| 254 |
+ //JSON데이터를 넣어 JSON Object 로 만들어 준다. |
|
| 255 |
+ JSONObject jsonObj = (JSONObject)jsonParser.parse(stringRet); |
|
| 256 |
+ |
|
| 257 |
+ // 6. JSON 객체에서 데이터 가져오기 |
|
| 258 |
+ |
|
| 259 |
+ if(jsonObj.get("result_cd") != null){
|
|
| 260 |
+ result_cd = jsonObj.get("result_cd").toString();
|
|
| 261 |
+ if("APR01".equals(result_cd)){
|
|
| 262 |
+ //통신성공 |
|
| 263 |
+ strResult = "Y"; |
|
| 264 |
+ rec_cert = jsonObj.get("apiRecCert").toString();
|
|
| 265 |
+ k_certNum = jsonObj.get("apiCertNum").toString();
|
|
| 266 |
+ }else if("APR02".equals(result_cd)){
|
|
| 267 |
+ //실패 - Token Expire |
|
| 268 |
+ strResult = "N"; |
|
| 269 |
+ result_msg = "실패 - Token Expire"; |
|
| 270 |
+ }else if("APR03".equals(result_cd)){
|
|
| 271 |
+ //실패 - Token Not Found |
|
| 272 |
+ strResult = "N"; |
|
| 273 |
+ result_msg = "실패 - Token Not Found"; |
|
| 274 |
+ }else if("APR04".equals(result_cd)){
|
|
| 275 |
+ //실패 - API 요청일시 길이 오류 |
|
| 276 |
+ strResult = "N"; |
|
| 277 |
+ result_msg = "실패 - API 요청일시 길이 오류"; |
|
| 278 |
+ }else if("APR05".equals(result_cd)){
|
|
| 279 |
+ //실패 - API 토큰 길이 오류 |
|
| 280 |
+ strResult = "N"; |
|
| 281 |
+ result_msg = "실패 - API 토큰 길이 오류"; |
|
| 282 |
+ }else if("APR06".equals(result_cd)){
|
|
| 283 |
+ //실패 - 결과전송 재요청(3회 제한) |
|
| 284 |
+ strResult = "N"; |
|
| 285 |
+ result_msg = "실패 - 결과전송 재요청(3회 제한)"; |
|
| 286 |
+ } |
|
| 287 |
+ }else{
|
|
| 288 |
+ //JSON 결과코드 에러 |
|
| 289 |
+ strResult = "F"; |
|
| 290 |
+ } |
|
| 291 |
+ }else{ //timeout except 처리
|
|
| 292 |
+ strResult = "F"; |
|
| 293 |
+ } |
|
| 294 |
+ |
|
| 295 |
+ // 파라미터 유효성 검증 |
|
| 296 |
+ if(!strResult.equals("Y")){
|
|
| 297 |
+ goErrorPage("결과값 비정상, 결과코드["+result_cd+"], "+"상세내용["+result_msg+"]", request, response);
|
|
| 298 |
+ return kmcVO; |
|
| 299 |
+ } |
|
| 300 |
+ |
|
| 301 |
+ //02. 1차 복호화 |
|
| 302 |
+ rec_cert = seed.getDec(rec_cert, k_certNum); |
|
| 303 |
+ |
|
| 304 |
+ //03. 1차 파싱 |
|
| 305 |
+ int inf1 = rec_cert.indexOf("/",0);
|
|
| 306 |
+ int inf2 = rec_cert.indexOf("/",inf1+1);
|
|
| 307 |
+ |
|
| 308 |
+ encPara = rec_cert.substring(0,inf1); //암호화된 통합 파라미터 |
|
| 309 |
+ encMsg1 = rec_cert.substring(inf1+1,inf2); //암호화된 통합 파라미터의 Hash값 |
|
| 310 |
+ |
|
| 311 |
+ //04. 위변조 검증 |
|
| 312 |
+ encMsg2 = seed.getMsg(encPara); |
|
| 313 |
+ |
|
| 314 |
+ if(encMsg2.equals(encMsg1)){
|
|
| 315 |
+ msgChk="Y"; |
|
| 316 |
+ } |
|
| 317 |
+ |
|
| 318 |
+ if(msgChk.equals("N")){
|
|
| 319 |
+ goErrorPage("비정상적인 접근입니다.!!", request, response);
|
|
| 320 |
+ return kmcVO; |
|
| 321 |
+ } |
|
| 322 |
+ |
|
| 323 |
+ //05. 2차 복호화 |
|
| 324 |
+ rec_cert = seed.getDec(encPara, ""); |
|
| 325 |
+ |
|
| 326 |
+ //06. 2차 파싱 |
|
| 327 |
+ int info1 = rec_cert.indexOf("/",0);
|
|
| 328 |
+ int info2 = rec_cert.indexOf("/",info1+1);
|
|
| 329 |
+ int info3 = rec_cert.indexOf("/",info2+1);
|
|
| 330 |
+ int info4 = rec_cert.indexOf("/",info3+1);
|
|
| 331 |
+ int info5 = rec_cert.indexOf("/",info4+1);
|
|
| 332 |
+ int info6 = rec_cert.indexOf("/",info5+1);
|
|
| 333 |
+ int info7 = rec_cert.indexOf("/",info6+1);
|
|
| 334 |
+ int info8 = rec_cert.indexOf("/",info7+1);
|
|
| 335 |
+ int info9 = rec_cert.indexOf("/",info8+1);
|
|
| 336 |
+ int info10 = rec_cert.indexOf("/",info9+1);
|
|
| 337 |
+ int info11 = rec_cert.indexOf("/",info10+1);
|
|
| 338 |
+ int info12 = rec_cert.indexOf("/",info11+1);
|
|
| 339 |
+ int info13 = rec_cert.indexOf("/",info12+1);
|
|
| 340 |
+ int info14 = rec_cert.indexOf("/",info13+1);
|
|
| 341 |
+ int info15 = rec_cert.indexOf("/",info14+1);
|
|
| 342 |
+ int info16 = rec_cert.indexOf("/",info15+1);
|
|
| 343 |
+ int info17 = rec_cert.indexOf("/",info16+1);
|
|
| 344 |
+ int info18 = rec_cert.indexOf("/",info17+1);
|
|
| 345 |
+ |
|
| 346 |
+ certNum = rec_cert.substring(0,info1); |
|
| 347 |
+ date = rec_cert.substring(info1+1,info2); |
|
| 348 |
+ CI = rec_cert.substring(info2+1,info3); |
|
| 349 |
+ phoneNo = rec_cert.substring(info3+1,info4); |
|
| 350 |
+ phoneCorp = rec_cert.substring(info4+1,info5); |
|
| 351 |
+ birth = rec_cert.substring(info5+1,info6); |
|
| 352 |
+ gender = rec_cert.substring(info6+1,info7); |
|
| 353 |
+ nation = rec_cert.substring(info7+1,info8); |
|
| 354 |
+ name = rec_cert.substring(info8+1,info9); |
|
| 355 |
+ result = rec_cert.substring(info9+1,info10); |
|
| 356 |
+ certMet = rec_cert.substring(info10+1,info11); |
|
| 357 |
+ ip = rec_cert.substring(info11+1,info12); |
|
| 358 |
+ reserve1 = rec_cert.substring(info12+1,info13); |
|
| 359 |
+ reserve2 = rec_cert.substring(info13+1,info14); |
|
| 360 |
+ reserve3 = rec_cert.substring(info14+1,info15); |
|
| 361 |
+ reserve4 = rec_cert.substring(info15+1,info16); |
|
| 362 |
+ plusInfo = rec_cert.substring(info16+1,info17); |
|
| 363 |
+ DI = rec_cert.substring(info17+1,info18); |
|
| 364 |
+ |
|
| 365 |
+ //07. CI, DI 복호화 |
|
| 366 |
+ CI = seed.getDec(CI, ""); |
|
| 367 |
+ DI = seed.getDec(DI, ""); |
|
| 368 |
+ |
|
| 369 |
+ // ---------------------------------------------------------------------------------- |
|
| 370 |
+ |
|
| 371 |
+ }catch(StringIndexOutOfBoundsException ex){
|
|
| 372 |
+ goErrorPage("StringIndexOutOfBoundsException", request, response);
|
|
| 373 |
+ }catch(NullPointerException ex){
|
|
| 374 |
+ goErrorPage("NullPointerException", request, response);
|
|
| 375 |
+ }catch(NumberFormatException ex){
|
|
| 376 |
+ goErrorPage("NumberFormatException", request, response);
|
|
| 377 |
+ }catch(IllegalStateException ex){
|
|
| 378 |
+ goErrorPage("IllegalStateException", request, response);
|
|
| 379 |
+ }catch(IndexOutOfBoundsException ex){
|
|
| 380 |
+ goErrorPage("IndexOutOfBoundsException", request, response);
|
|
| 381 |
+ } catch (IOException e) {
|
|
| 382 |
+ goErrorPage("IOException", request, response);
|
|
| 383 |
+ } catch (ParseException e) {
|
|
| 384 |
+ goErrorPage("ParseException", request, response);
|
|
| 385 |
+ } |
|
| 386 |
+ return kmcVO; |
|
| 88 | 387 |
} |
| 89 | 388 |
|
| 90 | 389 |
|
... | ... | @@ -144,5 +443,12 @@ |
| 144 | 443 |
return mberCertPhoneVO; |
| 145 | 444 |
} |
| 146 | 445 |
|
| 446 |
+ private void goErrorPage(String msg, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
| 447 |
+ FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request); |
|
| 448 |
+ flashMap.put("msg", msg);
|
|
| 449 |
+ FlashMapManager flashMapManager = RequestContextUtils.getFlashMapManager(request); |
|
| 450 |
+ flashMapManager.saveOutputFlashMap(flashMap, request, response); |
|
| 451 |
+ response.sendRedirect("/web/cert/log/kmcErrorPage.do");
|
|
| 452 |
+ } |
|
| 147 | 453 |
|
| 148 | 454 |
} |
+++ src/main/webapp/WEB-INF/jsp/web/cop/kmc/certResultError.jsp
... | ... | @@ -0,0 +1,22 @@ |
| 1 | +<%@ page contentType="text/html; charset=utf-8"%> | |
| 2 | +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | |
| 3 | +<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%> | |
| 4 | +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> | |
| 5 | +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> | |
| 6 | +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> | |
| 7 | +<script src="<c:url value='/js/jquery.js' />"></script> | |
| 8 | +<html> | |
| 9 | + <head> | |
| 10 | + <meta name="robots" content="noindex"> | |
| 11 | + | |
| 12 | + <script language=javascript> | |
| 13 | + $( document ).ready(function() { | |
| 14 | + alert("${msg}") | |
| 15 | + self.close(); | |
| 16 | + }); | |
| 17 | + </script> | |
| 18 | + | |
| 19 | + </head> | |
| 20 | + <body> | |
| 21 | + </body> | |
| 22 | +</html> (No newline at end of file) |
--- src/main/webapp/WEB-INF/jsp/web/login/usrCheckTerms.jsp
+++ src/main/webapp/WEB-INF/jsp/web/login/usrCheckTerms.jsp
... | ... | @@ -634,6 +634,7 @@ |
| 634 | 634 |
<input type="hidden" name="tr_cert" id="tr_cert" value = "${tr_cert}">
|
| 635 | 635 |
<input type="hidden" name="tr_url" id="tr_url" value = "${tr_url}">
|
| 636 | 636 |
<input type="hidden" name="tr_add" id="tr_add" value = "${tr_add}">
|
| 637 |
+ <input type="hidden" name="tr_ver" value = "V2"> |
|
| 637 | 638 |
</form> |
| 638 | 639 |
<form name="arsForm" method="post" action="#"> |
| 639 | 640 |
<input type="hidden" id="phoneNumber" name="phoneNumber" value = ""> |
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?