fix: 공통 메소드 분리 적용

dev
gitea-관리자 1 year ago
parent 8d79b6881d
commit 948ad11064

@ -16,13 +16,14 @@ import kr.xit.biz.ens.model.nice.NiceCiDTO.SymkeyStatInfo;
import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResDataBody; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResDataBody;
import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenResDataBody; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenResDataBody;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse;
import kr.xit.biz.nice.mapper.IBizNiceCiMapper; import kr.xit.biz.nice.mapper.IBizNiceCiMapper;
import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.exception.BizRuntimeException;
import kr.xit.core.support.utils.DateUtils; import kr.xit.core.support.utils.DateUtils;
import kr.xit.core.support.utils.IpMacUtils; import kr.xit.core.support.utils.IpMacUtils;
import kr.xit.core.support.utils.JsonUtils; import kr.xit.core.support.utils.JsonUtils;
import kr.xit.ens.cmm.CmmEnsUtils;
import kr.xit.ens.nice.cmm.CmmNiceCiUtils; import kr.xit.ens.nice.cmm.CmmNiceCiUtils;
import kr.xit.ens.nice.service.INiceCiService; import kr.xit.ens.nice.service.INiceCiService;
import kr.xit.ens.nice.service.NiceCiDummyTestService; import kr.xit.ens.nice.service.NiceCiDummyTestService;
@ -78,11 +79,11 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
*/ */
@Transactional @Transactional
@Override @Override
public TokenResponse generateToken(final NiceCiRequest reqDTO){ public NiceTokenResponse generateToken(final NiceCiRequest reqDTO){
final NiceCiInfo niceDTO = CmmNiceCiUtils.getNiceCiInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); final NiceCiInfo niceDTO = CmmNiceCiUtils.getNiceCiInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode());
//FIXME:: nice CI 연계후 제거 //FIXME:: nice CI 연계후 제거
TokenResponse tokenResponse = null; NiceTokenResponse tokenResponse = null;
if(isDummy) tokenResponse = dummyTestService.generateToken(); if(isDummy) tokenResponse = dummyTestService.generateToken();
else tokenResponse = niceCiService.generateToken(niceDTO); else tokenResponse = niceCiService.generateToken(niceDTO);
@ -167,7 +168,7 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
//FIXME:: nice CI 연계후 제거 //FIXME:: nice CI 연계후 제거
PublickeyResponse pubResDTO = null; PublickeyResponse pubResDTO = null;
if(isDummy) pubResDTO = dummyTestService.requestPublickey(); if(isDummy) pubResDTO = dummyTestService.requestPublickey();
else pubResDTO = niceCiService.requestPublickey(CmmNiceCiUtils.generateLengthUuid(24), niceDTO); else pubResDTO = niceCiService.requestPublickey(CmmEnsUtils.generateLengthUuid(24), niceDTO);
//FIXME::공개키 정보 갱신 - Error code enum 전환 //FIXME::공개키 정보 갱신 - Error code enum 전환
final ResponseDataHeader dataHeader = pubResDTO.getDataHeader(); final ResponseDataHeader dataHeader = pubResDTO.getDataHeader();
@ -243,7 +244,7 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
SymmetrickeyResponse symResDTO = null; SymmetrickeyResponse symResDTO = null;
if(isDummy) symResDTO = dummyTestService.requestRegSymmetrickey(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); if(isDummy) symResDTO = dummyTestService.requestRegSymmetrickey(reqDTO.getSignguCode(), reqDTO.getFfnlgCode());
else symResDTO = niceCiService.requestRegSymmetrickey(CmmNiceCiUtils.generateLengthUuid(24), symkeyRegInfo, niceDTO); else symResDTO = niceCiService.requestRegSymmetrickey(CmmEnsUtils.generateLengthUuid(24), symkeyRegInfo, niceDTO);
final ResponseDataHeader dataHeader = symResDTO.getDataHeader(); final ResponseDataHeader dataHeader = symResDTO.getDataHeader();
final SymmetrickeyResDataBody dataBody = symResDTO.getDataBody(); final SymmetrickeyResDataBody dataBody = symResDTO.getDataBody();
@ -308,7 +309,7 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
.siteCode(niceDTO.getSiteCode()) .siteCode(niceDTO.getSiteCode())
//.infoReqType() //default: 1-CI제공 //.infoReqType() //default: 1-CI제공
.juminId(reqDTO.getJuminId()) .juminId(reqDTO.getJuminId())
.reqNo(CmmNiceCiUtils.generateLengthUuid(30)) .reqNo(CmmEnsUtils.generateLengthUuid(30))
.reqDtim(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss")) .reqDtim(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss"))
.clientIp(IpMacUtils.getIpAddress().get(0)) .clientIp(IpMacUtils.getIpAddress().get(0))
.build(); .build();
@ -316,7 +317,7 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
IpinCiResponse ipinCiResponse = null; IpinCiResponse ipinCiResponse = null;
if(isDummy) ipinCiResponse = dummyTestService.requestCi(encDataDTO, niceDTO); if(isDummy) ipinCiResponse = dummyTestService.requestCi(encDataDTO, niceDTO);
else ipinCiResponse = niceCiService.requestCi(CmmNiceCiUtils.generateLengthUuid(24), encDataDTO, niceDTO); else ipinCiResponse = niceCiService.requestCi(CmmEnsUtils.generateLengthUuid(24), encDataDTO, niceDTO);
ResponseDataHeader resHeader = ipinCiResponse.getDataHeader(); ResponseDataHeader resHeader = ipinCiResponse.getDataHeader();
IpinCiResDataBody resBody = ipinCiResponse.getDataBody(); IpinCiResDataBody resBody = ipinCiResponse.getDataBody();
@ -326,9 +327,9 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
//FIXME::응답무결성 체크 //FIXME::응답무결성 체크
// 응답으로온 intigrety_value와 응답 enc_data를 Hmac한 값을 비교 // 응답으로온 intigrety_value와 응답 enc_data를 Hmac한 값을 비교
// 무결성체크가 완료되면 데이터를 보낸 대칭키로 복호화하여 데이터를 확인 // 무결성체크가 완료되면 데이터를 보낸 대칭키로 복호화하여 데이터를 확인
String checkHmac = CmmNiceCiUtils.encodeHmacSha256(niceDTO.getCurSymkeyHmacKey(), resEncData); String checkHmac = CmmEnsUtils.encodeHmacSha256(niceDTO.getCurSymkeyHmacKey(), resEncData);
if(resBody.getIntegrityValue().equals(checkHmac)){ if(resBody.getIntegrityValue().equals(checkHmac)){
String decData = CmmNiceCiUtils.decodeAesData(resEncData, niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv()); String decData = CmmEnsUtils.decodeAesData(resEncData, niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv());
resBody.setEncData(decData); resBody.setEncData(decData);
} }
return ipinCiResponse; return ipinCiResponse;

