Merge branch 'tolag3'

인증 개발
This commit is contained in:
leejunho 2024-11-25 12:46:43 +09:00
parent a9865ce89c
commit 0cc72f0c28
15 changed files with 940 additions and 116 deletions

View File

@ -0,0 +1,26 @@
package kcc.let.uat.uia.service;
import java.io.Serializable;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class SocialCertVO implements Serializable{
private static final long serialVersionUID = 1L;
private String name;
private String phone;
private String birth;
private String receiptID;
private String status;
}

View File

@ -1,8 +1,15 @@
package kcc.let.uat.uia.web;
import org.apache.poi.poifs.crypt.Decryptor;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@ -11,6 +18,11 @@ import com.barocert.BarocertException;
import com.barocert.kakaocert.KakaocertService;
import com.barocert.navercert.NavercertService;
import kcc.let.uat.uia.service.SocialCertVO;
import seed.utils.SeedUtils;
import seed.utils.kCertDecryptor;
import seed.utils.nCertDecryptor;
/**
* @packageName : kcc.let.uat.uia.web
* @fileName : SocialCertController.java
@ -22,6 +34,17 @@ import com.barocert.navercert.NavercertService;
* -----------------------------------------------------------
* 2024.11.21 JunHo Lee 최초 생성
*/
/**
* @packageName : kcc.let.uat.uia.web
* @fileName : SocialCertController.java
* @author : JunHo Lee
* @date : 2024.11.21
* @description :
* ===========================================================
* DATE AUTHOR NOTE
* -----------------------------------------------------------
* 2024.11.21 JunHo Lee 최초 생성
*/
@Controller
public class SocialCertController {
@ -37,29 +60,60 @@ public class SocialCertController {
@Value("#{KAKAO_CONFIG.ClientCode}")
private String KakaoClientCode;
/**
* 본인인증 요청
*
* @param clientCode
* 이용기관코드
* @param identity
* 본인인증 요청정보
* @return ResponseVerify
* 본인인증 요청 응답정보
* @throws BarocertException
*/
@RequestMapping(value = "/web/user/cert/nCert.do")
public String requestIdentity(Model m) throws BarocertException {
* @methodName : nCertStep1
* @author : JunHo Lee
* @date : 2024.11.21
* @description :
* @param m
* @return
* @throws Exception
*/
@RequestMapping(value = "/web/user/cert/nCertStep1.do")
public String nCertStep1(Model m) throws Exception {
return "uat/uia/NCertStep1";
}
/**
* @methodName : kCertStep1
* @author : JunHo Lee
* @date : 2024.11.21
* @description :
* @param m
* @return
* @throws Exception
*/
@RequestMapping(value = "/web/user/cert/kCertStep1.do")
public String kCertStep1(Model m) throws Exception {
return "uat/uia/KCertStep1";
}
/**
* @methodName : nCertStep2
* @author : JunHo Lee
* @date : 2024.11.21
* @description :
* @param m
* @param socialCertVO
* @return
* @throws BarocertException
*/
@RequestMapping(value = "/web/user/cert/nCertStep2.do")
public String nCertStep2(Model m, SocialCertVO socialCertVO) throws BarocertException {
// 본인인증 요청 정보 객체
com.barocert.navercert.identity.Identity identity = new com.barocert.navercert.identity.Identity();
// 수신자 휴대폰번호 - 11자 (하이픈 제외)
identity.setReceiverHP(navercertService.encrypt("01030266269"));
identity.setReceiverHP(navercertService.encrypt(socialCertVO.getPhone()));
// 수신자 성명 - 80자
identity.setReceiverName(navercertService.encrypt("이준호"));
identity.setReceiverName(navercertService.encrypt(socialCertVO.getName()));
// 수신자 생년월일 - 8자 (yyyyMMdd)
identity.setReceiverBirthday(navercertService.encrypt("19890202"));
identity.setReceiverBirthday(navercertService.encrypt(socialCertVO.getBirth()));
// 고객센터 연락처 - 최대 12자
identity.setCallCenterNum("1600-9854");
@ -73,74 +127,41 @@ public class SocialCertController {
try {
com.barocert.navercert.identity.IdentityReceipt request = navercertService.requestIdentity(NaverClientCode, identity);
// Boolean test = navercertService.isUseStaticIP();
System.out.println("ReceiptID :: " + request.getReceiptID());
System.out.println("Scheme :: " + request.getScheme());
System.out.println("MarketUrl :: " + request.getMarketUrl());
/**
* 본인인증 서명검증
* 인증되었을경우 State : 1
* 인증안되었을경우 State : 0
*/
// if(status.getState() == 0) {
//
// }else if(status.getState() == 1) {
//
// }
//서명이 되지 않았을경우
com.barocert.navercert.identity.IdentityStatus status = navercertService.getIdentityStatus(NaverClientCode, request.getReceiptID());
//서명이 되었을경우
com.barocert.navercert.identity.IdentityStatus status2 = navercertService.getIdentityStatus(NaverClientCode, request.getReceiptID());
com.barocert.navercert.identity.IdentityResult result = navercertService.verifyIdentity(NaverClientCode, request.getReceiptID());
System.out.println("Ci :: " + result.getCi());
System.out.println("ReceiptID :: " + result.getReceiptID());
System.out.println("ReceiverDay :: " + result.getReceiverDay());
System.out.println("ReceiverEmail :: " + result.getReceiverEmail());
System.out.println("ReceiverForeign :: " + result.getReceiverForeign());
System.out.println("ReceiverGender :: " + result.getReceiverGender());
System.out.println("ReceiverHP :: " + result.getReceiverHP());
System.out.println("ReceiverName :: " + result.getReceiverName());
System.out.println("ReceiverYear :: " + result.getReceiverYear());
System.out.println("SignedData :: " + result.getSignedData());
System.out.println("State :: " + result.getState());
m.addAttribute("result", result);
m.addAttribute("request", request);
} catch (BarocertException ne) {
m.addAttribute("Exception", ne);
return "exception";
m.addAttribute("Exception", "요청에 실패했습니다.");
return "redirect:/web/user/cert/nCertStep1.do";
}
return "uat/uia/NCert";
return "uat/uia/NCertStep2";
}
// @RequestMapping(value = "navercert/requestIdentity", method = RequestMethod.GET)
@RequestMapping(value = "/web/user/cert/kCert.do")
public String requestIdentity_k(Model m) throws BarocertException {
/**
* @methodName : kCertStep2
* @author : JunHo Lee
* @date : 2024.11.21
* @description :
* @param m
* @return
* @throws BarocertException
*/
@RequestMapping(value = "/web/user/cert/kCertStep2.do")
public String kCertStep2(Model m, SocialCertVO socialCertVO) throws BarocertException {
// 본인인증 요청 정보 객체
com.barocert.kakaocert.identity.Identity identity = new com.barocert.kakaocert.identity.Identity();
// 수신자 휴대폰번호 - 11자 (하이픈 제외)
identity.setReceiverHP(kakaocertService.encrypt("01012341234"));
identity.setReceiverHP(kakaocertService.encrypt(socialCertVO.getPhone()));
// 수신자 성명 - 80자
identity.setReceiverName(kakaocertService.encrypt("홍길동"));
identity.setReceiverName(kakaocertService.encrypt(socialCertVO.getName()));
// 수신자 생년월일 - 8자 (yyyyMMdd)
identity.setReceiverBirthday(kakaocertService.encrypt("19700101"));
identity.setReceiverBirthday(kakaocertService.encrypt(socialCertVO.getBirth()));
// 인증요청 메시지 제목 - 최대 40자
identity.setReqTitle("본인인증 요청 메시지 제목");
identity.setReqTitle("분쟁조정사건처리시스템 본인인증");
// 커스텀 메시지 - 최대 500자
identity.setExtraMessage(kakaocertService.encrypt("본인인증 커스텀 메시지"));
identity.setExtraMessage(kakaocertService.encrypt("한국공정거래조정원 분쟁조정사건처리시스템 본인인증 요청입니다."));
// 인증요청 만료시간 - 최대 1,000()까지 입력 가능
identity.setExpireIn(1000);
// 서명 원문 - 최대 40자 까지 입력가능
@ -152,36 +173,172 @@ public class SocialCertController {
try {
com.barocert.kakaocert.identity.IdentityReceipt result = kakaocertService.requestIdentity(KakaoClientCode, identity);
m.addAttribute("result", result);
com.barocert.kakaocert.identity.IdentityReceipt request = kakaocertService.requestIdentity(KakaoClientCode, identity);
m.addAttribute("request", request);
} catch (BarocertException ke) {
m.addAttribute("Exception", ke);
return "exception";
return "redirect:/web/user/cert/kCertStep1.do";
}
return "uat/uia/KCert";
return "uat/uia/KCertStep2";
}
/**
* @methodName : nCertStep3Ajax
* @author : JunHo Lee
* @date : 2024.11.21
* @description :
* @param reqeust
* @param repn
* @return
* @throws BarocertException
*/
@RequestMapping(value = "/web/user/cert/nCertStep3Ajax.do")
public ResponseEntity<?> nCertStep3Ajax(HttpServletRequest reqeust, HttpServletResponse repn, SocialCertVO socialCertVO) {
Map<String, String> returnData = new HashMap<String, String>();
com.barocert.navercert.identity.IdentityStatus status = null;
try {
status = navercertService.getIdentityStatus(NaverClientCode, socialCertVO.getReceiptID());
} catch (BarocertException e) {
returnData.put("result", "requestFail");
returnData.put("msg", "인증과정에 문제가 발생했습니다. 화면을 새로고침 후 다시 시도해 주세요.");
return new ResponseEntity<>(returnData, HttpStatus.OK);
}
if(status != null && status.getState() == 1) {
com.barocert.navercert.identity.IdentityResult result = null;
try {
result = navercertService.verifyIdentity(NaverClientCode, socialCertVO.getReceiptID());
} catch (BarocertException e) {
returnData.put("result", "requestFail");
returnData.put("msg", "인증과정에 문제가 발생했습니다. 화면을 새로고침 후 다시 시도해 주세요.");
return new ResponseEntity<>(returnData, HttpStatus.OK);
}
System.out.println("getReceiptID()); :: " + result.getReceiptID());
System.out.println("getReceiverDay()); :: " + nDecrypt(result.getReceiverDay()));
System.out.println("getReceiverEmail()); :: " + nDecrypt(result.getReceiverEmail()));
System.out.println("getReceiverForeign()); :: " + nDecrypt(result.getReceiverForeign()));
System.out.println("getReceiverGender()); :: " + nDecrypt(result.getReceiverGender()));
System.out.println("getReceiverHP()); :: " + nDecrypt(result.getReceiverHP()));
System.out.println("getReceiverName()); :: " + nDecrypt(result.getReceiverName()));
System.out.println("getReceiverYear()); :: " + nDecrypt(result.getReceiverYear()));
System.out.println("getSignedData()); :: " + result.getSignedData());
System.out.println("getState()); :: " + result.getState());
System.out.println("getCi()); :: " + nDecrypt(result.getCi()));
returnData.put("result", "success");
returnData.put("msg", "인증되었습니다.");
return new ResponseEntity<>(returnData, HttpStatus.OK);
}else {
returnData.put("result", "fail");
returnData.put("msg", "인증 후 다시 클릭해 주세요.");
return new ResponseEntity<>(returnData, HttpStatus.OK);
}
}
@RequestMapping(value = "/web/user/cert/kCertStep3Ajax.do")
public ResponseEntity<?> kCertStep3Ajax(HttpServletRequest reqeust, HttpServletResponse repn, SocialCertVO socialCertVO) {
Map<String, String> returnData = new HashMap<String, String>();
com.barocert.kakaocert.identity.IdentityStatus status = null;
try {
status = kakaocertService.getIdentityStatus(KakaoClientCode, socialCertVO.getReceiptID());
} catch (BarocertException e) {
returnData.put("result", "requestFail");
returnData.put("msg", "인증과정에 문제가 발생했습니다. 화면을 새로고침 후 다시 시도해 주세요.");
return new ResponseEntity<>(returnData, HttpStatus.OK);
}
if(status != null && status.getState() == 1) {
com.barocert.kakaocert.identity.IdentityResult result = null;
try {
result = kakaocertService.verifyIdentity(KakaoClientCode, socialCertVO.getReceiptID());
} catch (BarocertException e) {
returnData.put("result", "requestFail");
returnData.put("msg", "인증과정에 문제가 발생했습니다. 화면을 새로고침 후 다시 시도해 주세요.");
return new ResponseEntity<>(returnData, HttpStatus.OK);
}
System.out.println("getReceiptID()); :: " + result.getReceiptID());
System.out.println("getState()); :: " +result.getState());
System.out.println("getSignedData()); :: " + result.getSignedData());
System.out.println("getCi()); :: " + kDecrypt(result.getCi()));
System.out.println("getReceiverName()); :: " + kDecrypt(result.getReceiverName()));
System.out.println("getReceiverYear()); :: " + kDecrypt(result.getReceiverYear()));
System.out.println("getReceiverDay()); :: " + kDecrypt(result.getReceiverDay()));
System.out.println("getReceiverHP()); :: " + kDecrypt(result.getReceiverHP()));
System.out.println("getReceiverGender()); :: " + kDecrypt(result.getReceiverGender()));
returnData.put("result", "success");
returnData.put("msg", "인증되었습니다.");
return new ResponseEntity<>(returnData, HttpStatus.OK);
}else {
returnData.put("result", "fail");
returnData.put("msg", "인증 후 다시 클릭해 주세요.");
return new ResponseEntity<>(returnData, HttpStatus.OK);
}
}
private String decryptNaver() {
//복호화
String secretKey = "LqZ8a…";
// 초기화 벡터 (고정값)
String iv = "6C2Syq8t…";
// 암호문
String cipherText = "6MXhzI8yDVdCDktJ/Qdz9S…";
private String nDecrypt(String param){
try {
// 복호화
String secretKey = "0lOKtGZ_wu";
// 초기화 벡터
String iv = "6C2Syq8tbK3eApue";
// 암호문
String cipherText = SeedUtils.setReplaceNull(param);
nCertDecryptor decryptor = new nCertDecryptor();
String decryptedCI = decryptor.decrypt(secretKey, iv, cipherText);
return decryptedCI;
} catch (Exception e) {
System.out.println("복호화 실패!!!");
return param;
}
}
private String kDecrypt(String param) {
// 복호화
String secretKey = "+EJwVvo37PY1v4zcENdmGezYXwCdmtUlbaNVI0kvrFM=";
// 초기화 벡터
String iv = "uG+F70tIcBb3z1lh8RcVDQ==";
// 암호문
String cipherText = SeedUtils.setReplaceNull(param);
try {
// 복호화
// Decryptor decryptor = new Decryptor();
// String decryptedCI = decryptor.decrypt(secretKey, iv, cipherText);
// System.out.println(decryptedCI);
kCertDecryptor decryptor = new kCertDecryptor();
String decryptedCI = decryptor.decrypt(secretKey, iv, cipherText);
System.out.println(decryptedCI);
return decryptedCI;
} catch (Exception e) {
e.printStackTrace();
System.out.println("복호화 실패!!!");
return param;
}
return "";
}
}

View File

@ -0,0 +1,107 @@
package seed.utils;
public class kCertBase64 {
private static final char[] encodeTable = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/' };
public static char getEncode(int i) {
return encodeTable[i & 0x3F];
}
public static String encode(byte[] input) {
char[] result = new char[((input.length + 2) / 3) * 4];
int resultIndex = 0;
int checkLength = 0;
for (int i = 0; i < input.length; i = i + 3) {
checkLength = input.length - i;
if (checkLength == 2) {
result[resultIndex++] = getEncode(input[i] >> 2);
result[resultIndex++] = getEncode(((input[i] & 0x3) << 4) | ((input[i + 1] >> 4) & 0xF));
result[resultIndex++] = getEncode((input[i + 1] & 0xF) << 2);
result[resultIndex++] = '=';
} else if (checkLength == 1) {
result[resultIndex++] = getEncode(input[i] >> 2);
result[resultIndex++] = getEncode(((input[i]) & 0x3) << 4);
result[resultIndex++] = '=';
result[resultIndex++] = '=';
} else {
result[resultIndex++] = getEncode(input[i] >> 2);
result[resultIndex++] = getEncode(((input[i] & 0x3) << 4) | ((input[i + 1] >> 4) & 0xF));
result[resultIndex++] = getEncode(((input[i + 1] & 0xF) << 2) | ((input[i + 2] >> 6) & 0x3));
result[resultIndex++] = getEncode(input[i + 2] & 0x3F);
}
}
return new String(result);
}
private static final byte[] decodeTable = new byte[128];
private static final byte PADDING = 127;
static {
for (int i = 0; i < decodeTable.length; i++) {
decodeTable[i] = -1;
}
for (int i = 0; i < encodeTable.length; i++) {
decodeTable[encodeTable[i]] = (byte) i;
}
decodeTable['='] = PADDING;
}
public static byte[] decode(String input) {
int resultLength = getResultLength(input);
byte[] result = new byte[resultLength];
int resultIndex = 0;
byte[] splitBuff = new byte[4];
int bufIndex = 0;
for (int i = 0; i < input.length(); i++) {
char inputChar = input.charAt(i);
byte decodeValue = decodeTable[inputChar];
if (decodeValue != -1) {
splitBuff[bufIndex++] = decodeValue;
}
if (bufIndex == 4) {
result[resultIndex++] = (byte) ((splitBuff[0] << 2) | (splitBuff[1] >> 4));
if (splitBuff[2] != PADDING)
result[resultIndex++] = (byte) ((splitBuff[1] << 4) | (splitBuff[2] >> 2));
if (splitBuff[3] != PADDING)
result[resultIndex++] = (byte) ((splitBuff[2] << 6) | (splitBuff[3]));
bufIndex = 0;
}
}
return result;
}
private static int getResultLength(String input) {
final int inputLength = input.length();
int paddingCheck = inputLength - 1;
int paddingSize = 0;
for (; paddingCheck >= 0; paddingCheck--) {
byte code = decodeTable[input.charAt(paddingCheck)];
if (code == PADDING)
continue;
if (code == -1) {
return input.length() / 4 * 3;
}
break;
}
paddingCheck++;
paddingSize = inputLength - paddingCheck;
return input.length() / 4 * 3 - paddingSize;
}
}

View File

@ -0,0 +1,41 @@
package seed.utils;
import java.security.MessageDigest;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class kCertDecryptor {
public String decrypt(String secretKey, String iv, String cipher) throws Exception {
// 암호화 알고리즘/모드/패딩
String algorithm = "AES/CTR/NoPadding";
// 비밀 디코딩
byte[] decodedSecretKey = kCertBase64.decode(secretKey);
// 초기화 벡터 디코딩
byte[] decodedIv = kCertBase64.decode(iv);
// 암호문 디코딩
byte[] decodecCipher = kCertBase64.decode(cipher);
// 복호화 객체 생성
Cipher decipherInstance = Cipher.getInstance(algorithm);
// 복호화 스펙 정의
SecretKeySpec keySpec = new SecretKeySpec(decodedSecretKey, "AES");
IvParameterSpec ivSpec = new IvParameterSpec(decodedIv);
// 복호화 객체 초기화
decipherInstance.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
// 복호화
byte[] plain = decipherInstance.doFinal(decodecCipher);
// 복호화 평문(byte[]) 문자로 변환
return new String(plain, "UTF-8");
}
}

View File

@ -0,0 +1,107 @@
package seed.utils;
public class nCertBase64 {
private static final char[] encodeTable = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/' };
public static char getEncode(int i) {
return encodeTable[i & 0x3F];
}
public static String encode(byte[] input) {
char[] result = new char[((input.length + 2) / 3) * 4];
int resultIndex = 0;
int checkLength = 0;
for (int i = 0; i < input.length; i = i + 3) {
checkLength = input.length - i;
if (checkLength == 2) {
result[resultIndex++] = getEncode(input[i] >> 2);
result[resultIndex++] = getEncode(((input[i] & 0x3) << 4) | ((input[i + 1] >> 4) & 0xF));
result[resultIndex++] = getEncode((input[i + 1] & 0xF) << 2);
result[resultIndex++] = '=';
} else if (checkLength == 1) {
result[resultIndex++] = getEncode(input[i] >> 2);
result[resultIndex++] = getEncode(((input[i]) & 0x3) << 4);
result[resultIndex++] = '=';
result[resultIndex++] = '=';
} else {
result[resultIndex++] = getEncode(input[i] >> 2);
result[resultIndex++] = getEncode(((input[i] & 0x3) << 4) | ((input[i + 1] >> 4) & 0xF));
result[resultIndex++] = getEncode(((input[i + 1] & 0xF) << 2) | ((input[i + 2] >> 6) & 0x3));
result[resultIndex++] = getEncode(input[i + 2] & 0x3F);
}
}
return new String(result);
}
private static final byte[] decodeTable = new byte[128];
private static final byte PADDING = 127;
static {
for (int i = 0; i < decodeTable.length; i++) {
decodeTable[i] = -1;
}
for (int i = 0; i < encodeTable.length; i++) {
decodeTable[encodeTable[i]] = (byte) i;
}
decodeTable['='] = PADDING;
}
public static byte[] decode(String input) {
int resultLength = getResultLength(input);
byte[] result = new byte[resultLength];
int resultIndex = 0;
byte[] splitBuff = new byte[4];
int bufIndex = 0;
for (int i = 0; i < input.length(); i++) {
char inputChar = input.charAt(i);
byte decodeValue = decodeTable[inputChar];
if (decodeValue != -1) {
splitBuff[bufIndex++] = decodeValue;
}
if (bufIndex == 4) {
result[resultIndex++] = (byte) ((splitBuff[0] << 2) | (splitBuff[1] >> 4));
if (splitBuff[2] != PADDING)
result[resultIndex++] = (byte) ((splitBuff[1] << 4) | (splitBuff[2] >> 2));
if (splitBuff[3] != PADDING)
result[resultIndex++] = (byte) ((splitBuff[2] << 6) | (splitBuff[3]));
bufIndex = 0;
}
}
return result;
}
private static int getResultLength(String input) {
final int inputLength = input.length();
int paddingCheck = inputLength - 1;
int paddingSize = 0;
for (; paddingCheck >= 0; paddingCheck--) {
byte code = decodeTable[input.charAt(paddingCheck)];
if (code == PADDING)
continue;
if (code == -1) {
return input.length() / 4 * 3;
}
break;
}
paddingCheck++;
paddingSize = inputLength - paddingCheck;
return input.length() / 4 * 3 - paddingSize;
}
}

View File

@ -0,0 +1,59 @@
package seed.utils;
import java.security.MessageDigest;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class nCertDecryptor {
public static int BLOCK_SIZE = 16;
public String decrypt(String secretKey, String iv, String cipher) throws Exception {
// 암호화 알고리즘/모드/패딩
String algorithm = "AES/CBC/PKCS5PADDING";
// 비밀 디코딩
byte[] decodedSecretKey = keyInstance(secretKey, BLOCK_SIZE);
// 초기화 벡터 디코딩
byte[] decodedIv = iv.getBytes("UTF-8");
// 암호문 디코딩
byte[] decodecCipher = nCertBase64.decode(cipher);
// 복호화 객체 생성
Cipher decipherInstance = Cipher.getInstance(algorithm);
// 복호화 스펙 정의
SecretKeySpec keySpec = new SecretKeySpec(decodedSecretKey, "AES");
IvParameterSpec ivSpec = new IvParameterSpec(decodedIv);
// 복호화 객체 초기화
decipherInstance.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
// 복호화
byte[] plain = decipherInstance.doFinal(decodecCipher);
// 복호화 평문(byte[]) 문자로 변환
return new String(plain, "UTF-8");
}
public byte[] keyInstance(String secretkey, int size) {
byte[] retHashValue = new byte[size];
try {
MessageDigest md = MessageDigest.getInstance("SHA1");
byte[] hash = md.digest(secretkey.getBytes("UTF-8"));
size = Math.min(size, hash.length);
System.arraycopy(hash, 0, retHashValue, 0, size);
}catch(Exception e) {
e.printStackTrace();
}
return retHashValue;
}
}

View File

@ -175,4 +175,9 @@
<decorator name="weblayout" page="/WEB-INF/jsp/layout/siteCheck.jsp">
<pattern>*/web/*</pattern>
</decorator>
<!-- 사용자 팝업 레이아웃 -->
<decorator name="popupLayout" page="/WEB-INF/jsp/layout/popupLayout.jsp">
<pattern>/web/user/cert/*</pattern>
</decorator>
</decorators>

View File

@ -26,6 +26,14 @@
return true;
}
function certPop(div){
if(div == 'naver'){
window.open('/web/user/cert/nCertStep1.do', 'naverPop', 'width=710, height=527')
}else if(div == 'kakao'){
window.open('/web/user/cert/kCertStep1.do', 'kakaoPop', 'width=710, height=527')
}
}
</script>
<div class="sub_content self_identification w100per">
@ -50,13 +58,13 @@
</button>
</li>
<li>
<button type="button" class="btn_idf naver">
<button type="button" class="btn_idf naver" onclick="certPop('naver');">
<i class="icon naver"></i>
<span>네이버</span>
</button>
</li>
<li>
<button type="button" class="btn_idf kakao">
<button type="button" class="btn_idf kakao" onclick="certPop('kakao');">
<i class="icon kakao"></i>
<span>카카오톡</span>
</button>

View File

@ -0,0 +1,33 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>한국공정거래조정원 온라인분쟁조정시스템 > 마이페이지 > 본인인증 > 간편인증</title>
<!-- css -->
<link rel="stylesheet" href="/kofair_case_seed/css/reset.css">
<link rel="stylesheet" href="/kofair_case_seed/css/font.css">
<link rel="stylesheet" href="/kofair_case_seed/usr/style/common.css">
<link rel="stylesheet" href="/kofair_case_seed/usr/style/layout.css">
<link rel="stylesheet" href="/kofair_case_seed/usr/style/style.css">
<link rel="stylesheet" href="/kofair_case_seed/usr/style/popup.css">
<!-- js -->
<script src="/kofair_case_seed/script/lib/jquery-3.5.0.js"></script>
<script src="/kofair_case_seed/usr/scripts/common.js"></script>
<script src="/kofair_case_seed/usr/scripts/layout.js"></script>
<script src="/kofair_case_seed/usr/scripts/ui.js"></script>
<script src="/kofair_case_seed/usr/scripts/popup.js"></script>
<decorator:head />
</head>
<body>
<decorator:body />
</body>
</html>

View File

@ -1,9 +0,0 @@
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="kc" uri="/WEB-INF/tlds/kcc_tld.tld"%>
<!DOCTYPE html>
kakaoCert

View File

@ -0,0 +1,98 @@
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html>
<script type="text/javascript">
$(document).ready(function(){
if('${Exception}' != ''){
alert('${Exception}');
}
});
function validation(){
if($('#name').val() == ''){
alert('이름을 입력해 주세요');
return false;
}
if($('#phone').val() == ''){
alert('휴대전화를 입력해 주세요.');
return false;
}
if($('#birth').val() == ''){
alert('생년월일을 입력해 주세요.');
return false;
}
if(!$('#agree_01').is(':checked')){
alert('개인정보 수집 및 이용동의를 체크해 주세요.');
return false;
}
if(!$('#agree_02').is(':checked')){
alert('제3자 정보 제공 동의를 체크해 주세요.');
return false;
}
return true;
}
function goStep2(){
if(validation()){
document.kForm.submit();
}
}
</script>
<form id="kForm" name="kForm" action="/web/user/cert/kCertStep2.do" method="post">
<div class="window_popup idf" style="width:700px">
<div class="title_area">
<h1>카카오 간편인증</h1>
</div>
<div class="cont_area">
<div class="table_type_rows">
<table>
<colgroup>
<col style="width:200px;">
<col style="width:auto;">
</colgroup>
<tbody>
<tr>
<th>이름</th>
<td><input type="text" id="name" name="name" class="input_text w100per" placeholder="이름"></td>
</tr>
<tr>
<th>휴대전화</th>
<td><input type="text" id="phone" name="phone" class="input_text w100per" placeholder="본인명의 휴대전화번호(숫자만 입력)"></td>
</tr>
<tr>
<th>생년월일</th>
<td><input type="text" id="birth" name="birth" class="input_text w100per" placeholder="생년월일 8자리(19990101)"></td>
</tr>
</tbody>
</table>
</div>
<ul class="agree_box_area">
<li>
<div class="checkbox_wrap">
<input type="checkbox" id="agree_01"><label for="agree_01">개인정보 수집 및 이용동의 <span class="color_red">(필수)</span></label>
</div>
<button type="button" class="btn btn_35 btn_text darkgray_border">자세히보기</button>
</li>
<li>
<div class="checkbox_wrap">
<input type="checkbox" id="agree_02"><label for="agree_02">제3자 정보 제공 동의 <span class="color_red">(필수)</span></label>
</div>
<button type="button" class="btn btn_35 btn_text darkgray_border">자세히보기</button>
</li>
</ul>
<div class="btn_wrap center">
<button type="button" class="btn btn_40 btn_text gray_fill" onclick="self.close();">취소</button>
<button type="button" class="btn btn_40 btn_text darkblue_fill" onclick="goStep2();">인증요청</button>
</div>
</div>
</div>
</form>

View File

@ -0,0 +1,57 @@
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="kc" uri="/WEB-INF/tlds/kcc_tld.tld"%>
<!DOCTYPE html>
<script type="text/javascript">
function step3(){
$.ajax({
url: '/web/user/cert/kCertStep3Ajax.do',
type: 'POST',
processData: false,
contentType: false,
data: new FormData(document.kForm),
success: function(response) {
alert(response.msg);
if(response.result == 'success'){
window.close();
}else if(response.result == 'requestFail'){
window.close();
}
},
error: function(error) {
alert("error");
}
});
}
</script>
<form id="kForm" name="kForm" action="/web/user/cert/kCertStep2.do" method="post">
<input type="hidden" name="receiptID" value="${request.receiptID}"/>
<div class="window_popup idf" style="width:700px">
<div class="title_area">
<h1>카카오 간편인증</h1>
</div>
<div class="cont_area text_center">
<p class="title gMarket_bold"><i class="icon lock"></i> 인증을 진행해주세요.</p>
<div class="box gray_fill">
입력하신 휴대폰으로 인증 요청 메시지를 보냈습니다.<br>
앱에서 인증을 진행해 주세요.
</div>
<div class="btn_wrap center">
<button type="button" class="btn btn_40 btn_text gray_fill" onclick="self.close();">취소</button>
<button type="button" class="btn btn_40 btn_text darkblue_fill" onclick="step3();">인증요청</button>
</div>
</div>
</div>
</form>

View File

@ -1,20 +0,0 @@
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="kc" uri="/WEB-INF/tlds/kcc_tld.tld"%>
<!DOCTYPE html>
<div id="content">
<p class="heading1">Response</p>
<br/>
<fieldset class="fieldset1">
<legend>${requestScope['javax.servlet.forward.request_uri']}</legend>
<ul>
<li>접수아이디 (ReceiptID) : ${result.receiptID}</li>
<li>앱스킴 (Scheme) : ${result.scheme}</li>
<li>앱다운로드URL (MarketURL) : ${result.marketUrl}</li>
</ul>
</fieldset>
</div>

View File

@ -0,0 +1,98 @@
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html>
<script type="text/javascript">
$(document).ready(function(){
if('${Exception}' != ''){
alert('${Exception}');
}
});
function validation(){
if($('#name').val() == ''){
alert('이름을 입력해 주세요');
return false;
}
if($('#phone').val() == ''){
alert('휴대전화를 입력해 주세요.');
return false;
}
if($('#birth').val() == ''){
alert('생년월일을 입력해 주세요.');
return false;
}
if(!$('#agree_01').is(':checked')){
alert('개인정보 수집 및 이용동의를 체크해 주세요.');
return false;
}
if(!$('#agree_02').is(':checked')){
alert('제3자 정보 제공 동의를 체크해 주세요.');
return false;
}
return true;
}
function goStep2(){
if(validation()){
document.nForm.submit();
}
}
</script>
<form id="nForm" name="nForm" action="/web/user/cert/nCertStep2.do" method="post">
<div class="window_popup idf" style="width:700px">
<div class="title_area">
<h1>네이버 간편인증</h1>
</div>
<div class="cont_area">
<div class="table_type_rows">
<table>
<colgroup>
<col style="width:200px;">
<col style="width:auto;">
</colgroup>
<tbody>
<tr>
<th>이름</th>
<td><input type="text" id="name" name="name" class="input_text w100per" placeholder="이름"></td>
</tr>
<tr>
<th>휴대전화</th>
<td><input type="text" id="phone" name="phone" class="input_text w100per" placeholder="본인명의 휴대전화번호(숫자만 입력)"></td>
</tr>
<tr>
<th>생년월일</th>
<td><input type="text" id="birth" name="birth" class="input_text w100per" placeholder="생년월일 8자리(19990101)"></td>
</tr>
</tbody>
</table>
</div>
<ul class="agree_box_area">
<li>
<div class="checkbox_wrap">
<input type="checkbox" id="agree_01"><label for="agree_01">개인정보 수집 및 이용동의 <span class="color_red">(필수)</span></label>
</div>
<button type="button" class="btn btn_35 btn_text darkgray_border">자세히보기</button>
</li>
<li>
<div class="checkbox_wrap">
<input type="checkbox" id="agree_02"><label for="agree_02">제3자 정보 제공 동의 <span class="color_red">(필수)</span></label>
</div>
<button type="button" class="btn btn_35 btn_text darkgray_border">자세히보기</button>
</li>
</ul>
<div class="btn_wrap center">
<button type="button" class="btn btn_40 btn_text gray_fill" onclick="self.close();">취소</button>
<button type="button" class="btn btn_40 btn_text darkblue_fill" onclick="goStep2();">인증요청</button>
</div>
</div>
</div>
</form>

View File

@ -0,0 +1,57 @@
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="kc" uri="/WEB-INF/tlds/kcc_tld.tld"%>
<!DOCTYPE html>
<script type="text/javascript">
function step3(){
$.ajax({
url: '/web/user/cert/nCertStep3Ajax.do',
type: 'POST',
processData: false,
contentType: false,
data: new FormData(document.nForm),
success: function(response) {
alert(response.msg);
if(response.result == 'success'){
window.close();
}else if(response.result == 'requestFail'){
window.close();
}
},
error: function(error) {
alert("error");
}
});
}
</script>
<form id="nForm" name="nForm" action="/web/user/cert/nCertStep2.do" method="post">
<input type="hidden" name="receiptID" value="${request.receiptID}"/>
<div class="window_popup idf" style="width:700px">
<div class="title_area">
<h1>네이버 간편인증</h1>
</div>
<div class="cont_area text_center">
<p class="title gMarket_bold"><i class="icon lock"></i> 인증을 진행해주세요.</p>
<div class="box gray_fill">
입력하신 휴대폰으로 인증 요청 메시지를 보냈습니다.<br>
앱에서 인증을 진행해 주세요.
</div>
<div class="btn_wrap center">
<button type="button" class="btn btn_40 btn_text gray_fill" onclick="self.close();">취소</button>
<button type="button" class="btn btn_40 btn_text darkblue_fill" onclick="step3();">인증요청</button>
</div>
</div>
</div>
</form>