@ -4,7 +4,7 @@ import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest;
import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse;
/** /**
@ -26,7 +26,7 @@ public interface IBizNiceCiService {
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 기관용 Token // 기관용 Token
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
TokenResponse generateToken(final NiceCiRequest reqDTO); NiceTokenResponse generateToken(final NiceCiRequest reqDTO);
TokenRevokeResponse revokeToken(final NiceCiRequest reqDTO); TokenRevokeResponse revokeToken(final NiceCiRequest reqDTO);
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 기관용 Token // 기관용 Token

@ -12,7 +12,7 @@ import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest;
import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.ResponseDataHeader; import kr.xit.biz.ens.model.nice.NiceCiDTO.ResponseDataHeader;
import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse;
import kr.xit.biz.nice.service.IBizNiceCiService; import kr.xit.biz.nice.service.IBizNiceCiService;
import kr.xit.core.model.ApiResponseDTO; import kr.xit.core.model.ApiResponseDTO;
@ -75,7 +75,7 @@ public class BizNiceCiController {
@Operation(summary = "기관용 토큰 발급 요청", description = "기관용 토큰 발급 요청") @Operation(summary = "기관용 토큰 발급 요청", description = "기관용 토큰 발급 요청")
@PostMapping(value = "/generateToken", produces = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "/generateToken", produces = MediaType.APPLICATION_JSON_VALUE)
public ApiResponseDTO<?> generateToken(@RequestBody final NiceCiRequest reqDTO) { public ApiResponseDTO<?> generateToken(@RequestBody final NiceCiRequest reqDTO) {
final TokenResponse tokenResponse = service.generateToken(reqDTO); final NiceTokenResponse tokenResponse = service.generateToken(reqDTO);
return niceTokenResponse(tokenResponse.getDataHeader(), tokenResponse.getDataBody()); return niceTokenResponse(tokenResponse.getDataHeader(), tokenResponse.getDataBody());
} }

@ -2,15 +2,14 @@ package kr.xit.core.spring.util;
import egovframework.com.cmm.EgovMessageSource; import egovframework.com.cmm.EgovMessageSource;
import kr.xit.biz.cmm.service.CmmEnsCacheService; import kr.xit.biz.cmm.service.CmmEnsCacheService;
import kr.xit.biz.cmm.service.ICmmEnsCacheService;
import kr.xit.core.spring.config.support.ApplicationContextProvider;
import kr.xit.ens.nice.service.INiceCiService;
import kr.xit.ens.nice.service.NiceCiDummyTestService; import kr.xit.ens.nice.service.NiceCiDummyTestService;
import kr.xit.ens.nice.service.NiceCiService;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import kr.xit.core.spring.config.support.ApplicationContextProvider;
import kr.xit.core.support.slack.SlackWebhookPush;
/** /**
* <pre> * <pre>
* description : Get Bean Object * description : Get Bean Object
@ -51,12 +50,12 @@ public class ApiSpringUtils {
return (EgovMessageSource)getBean(EgovMessageSource.class); return (EgovMessageSource)getBean(EgovMessageSource.class);
} }
public static CmmEnsCacheService getCmmEnsCacheService(){ public static ICmmEnsCacheService getCmmEnsCacheService(){
return (CmmEnsCacheService)getBean(CmmEnsCacheService.class); return (ICmmEnsCacheService)getBean(CmmEnsCacheService.class);
} }
public static NiceCiService getNiceCiService(){ public static INiceCiService getNiceCiService(){
return (NiceCiService)getBean(NiceCiService.class); return (INiceCiService)getBean(INiceCiService.class);
} }
public static NiceCiDummyTestService getDummyNiceCiService(){ public static NiceCiDummyTestService getDummyNiceCiService(){

@ -0,0 +1,177 @@
package kr.xit.ens.cmm;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.Mac;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import kr.xit.core.exception.BizRuntimeException;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/**
* <pre>
* description :
*
* packageName : kr.xit.ens.cmm
* fileName : CmmNiceCiUtils
* author : limju
* date : 2023-09-19
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-09-19 limju
*
* </pre>
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CmmEnsUtils {
//private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
public static <T> void validate(T t) {
Locale.setDefault(Locale.KOREA);
final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
final Set<ConstraintViolation<T>> list = validator.validate(t);
if (list.size() > 0) {
List<String> errors = list.stream()
.map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate()))
.collect(Collectors.toList());
throw BizRuntimeException.create(
list.stream()
.map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate()))
//.map(row -> String.format("%s=%s", row.getPropertyPath(), row.get()) ? row.getMessage(): row.getMessageTemplate()))
.collect(Collectors.toList()).toString());
}
}
public static String generateLengthUuid(int length) {
final String allChars = UUID.randomUUID().toString().replace("-", "");
final Random random = new Random();
final char[] otp = new char[length];
for (int i = 0; i < length; i++) {
otp[i] = allChars.charAt(random.nextInt(allChars.length()));
}
return String.valueOf(otp);
}
/**
* sha256
*
* @param text
* @return
* @throws IOException
* @throws NoSuchAlgorithmException
*/
public static String hexSha256(final String text) {
final StringBuffer sbuf = new StringBuffer();
try {
final MessageDigest mDigest = MessageDigest.getInstance("SHA-256");
mDigest.update(text.getBytes());
final byte[] msgStr = mDigest.digest();
for(int i = 0; i < msgStr.length; i++) {
final byte tmpStrByte = msgStr[i];
final String tmpEncTxt = Integer.toString((tmpStrByte & 0xff) + 0x100, 16).substring(1);
sbuf.append(tmpEncTxt);
}
} catch (NoSuchAlgorithmException nae){
throw BizRuntimeException.create(nae.getMessage());
}
return sbuf.toString();
}
/**
* <pre>
* Nice ci
* Base64 encoding return
* @param key
* @param iv
* @param planText
* @return String Base64 encoding data
* </pre>
*/
public static String encodeAesData(final String key, final String iv, final String planText) {
final SecretKey secureKey = new SecretKeySpec(key.getBytes(), "AES");
try {
final Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, secureKey, new IvParameterSpec(iv.getBytes()));
final byte[] encData = cipher.doFinal(planText.trim().getBytes(StandardCharsets.UTF_8));
return Base64.getEncoder().encodeToString(encData);
}catch (NoSuchPaddingException | NoSuchAlgorithmException e){
throw BizRuntimeException.create(e.getMessage());
} catch (InvalidAlgorithmParameterException | InvalidKeyException e) {
throw BizRuntimeException.create(e.getMessage());
} catch (IllegalBlockSizeException | BadPaddingException e) {
throw BizRuntimeException.create(e.getMessage());
}
}
/**
* <pre>
* Hmac (integrity_value)
* @param hmacKey
* @param message
*
* @return String
* </pre>
*/
public static String encodeHmacSha256(final String hmacKey, final String message) {
try {
final Mac mac = Mac.getInstance("HmacSHA256");
final SecretKeySpec sks = new SecretKeySpec(hmacKey.getBytes(), "HmacSHA256");
mac.init(sks);
final byte[] hmac256 = mac.doFinal(message.getBytes());
return Base64.getEncoder().encodeToString(hmac256);
}catch (NoSuchAlgorithmException|InvalidKeyException e){
throw BizRuntimeException.create(e.getMessage());
}
}
public static String decodeAesData(String encData, String key, String iv) {
final byte[] respDataEnc = Base64.getDecoder().decode(encData.getBytes());
final SecretKey secureKey = new SecretKeySpec(key.getBytes(), "AES");
try {
final Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, secureKey, new IvParameterSpec(iv.getBytes()));
final byte[] decrypted = cipher.doFinal(respDataEnc);
return new String(decrypted);
}catch (NoSuchPaddingException|NoSuchAlgorithmException e){
throw BizRuntimeException.create(e.getMessage());
} catch (InvalidAlgorithmParameterException|InvalidKeyException e) {
throw BizRuntimeException.create(e.getMessage());
} catch (IllegalBlockSizeException|BadPaddingException e) {
throw BizRuntimeException.create(e.getMessage());
}
}
}

@ -0,0 +1,56 @@
package kr.xit.ens.kt.cmm;
import egovframework.com.cmm.EgovMessageSource;
import javax.validation.Validation;
import javax.validation.Validator;
import kr.xit.biz.cmm.service.ICmmEnsCacheService;
import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO;
import kr.xit.core.exception.BizRuntimeException;
import kr.xit.core.spring.config.properties.PropertiesUtils;
import kr.xit.core.spring.util.ApiSpringUtils;
import kr.xit.ens.nice.service.INiceCiService;
import kr.xit.ens.nice.service.NiceCiDummyTestService;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
/**
* <pre>
* description :
*
* packageName : kr.xit.ens.kt.cmm
* fileName : CmmKtMmsUtils
* author : limju
* date : 2023-09-19
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-09-19 limju
*
* </pre>
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CmmKtMmsUtils {
private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
private static final EgovMessageSource messageSource = ApiSpringUtils.getMessageSource();
private static final ICmmEnsCacheService cacheService = ApiSpringUtils.getCmmEnsCacheService();
private static final INiceCiService niceCiService = ApiSpringUtils.getNiceCiService();
private static final NiceCiDummyTestService dummyTestService = ApiSpringUtils.getDummyNiceCiService();
private static final boolean IS_DUMMY = Boolean.valueOf(PropertiesUtils.getProperty("contract.nice.dummy"));
/**
* KT MMS
* @return
*/
public static CmmEnsRlaybsnmDTO getKtMnsInfo(final String signguCode, final String ffnlgCode) {
final CmmEnsRlaybsnmDTO dto = cacheService.getRlaybsnmInfoCache(signguCode, ffnlgCode);
if(ObjectUtils.isEmpty(dto)) throw BizRuntimeException.create(messageSource.getMessage("fail.api.kt.info"));
cacheService.logCache();
return dto;
}
}

@ -0,0 +1,25 @@
package kr.xit.ens.kt.service;
import kr.xit.biz.ens.model.kt.KtMmsDTO.KtTokenRequest;
import kr.xit.biz.ens.model.kt.KtMmsDTO.KtTokenResponse;
/**
* <pre>
* description :
*
* packageName : kr.xit.ens.kt.service
* fileName : IKtMmsService
* author : limju
* date : 2023-09-22
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-09-22 limju
*
* </pre>
*/
public interface IKtMmsService {
KtTokenResponse requestToken(final KtTokenRequest reqDTO);
}

@ -0,0 +1,32 @@
package kr.xit.ens.kt.service;
import kr.xit.biz.ens.model.kt.KtMmsDTO.KtTokenRequest;
import kr.xit.biz.ens.model.kt.KtMmsDTO.KtTokenResponse;
import kr.xit.ens.cmm.CmmEnsUtils;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
import org.springframework.stereotype.Service;
/**
* <pre>
* description :
*
* packageName : kr.xit.ens.kt.service
* fileName : KtMmsService
* author : limju
* date : 2023-09-22
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-09-22 limju
*
* </pre>
*/
@Service
public class KtMmsService extends EgovAbstractServiceImpl implements IKtMmsService {
@Override
public KtTokenResponse requestToken(final KtTokenRequest reqDTO) {
CmmEnsUtils.validate(reqDTO);
return null;
}
}

@ -0,0 +1,48 @@
package kr.xit.ens.kt.web;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import kr.xit.biz.cmm.service.ICmmEnsCacheService;
import kr.xit.biz.ens.model.kt.KtMmsDTO.KtMnsRequest;
import kr.xit.biz.ens.model.kt.KtMmsDTO.KtTokenRequest;
import kr.xit.core.model.ApiResponseDTO;
import kr.xit.ens.kt.service.IKtMmsService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <pre>
* description :
*
* packageName : kr.xit.ens.kt.web
* fileName : KtMmsController
* author : limju
* date : 2023-09-22
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-09-22 limju
*
* </pre>
*/
@Tag(name = "KtMmsController", description = "KT MMS API")
@RequiredArgsConstructor
@RestController
@RequestMapping(value = "/api/ens/kt/v1")
public class KtMmsController {
private final IKtMmsService service;
private final ICmmEnsCacheService ensCacheService;
@Operation(summary = "기관용 토큰 발급 요청", description = "기관용 토큰 발급 요청")
@PostMapping(value = "/requestToken", produces = MediaType.APPLICATION_JSON_VALUE)
public ApiResponseDTO<?> requestToken(@RequestBody final KtMnsRequest reqDTO) {
return ApiResponseDTO.success(service.requestToken(KtTokenRequest.builder()
.build()));
// return ApiResponseDTO.success(
// service.requestToken(CmmKtMmsUtils.getKtMnsInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode())));
}
}

@ -1,33 +1,13 @@
package kr.xit.ens.nice.cmm; package kr.xit.ens.nice.cmm;
import egovframework.com.cmm.EgovMessageSource; import egovframework.com.cmm.EgovMessageSource;
import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.Mac;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import javax.validation.ConstraintViolation;
import javax.validation.Validation; import javax.validation.Validation;
import javax.validation.Validator; import javax.validation.Validator;
import kr.xit.biz.cmm.service.CmmEnsCacheService; import kr.xit.biz.cmm.service.ICmmEnsCacheService;
import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiInfo; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiInfo;
import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.ResponseDataHeader; import kr.xit.biz.ens.model.nice.NiceCiDTO.ResponseDataHeader;
@ -38,11 +18,11 @@ import kr.xit.core.spring.config.properties.PropertiesUtils;
import kr.xit.core.spring.util.ApiSpringUtils; import kr.xit.core.spring.util.ApiSpringUtils;
import kr.xit.core.support.utils.DateUtils; import kr.xit.core.support.utils.DateUtils;
import kr.xit.core.support.utils.JsonUtils; import kr.xit.core.support.utils.JsonUtils;
import kr.xit.ens.cmm.CmmEnsUtils;
import kr.xit.ens.nice.service.INiceCiService;
import kr.xit.ens.nice.service.NiceCiDummyTestService; import kr.xit.ens.nice.service.NiceCiDummyTestService;
import kr.xit.ens.nice.service.NiceCiService;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.util.Base64Utils; import org.springframework.util.Base64Utils;
@ -67,14 +47,12 @@ import org.springframework.util.Base64Utils;
public class CmmNiceCiUtils { public class CmmNiceCiUtils {
private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
private static final EgovMessageSource messageSource = ApiSpringUtils.getMessageSource(); private static final EgovMessageSource messageSource = ApiSpringUtils.getMessageSource();
private static final CmmEnsCacheService cacheService = ApiSpringUtils.getCmmEnsCacheService(); private static final ICmmEnsCacheService cacheService = ApiSpringUtils.getCmmEnsCacheService();
private static final NiceCiService niceCiService = ApiSpringUtils.getNiceCiService(); private static final INiceCiService niceCiService = ApiSpringUtils.getNiceCiService();
private static final NiceCiDummyTestService dummyTestService = ApiSpringUtils.getDummyNiceCiService(); private static final NiceCiDummyTestService dummyTestService = ApiSpringUtils.getDummyNiceCiService();
private static final boolean IS_DUMMY = Boolean.valueOf(PropertiesUtils.getProperty("contract.nice.dummy")); private static final boolean IS_DUMMY = Boolean.valueOf(PropertiesUtils.getProperty("contract.nice.dummy"));
private static final int EXPIRED_CHECK_DAYS = 0;
//private static final String FFNLG_CODE = PropertiesUtils.getProperty("contract.nice.ffnlg-code"); //private static final String FFNLG_CODE = PropertiesUtils.getProperty("contract.nice.ffnlg-code");
//private static final String CLIENT_ID = PropertiesUtils.getProperty("contract.nice.client-id"); //private static final String CLIENT_ID = PropertiesUtils.getProperty("contract.nice.client-id");
@ -117,7 +95,7 @@ public class CmmNiceCiUtils {
// 2. 공개키 발급 요청 // 2. 공개키 발급 요청
PublickeyResponse pubResDTO = null; PublickeyResponse pubResDTO = null;
if(IS_DUMMY) pubResDTO = dummyTestService.requestPublickey(); if(IS_DUMMY) pubResDTO = dummyTestService.requestPublickey();
else pubResDTO = niceCiService.requestPublickey(CmmNiceCiUtils.generateLengthUuid(24), niceDTO); else pubResDTO = niceCiService.requestPublickey(CmmEnsUtils.generateLengthUuid(24), niceDTO);
return cacheService.getNiceCiInfoCache(signguCode, ffnlgCode); return cacheService.getNiceCiInfoCache(signguCode, ffnlgCode);
} }
@ -137,7 +115,7 @@ public class CmmNiceCiUtils {
// 1. 토큰 폐기 // 1. 토큰 폐기
if(IS_DUMMY) dummyTestService.requestRegSymmetrickey(signguCode, ffnlgCode); if(IS_DUMMY) dummyTestService.requestRegSymmetrickey(signguCode, ffnlgCode);
else niceCiService.requestRegSymmetrickey(CmmNiceCiUtils.generateLengthUuid(24), null, niceDTO); else niceCiService.requestRegSymmetrickey(CmmEnsUtils.generateLengthUuid(24), null, niceDTO);
return cacheService.getNiceCiInfoCache(signguCode, ffnlgCode); return cacheService.getNiceCiInfoCache(signguCode, ffnlgCode);
} }
@ -152,10 +130,10 @@ public class CmmNiceCiUtils {
public static SymkeyRegInfo getSymkeyRegInfo(String siteCode) { public static SymkeyRegInfo getSymkeyRegInfo(String siteCode) {
return SymkeyRegInfo.builder() return SymkeyRegInfo.builder()
.siteCode(siteCode) .siteCode(siteCode)
.requestNo(generateLengthUuid(30)) .requestNo(CmmEnsUtils.generateLengthUuid(30))
.key(generateLengthUuid(32)) .key(CmmEnsUtils.generateLengthUuid(32))
.iv(generateLengthUuid(16)) .iv(CmmEnsUtils.generateLengthUuid(16))
.hmacKey(generateLengthUuid(32)) .hmacKey(CmmEnsUtils.generateLengthUuid(32))
.build(); .build();
} }
@ -177,22 +155,6 @@ public class CmmNiceCiUtils {
return map; return map;
} }
public static <T> void validate(T t) {
//final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
final Set<ConstraintViolation<T>> list = validator.validate(t);
if (list.size() > 0) {
List<String> errors = list.stream()
.map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate()))
.collect(Collectors.toList());
throw BizRuntimeException.create(
list.stream()
.map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate()))
.collect(Collectors.toList()).toString());
}
}
/** /**
* <pre> * <pre>
* GW_RSLT_CD : "1200" TRAN_ID * GW_RSLT_CD : "1200" TRAN_ID
@ -209,114 +171,4 @@ public class CmmNiceCiUtils {
if(!tranId.equals(resHeader.getTranId())) throw BizRuntimeException.create(messageSource.getMessage("fail.api.nice.invalid.tranId")); if(!tranId.equals(resHeader.getTranId())) throw BizRuntimeException.create(messageSource.getMessage("fail.api.nice.invalid.tranId"));
return t; return t;
} }
public static String generateLengthUuid(int length) {
final String allChars = UUID.randomUUID().toString().replace("-", "");
final Random random = new Random();
final char[] otp = new char[length];
for (int i = 0; i < length; i++) {
otp[i] = allChars.charAt(random.nextInt(allChars.length()));
}
return String.valueOf(otp);
}
/**
* sha256
*
* @param text
* @return
* @throws IOException
* @throws NoSuchAlgorithmException
*/
public static String hexSha256(final String text) {
final StringBuffer sbuf = new StringBuffer();
try {
final MessageDigest mDigest = MessageDigest.getInstance("SHA-256");
mDigest.update(text.getBytes());
final byte[] msgStr = mDigest.digest();
for(int i = 0; i < msgStr.length; i++) {
final byte tmpStrByte = msgStr[i];
final String tmpEncTxt = Integer.toString((tmpStrByte & 0xff) + 0x100, 16).substring(1);
sbuf.append(tmpEncTxt);
}
} catch (NoSuchAlgorithmException nae){
throw BizRuntimeException.create(nae.getMessage());
}
return sbuf.toString();
}
/**
* <pre>
* Nice ci
* Base64 encoding return
* @param key
* @param iv
* @param planText
* @return String Base64 encoding data
* </pre>
*/
public static String encodeAesData(final String key, final String iv, final String planText) {
final SecretKey secureKey = new SecretKeySpec(key.getBytes(), "AES");
try {
final Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, secureKey, new IvParameterSpec(iv.getBytes()));
final byte[] encData = cipher.doFinal(planText.trim().getBytes(StandardCharsets.UTF_8));
return Base64.getEncoder().encodeToString(encData);
}catch (NoSuchPaddingException | NoSuchAlgorithmException e){
throw BizRuntimeException.create(e.getMessage());
} catch (InvalidAlgorithmParameterException | InvalidKeyException e) {
throw BizRuntimeException.create(e.getMessage());
} catch (IllegalBlockSizeException | BadPaddingException e) {
throw BizRuntimeException.create(e.getMessage());
}
}
/**
* <pre>
* Hmac (integrity_value)
* @param hmacKey
* @param message
*
* @return String
* </pre>
*/
public static String encodeHmacSha256(final String hmacKey, final String message) {
try {
final Mac mac = Mac.getInstance("HmacSHA256");
final SecretKeySpec sks = new SecretKeySpec(hmacKey.getBytes(), "HmacSHA256");
mac.init(sks);
final byte[] hmac256 = mac.doFinal(message.getBytes());
return Base64.getEncoder().encodeToString(hmac256);
}catch (NoSuchAlgorithmException|InvalidKeyException e){
throw BizRuntimeException.create(e.getMessage());
}
}
public static String decodeAesData(String encData, String key, String iv) {
final byte[] respDataEnc = Base64.getDecoder().decode(encData.getBytes());
final SecretKey secureKey = new SecretKeySpec(key.getBytes(), "AES");
try {
final Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, secureKey, new IvParameterSpec(iv.getBytes()));
final byte[] decrypted = cipher.doFinal(respDataEnc);
return new String(decrypted);
}catch (NoSuchPaddingException|NoSuchAlgorithmException e){
throw BizRuntimeException.create(e.getMessage());
} catch (InvalidAlgorithmParameterException|InvalidKeyException e) {
throw BizRuntimeException.create(e.getMessage());
} catch (IllegalBlockSizeException|BadPaddingException e) {
throw BizRuntimeException.create(e.getMessage());
}
}
} }

@ -6,7 +6,7 @@ import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiInfo;
import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.SymkeyRegInfo; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymkeyRegInfo;
import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse;
/** /**
@ -28,7 +28,7 @@ public interface INiceCiService {
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 기관용 Token // 기관용 Token
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
TokenResponse generateToken(final NiceCiInfo dto); NiceTokenResponse generateToken(final NiceCiInfo dto);
TokenRevokeResponse revokeToken(final NiceCiInfo dto); TokenRevokeResponse revokeToken(final NiceCiInfo dto);
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 기관용 Token // 기관용 Token

@ -4,6 +4,7 @@ import kr.xit.biz.ens.model.nice.NiceCiDTO.*;
import kr.xit.core.spring.annotation.TraceLogging; import kr.xit.core.spring.annotation.TraceLogging;
import kr.xit.core.support.utils.DateUtils; import kr.xit.core.support.utils.DateUtils;
import kr.xit.core.support.utils.JsonUtils; import kr.xit.core.support.utils.JsonUtils;
import kr.xit.ens.cmm.CmmEnsUtils;
import kr.xit.ens.nice.cmm.CmmNiceCiUtils; import kr.xit.ens.nice.cmm.CmmNiceCiUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -41,13 +42,13 @@ public class NiceCiDummyTestService extends EgovAbstractServiceImpl {
* @return TokenResponse * @return TokenResponse
*/ */
@TraceLogging @TraceLogging
public TokenResponse generateToken(){ public NiceTokenResponse generateToken(){
final TokenRequest tokenRequest = TokenRequest.builder().build(); final NiceTokenRequest tokenRequest = NiceTokenRequest.builder().build();
CmmNiceCiUtils.validate(tokenRequest); CmmEnsUtils.validate(tokenRequest);
log.debug("{}", tokenRequest); log.debug("{}", tokenRequest);
return TokenResponse.builder() return NiceTokenResponse.builder()
.dataHeader(ResponseDataHeader.builder() .dataHeader(ResponseDataHeader.builder()
.gwRsltCd("1200") .gwRsltCd("1200")
.gwRsltMsg("오류없음") .gwRsltMsg("오류없음")
@ -99,14 +100,14 @@ public class NiceCiDummyTestService extends EgovAbstractServiceImpl {
final PublickeyRequest pubReqDTO = PublickeyRequest.builder() final PublickeyRequest pubReqDTO = PublickeyRequest.builder()
.dataHeader(RequestDataHeader.builder() .dataHeader(RequestDataHeader.builder()
.cntyId(CNTY_CD) .cntyId(CNTY_CD)
.tranId(CmmNiceCiUtils.generateLengthUuid(24)) .tranId(CmmEnsUtils.generateLengthUuid(24))
.build()) .build())
.dataBody(PublickeyReqDataBody.builder() .dataBody(PublickeyReqDataBody.builder()
.reqDtim(todayDt) .reqDtim(todayDt)
.build()) .build())
.build(); .build();
log.debug("{}", pubReqDTO); log.debug("{}", pubReqDTO);
CmmNiceCiUtils.validate(pubReqDTO); CmmEnsUtils.validate(pubReqDTO);
return PublickeyResponse.builder() return PublickeyResponse.builder()
.dataHeader(ResponseDataHeader.builder() .dataHeader(ResponseDataHeader.builder()
@ -146,14 +147,14 @@ public class NiceCiDummyTestService extends EgovAbstractServiceImpl {
SymmetrickeyRequest symReqDTO = SymmetrickeyRequest.builder() SymmetrickeyRequest symReqDTO = SymmetrickeyRequest.builder()
.dataHeader(RequestDataHeader.builder() .dataHeader(RequestDataHeader.builder()
.cntyId(CNTY_CD) .cntyId(CNTY_CD)
.tranId(CmmNiceCiUtils.generateLengthUuid(24)) .tranId(CmmEnsUtils.generateLengthUuid(24))
.build()) .build())
.dataBody(SymmetrickeyReqDataBody.builder() .dataBody(SymmetrickeyReqDataBody.builder()
.pubkeyVersion(niceDTO.getKeyVersion()) .pubkeyVersion(niceDTO.getKeyVersion())
.symkeyRegInfo(encSymkeyRegInfo) .symkeyRegInfo(encSymkeyRegInfo)
.build()) .build())
.build(); .build();
CmmNiceCiUtils.validate(symReqDTO); CmmEnsUtils.validate(symReqDTO);
return SymmetrickeyResponse.builder() return SymmetrickeyResponse.builder()
.dataHeader(ResponseDataHeader.builder() .dataHeader(ResponseDataHeader.builder()
@ -183,15 +184,15 @@ public class NiceCiDummyTestService extends EgovAbstractServiceImpl {
// 아이핀 CI 요청 // 아이핀 CI 요청
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
public IpinCiResponse requestCi(final IpinCiReqEncData encDataDTO, final NiceCiInfo niceDTO) { public IpinCiResponse requestCi(final IpinCiReqEncData encDataDTO, final NiceCiInfo niceDTO) {
CmmNiceCiUtils.validate(encDataDTO); CmmEnsUtils.validate(encDataDTO);
final String jsonEncData = CmmNiceCiUtils.encodeAesData(niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv(), JsonUtils.toJson(encDataDTO)); final String jsonEncData = CmmEnsUtils.encodeAesData(niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv(), JsonUtils.toJson(encDataDTO));
final String integrityValue = CmmNiceCiUtils.encodeHmacSha256(niceDTO.getCurSymkeyHmacKey(), jsonEncData); final String integrityValue = CmmEnsUtils.encodeHmacSha256(niceDTO.getCurSymkeyHmacKey(), jsonEncData);
final IpinCiRequest ipinCiRequest = IpinCiRequest.builder() final IpinCiRequest ipinCiRequest = IpinCiRequest.builder()
.dataHeader(RequestDataHeader.builder() .dataHeader(RequestDataHeader.builder()
.cntyId(CNTY_CD) .cntyId(CNTY_CD)
.tranId(CmmNiceCiUtils.generateLengthUuid(24)) .tranId(CmmEnsUtils.generateLengthUuid(24))
.build()) .build())
.dataBody(IpinCiReqDataBody.builder() .dataBody(IpinCiReqDataBody.builder()
.symkeyVersion(niceDTO.getCurSymkeyVersion()) .symkeyVersion(niceDTO.getCurSymkeyVersion())
@ -199,7 +200,7 @@ public class NiceCiDummyTestService extends EgovAbstractServiceImpl {
.integrityValue(integrityValue) .integrityValue(integrityValue)
.build()) .build())
.build(); .build();
CmmNiceCiUtils.validate(ipinCiRequest); CmmEnsUtils.validate(ipinCiRequest);
return IpinCiResponse.builder() return IpinCiResponse.builder()

@ -16,13 +16,14 @@ import kr.xit.biz.ens.model.nice.NiceCiDTO.SymkeyRegInfo;
import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyReqDataBody; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyReqDataBody;
import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyRequest;
import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenRequest;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse;
import kr.xit.core.spring.annotation.TraceLogging; import kr.xit.core.spring.annotation.TraceLogging;
import kr.xit.core.spring.util.ApiWebClientUtil; import kr.xit.core.spring.util.ApiWebClientUtil;
import kr.xit.core.support.utils.DateUtils; import kr.xit.core.support.utils.DateUtils;
import kr.xit.core.support.utils.JsonUtils; import kr.xit.core.support.utils.JsonUtils;
import kr.xit.ens.cmm.CmmEnsUtils;
import kr.xit.ens.nice.cmm.CmmNiceCiUtils; import kr.xit.ens.nice.cmm.CmmNiceCiUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -84,9 +85,9 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
*/ */
@Override @Override
@TraceLogging @TraceLogging
public TokenResponse generateToken(final NiceCiInfo niceDTO){ public NiceTokenResponse generateToken(final NiceCiInfo niceDTO){
final TokenRequest tokenRequest = TokenRequest.builder().build(); final NiceTokenRequest tokenRequest = NiceTokenRequest.builder().build();
CmmNiceCiUtils.validate(tokenRequest); CmmEnsUtils.validate(tokenRequest);
final Map<String,String> map = new HashMap<>(); final Map<String,String> map = new HashMap<>();
map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
@ -105,7 +106,7 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
) )
); );
return webClient.exchange(HOST + API_GENERATE_TOKEN, HttpMethod.POST, JsonUtils.toJson(tokenRequest), TokenResponse.class, map); return webClient.exchange(HOST + API_GENERATE_TOKEN, HttpMethod.POST, JsonUtils.toJson(tokenRequest), NiceTokenResponse.class, map);
} }
/** /**
@ -158,7 +159,7 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
.reqDtim(todayDt) .reqDtim(todayDt)
.build()) .build())
.build(); .build();
CmmNiceCiUtils.validate(pubReqDTO); CmmEnsUtils.validate(pubReqDTO);
final PublickeyResponse pubResDTO = webClient.exchange( final PublickeyResponse pubResDTO = webClient.exchange(
HOST + API_GENERATE_TOKEN, HOST + API_GENERATE_TOKEN,
@ -209,7 +210,7 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
.symkeyRegInfo(encSymkeyRegInfo) .symkeyRegInfo(encSymkeyRegInfo)
.build()) .build())
.build(); .build();
CmmNiceCiUtils.validate(reqDTO); CmmEnsUtils.validate(reqDTO);
final Map<String,String> headerMap = CmmNiceCiUtils.getHeaderMap( final Map<String,String> headerMap = CmmNiceCiUtils.getHeaderMap(
MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE,
@ -237,10 +238,10 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
// 아이핀 CI 요청 // 아이핀 CI 요청
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
public IpinCiResponse requestCi(final String tranId, final IpinCiReqEncData encDataDTO, final NiceCiInfo niceDTO) { public IpinCiResponse requestCi(final String tranId, final IpinCiReqEncData encDataDTO, final NiceCiInfo niceDTO) {
CmmNiceCiUtils.validate(encDataDTO); CmmEnsUtils.validate(encDataDTO);
final String jsonEncData = CmmNiceCiUtils.encodeAesData(niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv(), JsonUtils.toJson(encDataDTO)); final String jsonEncData = CmmEnsUtils.encodeAesData(niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv(), JsonUtils.toJson(encDataDTO));
final String integrityValue = CmmNiceCiUtils.encodeHmacSha256(niceDTO.getCurSymkeyHmacKey(), jsonEncData); final String integrityValue = CmmEnsUtils.encodeHmacSha256(niceDTO.getCurSymkeyHmacKey(), jsonEncData);
final IpinCiRequest ipinCiRequest = IpinCiRequest.builder() final IpinCiRequest ipinCiRequest = IpinCiRequest.builder()
.dataHeader(RequestDataHeader.builder() .dataHeader(RequestDataHeader.builder()
@ -253,7 +254,7 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
.integrityValue(integrityValue) .integrityValue(integrityValue)
.build()) .build())
.build(); .build();
CmmNiceCiUtils.validate(ipinCiRequest); CmmEnsUtils.validate(ipinCiRequest);
final Map<String,String> headerMap = new HashMap<>(); final Map<String,String> headerMap = new HashMap<>();
headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);

@ -8,6 +8,7 @@ import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest;
import kr.xit.core.model.ApiResponseDTO; import kr.xit.core.model.ApiResponseDTO;
import kr.xit.core.support.utils.DateUtils; import kr.xit.core.support.utils.DateUtils;
import kr.xit.core.support.utils.IpMacUtils; import kr.xit.core.support.utils.IpMacUtils;
import kr.xit.ens.cmm.CmmEnsUtils;
import kr.xit.ens.nice.cmm.CmmNiceCiUtils; import kr.xit.ens.nice.cmm.CmmNiceCiUtils;
import kr.xit.ens.nice.service.INiceCiService; import kr.xit.ens.nice.service.INiceCiService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -72,7 +73,7 @@ public class NiceCiController {
public ApiResponseDTO<?> requestPublickey(@RequestBody final NiceCiRequest reqDTO) { public ApiResponseDTO<?> requestPublickey(@RequestBody final NiceCiRequest reqDTO) {
return ApiResponseDTO.success( return ApiResponseDTO.success(
service.requestPublickey( service.requestPublickey(
CmmNiceCiUtils.generateLengthUuid(24), CmmEnsUtils.generateLengthUuid(24),
CmmNiceCiUtils.getNiceCiInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()) CmmNiceCiUtils.getNiceCiInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode())
) )
); );
@ -89,7 +90,7 @@ public class NiceCiController {
public ApiResponseDTO<?> requestRegSymmetrickey(@RequestBody final NiceCiRequest reqDTO) { public ApiResponseDTO<?> requestRegSymmetrickey(@RequestBody final NiceCiRequest reqDTO) {
return ApiResponseDTO.success( return ApiResponseDTO.success(
service.requestRegSymmetrickey( service.requestRegSymmetrickey(
CmmNiceCiUtils.generateLengthUuid(24), CmmEnsUtils.generateLengthUuid(24),
null, null,
CmmNiceCiUtils.getPublickeyNiceCiInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()) CmmNiceCiUtils.getPublickeyNiceCiInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode())
) )
@ -112,14 +113,14 @@ public class NiceCiController {
.siteCode(niceDTO.getSiteCode()) .siteCode(niceDTO.getSiteCode())
//.infoReqType() //default: 1-CI제공 //.infoReqType() //default: 1-CI제공
.juminId(reqDTO.getJuminId()) .juminId(reqDTO.getJuminId())
.reqNo(CmmNiceCiUtils.generateLengthUuid(30)) .reqNo(CmmEnsUtils.generateLengthUuid(30))
.reqDtim(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss")) .reqDtim(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss"))
.clientIp(IpMacUtils.getIpAddress().get(0)) .clientIp(IpMacUtils.getIpAddress().get(0))
.build(); .build();
return ApiResponseDTO.success( return ApiResponseDTO.success(
service.requestCi( service.requestCi(
CmmNiceCiUtils.generateLengthUuid(24), CmmEnsUtils.generateLengthUuid(24),
encDataDTO, encDataDTO,
CmmNiceCiUtils.getPublickeyNiceCiInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()) CmmNiceCiUtils.getPublickeyNiceCiInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode())
) )

@ -8,6 +8,7 @@ import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest;
import kr.xit.core.model.ApiResponseDTO; import kr.xit.core.model.ApiResponseDTO;
import kr.xit.core.support.utils.DateUtils; import kr.xit.core.support.utils.DateUtils;
import kr.xit.core.support.utils.IpMacUtils; import kr.xit.core.support.utils.IpMacUtils;
import kr.xit.ens.cmm.CmmEnsUtils;
import kr.xit.ens.nice.cmm.CmmNiceCiUtils; import kr.xit.ens.nice.cmm.CmmNiceCiUtils;
import kr.xit.ens.nice.service.NiceCiDummyTestService; import kr.xit.ens.nice.service.NiceCiDummyTestService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -94,7 +95,7 @@ public class NiceCiDummyTestController {
.siteCode(niceDTO.getSiteCode()) .siteCode(niceDTO.getSiteCode())
//.infoReqType() //default: 1-CI제공 //.infoReqType() //default: 1-CI제공
.juminId(reqDTO.getJuminId()) .juminId(reqDTO.getJuminId())
.reqNo(CmmNiceCiUtils.generateLengthUuid(30)) .reqNo(CmmEnsUtils.generateLengthUuid(30))
.reqDtim(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss")) .reqDtim(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss"))
.clientIp(IpMacUtils.getIpAddress().get(0)) .clientIp(IpMacUtils.getIpAddress().get(0))
.build(); .build();

@ -39,6 +39,11 @@ contract:
ci: /digital/niceid/cert/v1.0/ipin/addinfo/ci ci: /digital/niceid/cert/v1.0/ipin/addinfo/ci
kt: kt:
dummy: true dummy: true
host: http://172.16.0.13:10210/ONLWeb/api/pf/blacklist/reg # vpn 사용전
host: http://172.16.0.13:10210/ONLWeb
# vpn 사용
# host: http://211.43.10.163:10210/ONLWeb
# 운영
#host: http://172.16.1.182:10210/ONLWeb
# signgu-code: 11000 # signgu-code: 11000
# ffnlg-code: 11 # ffnlg-code: 11

@ -3,4 +3,6 @@
#------------------------------------------------ #------------------------------------------------
fail.api.nice.info=NICE \uC778\uC99D \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. fail.api.nice.info=NICE \uC778\uC99D \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.
fail.api.nice.revoke.token=\uD1A0\uD070(NICE) \uD3D0\uAE30\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4 fail.api.nice.revoke.token=\uD1A0\uD070(NICE) \uD3D0\uAE30\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4
fail.api.nice.invalid.tranId=NICE \uC778\uC99D \uC694\uCCAD\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4(TRAN_ID \uBD88\uC77C\uCE58). fail.api.nice.invalid.tranId=NICE \uC778\uC99D \uC694\uCCAD\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4(TRAN_ID \uBD88\uC77C\uCE58)
fail.api.kt.info=KT \uC778\uC99D \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.

Loading…
Cancel
Save