feat: Nice CI API 반영

dev
gitea-관리자 1 year ago
parent 5757839202
commit f6cbc2d057

@ -45,8 +45,9 @@ public class CmmEnsCacheService implements ICmmEnsCacheService {
/** /**
* Nice CI cache load * Nice CI cache load
* @param dto NiceCiRequestDTO * @param signguCode String
* @return CrtfInfo * @param ffnlgCode String
* @return NiceCiInfo
*/ */
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Cacheable(cacheNames = "niceCiInfo", keyGenerator = "simpleKeyGenerator") @Cacheable(cacheNames = "niceCiInfo", keyGenerator = "simpleKeyGenerator")
@ -56,8 +57,8 @@ public class CmmEnsCacheService implements ICmmEnsCacheService {
/** /**
* Nice CI cache remove * Nice CI cache remove
* @param signguCode * @param signguCode String
* @param ffnlgCode * @param ffnlgCode String
*/ */
@Transactional(readOnly = true) @Transactional(readOnly = true)
@CacheEvict(cacheNames = "niceCiInfo", keyGenerator = "simpleKeyGenerator") @CacheEvict(cacheNames = "niceCiInfo", keyGenerator = "simpleKeyGenerator")
@ -65,9 +66,8 @@ public class CmmEnsCacheService implements ICmmEnsCacheService {
} }
/** /**
* KT / KAKAO cache load * KT / KAKAO / postplus / epost cache load
* @param signguCode * @param dto CmmEnsRequestDTO
* @param ffnlgCode
* @return CmmEnsRlaybsnmDTO * @return CmmEnsRlaybsnmDTO
*/ */
@Transactional(readOnly = true) @Transactional(readOnly = true)
@ -77,9 +77,8 @@ public class CmmEnsCacheService implements ICmmEnsCacheService {
} }
/** /**
* KT / KAKAO cache remove * KT / KAKAO / postplus / epost cache remove
* @param signguCode * @param dto CmmEnsRequestDTO
* @param ffnlgCode
*/ */
@Transactional(readOnly = true) @Transactional(readOnly = true)
@CacheEvict(cacheNames = "rlaybsnmInfo", keyGenerator = "simpleKeyGenerator") @CacheEvict(cacheNames = "rlaybsnmInfo", keyGenerator = "simpleKeyGenerator")
@ -95,7 +94,7 @@ public class CmmEnsCacheService implements ICmmEnsCacheService {
Cache cache = ((CaffeineCache) cacheManager.getCache(cacheName)).getNativeCache(); Cache cache = ((CaffeineCache) cacheManager.getCache(cacheName)).getNativeCache();
for(Object key : cache.asMap().keySet()) { for(Object key : cache.asMap().keySet()) {
Object value = cache.getIfPresent(key); //Object value = cache.getIfPresent(key);
log.info("key: {}", key); log.info("key: {}", key);
//log.info("key: {} - value: {}", key, value.toString()); //log.info("key: {} - value: {}", key, value.toString());
} }

@ -3,26 +3,21 @@ package kr.xit.biz.nice.service;
import egovframework.com.cmm.EgovMessageSource; import egovframework.com.cmm.EgovMessageSource;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import kr.xit.biz.cmm.service.CmmEnsCacheService; import kr.xit.biz.cmm.service.CmmEnsCacheService;
import kr.xit.biz.common.ApiConstants.NiceCiWrkDiv;
import kr.xit.biz.common.ApiConstants.SignguCode; import kr.xit.biz.common.ApiConstants.SignguCode;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResDataBody; import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResEncData;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResponse;
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.NiceCiRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest;
import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResDataBody; import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResDataBody;
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.SymkeyRegInfo; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymkeyRegInfo;
import kr.xit.biz.ens.model.nice.NiceCiDTO.SymkeyStatInfo; 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.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.TokenRevokeResDataBody; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResDataBody;
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.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 lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -58,7 +53,6 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 기관용 Token // 기관용 Token
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
/** /**
* <pre> * <pre>
* NICE * NICE
@ -76,8 +70,8 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
final ResponseDataHeader dataHeader = tokenResponse.getDataHeader(); final ResponseDataHeader dataHeader = tokenResponse.getDataHeader();
if(dataHeader.getGwRsltCd().equals("1200")){ if(dataHeader.getGwRsltCd().equals("1200")){
TokenResDataBody dataBody = tokenResponse.getDataBody(); final TokenResDataBody dataBody = tokenResponse.getDataBody();
NiceCiInfo niceDTO = NiceCiInfo.builder() final NiceCiInfo niceDTO = NiceCiInfo.builder()
.signguCode(reqDTO.getSignguCode()) .signguCode(reqDTO.getSignguCode())
.ffnlgCode(reqDTO.getFfnlgCode()) .ffnlgCode(reqDTO.getFfnlgCode())
.accessToken(dataBody.getAccessToken()) .accessToken(dataBody.getAccessToken())
@ -91,7 +85,7 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
// 공개키 정보 캐쉬 삭제 // 공개키 정보 캐쉬 삭제
cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode()); cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode());
updateNiceCerfInfoSync(niceDTO, reqDTO); updateNiceCerfInfoSync(niceDTO, reqDTO, NiceCiWrkDiv.TOKEN);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@ -112,14 +106,14 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
@Transactional @Transactional
@Override @Override
public TokenRevokeResponse revokeToken(final NiceCiRequest reqDTO){ public TokenRevokeResponse revokeToken(final NiceCiRequest reqDTO){
TokenRevokeResponse resDTO = niceCiService.revokeToken(reqDTO); final TokenRevokeResponse resDTO = niceCiService.revokeToken(reqDTO);
final ResponseDataHeader dataHeader = resDTO.getDataHeader(); final ResponseDataHeader dataHeader = resDTO.getDataHeader();
if(dataHeader.getGwRsltCd().equals("1200")){ if(dataHeader.getGwRsltCd().equals("1200")){
TokenRevokeResDataBody dataBody = resDTO.getDataBody(); final TokenRevokeResDataBody dataBody = resDTO.getDataBody();
if(dataBody.isResult()){ if(dataBody.isResult()){
NiceCiInfo niceDTO = NiceCiInfo.builder() final NiceCiInfo niceDTO = NiceCiInfo.builder()
.signguCode(reqDTO.getSignguCode()) .signguCode(reqDTO.getSignguCode())
.ffnlgCode(reqDTO.getFfnlgCode()) .ffnlgCode(reqDTO.getFfnlgCode())
.accessToken(null) .accessToken(null)
@ -131,7 +125,7 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
// 공개키 정보 캐쉬 삭제 // 공개키 정보 캐쉬 삭제
cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode()); cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode());
updateNiceCerfInfoSync(niceDTO, reqDTO); updateNiceCerfInfoSync(niceDTO, reqDTO, NiceCiWrkDiv.TOKEN);
}else{ }else{
throw BizRuntimeException.create("토큰을 폐기하지 못했습니다."); throw BizRuntimeException.create("토큰을 폐기하지 못했습니다.");
} }
@ -139,13 +133,10 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
return resDTO; return resDTO;
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 기관용 Token
//--------------------------------------------------------------------------------
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 공개키(Publickey) // 공개키(Publickey)
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
/** /**
* <pre> * <pre>
* *
@ -157,21 +148,13 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
*/ */
@Transactional @Transactional
@Override @Override
public PublickeyResponse requestPublickey(final NiceCiRequest reqDTO) { public PublickeyResDataBody requestPublickey(final NiceCiRequest reqDTO) {
final NiceCiInfo niceDTO = CmmNiceCiUtils.getNiceCiInfo(reqDTO); final NiceCiInfo niceDTO = CmmNiceCiUtils.getNiceCiInfo(reqDTO);
if(ObjectUtils.isEmpty(niceDTO.getAccessToken())) throw BizRuntimeException.create(messageSource.getMessage("fail.api.nice.token.info")); if(ObjectUtils.isEmpty(niceDTO.getAccessToken())) throw BizRuntimeException.create(messageSource.getMessage("fail.api.nice.token.info"));
final PublickeyResponse pubResDTO = niceCiService.requestPublickey(reqDTO); final PublickeyResDataBody dataBody = niceCiService.requestPublickey(reqDTO);
//FIXME::공개키 정보 갱신 - Error code enum 전환
final ResponseDataHeader dataHeader = pubResDTO.getDataHeader();
final PublickeyResDataBody dataBody = pubResDTO.getDataBody();
// 3. 공개키 정보 update // 3. 공개키 정보 update
if(ObjectUtils.isNotEmpty(dataBody)
&& dataHeader.getGwRsltCd().equals("1200")
&& dataBody.getRspCd().equals("P000")
&& dataBody.getResultCd().equals("0000")){
niceDTO.setSiteCode(dataBody.getSiteCode()); niceDTO.setSiteCode(dataBody.getSiteCode());
niceDTO.setKeyVersion(dataBody.getKeyVersion()); niceDTO.setKeyVersion(dataBody.getKeyVersion());
niceDTO.setPublicKey(dataBody.getPublicKey()); niceDTO.setPublicKey(dataBody.getPublicKey());
@ -180,36 +163,15 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
// 공개키 정보 캐쉬 삭제 // 공개키 정보 캐쉬 삭제
cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode()); cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode());
//FIXME:: 교통시설운영처 또는 장사시설인 경우 sync ---------------------------------------- updateNiceCerfInfoSync(niceDTO, reqDTO, NiceCiWrkDiv.PUBLIC_KEY);
if(SignguCode.TRAFFIC.getCode().equals(niceDTO.getSignguCode())){
niceDTO.setSignguCode(SignguCode.FUNERAL.getCode());
niceCiMapper.updateNiceCrtfPublickey(niceDTO);
}
if(SignguCode.FUNERAL.getCode().equals(niceDTO.getSignguCode())){ return dataBody;
niceDTO.setSignguCode(SignguCode.TRAFFIC.getCode());
niceCiMapper.updateNiceCrtfPublickey(niceDTO);
} }
// 공개키 정보 캐쉬 삭제
cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode());
cacheService.logCache();
//------------------------------------------------------------------------------------
return pubResDTO;
}
//FIXME::에러처리 방안 설정후 적용 할 것
throw BizRuntimeException.create(JsonUtils.toJson(dataHeader));
}
//--------------------------------------------------------------------------------
// 공개키(Publickey)
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 대칭키 : symmetrickey // 대칭키 : symmetrickey
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
/** /**
* <pre> * <pre>
* 0. cache call * 0. cache call
@ -221,25 +183,14 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
*/ */
@Transactional @Transactional
@Override @Override
public SymmetrickeyResponse requestRegSymmetrickey(final NiceCiRequest reqDTO) { public SymkeyStatInfo requestRegSymmetrickey(final NiceCiRequest reqDTO) {
final String signguCode = reqDTO.getSignguCode();
final String ffnlgCode = reqDTO.getFfnlgCode();
//FIXME::NICE 연계이후 메소드 교체
final SymkeyRegInfo symkeyRegInfo = CmmNiceCiUtils.getSymkeyRegInfo(); final SymkeyRegInfo symkeyRegInfo = CmmNiceCiUtils.getSymkeyRegInfo();
SymmetrickeyResponse symResDTO = niceCiService.requestRegSymmetrickey(reqDTO, symkeyRegInfo); final SymkeyStatInfo symkeyStatInfo = niceCiService.requestRegSymmetrickey(reqDTO, symkeyRegInfo);
final NiceCiInfo niceDTO = NiceCiInfo.builder()
final ResponseDataHeader dataHeader = symResDTO.getDataHeader();
final SymmetrickeyResDataBody dataBody = symResDTO.getDataBody();
if(dataHeader.getGwRsltCd().equals("1200")
&& dataBody.getRspCd().equals("P000")
//FIXME:: "0007" 인 경우 확인 필요 - result_cd 0000, 0007일 경우 나감 (0007: key 중복 오류 (현재 및 직전에 사용한 Key 사용 불가)
&& dataBody.getResultCd().equals("0000")){
SymkeyStatInfo symkeyStatInfo = JsonUtils.toObject(dataBody.getSymkeyStatInfo(), SymkeyStatInfo.class);
NiceCiInfo niceDTO = NiceCiInfo.builder()
.signguCode(reqDTO.getSignguCode()) .signguCode(reqDTO.getSignguCode())
.ffnlgCode(reqDTO.getFfnlgCode()) .ffnlgCode(reqDTO.getFfnlgCode())
.build(); .build();
niceDTO.setBefSymkeyVersion(symkeyStatInfo.getBefSymkeyVersion()); niceDTO.setBefSymkeyVersion(symkeyStatInfo.getBefSymkeyVersion());
niceDTO.setBefSymkeyValidDtim(symkeyStatInfo.getBefValidDtim()); niceDTO.setBefSymkeyValidDtim(symkeyStatInfo.getBefValidDtim());
niceDTO.setBefSymkeyKey(niceDTO.getCurSymkeyKey()); niceDTO.setBefSymkeyKey(niceDTO.getCurSymkeyKey());
@ -256,74 +207,54 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
// 공개키 정보 캐쉬 삭제 // 공개키 정보 캐쉬 삭제
cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode()); cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode());
//FIXME:: 교통시설운영처 또는 장사시설인 경우 sync ---------------------------------------- updateNiceCerfInfoSync(niceDTO, reqDTO, NiceCiWrkDiv.SYM_KEY);
if(SignguCode.TRAFFIC.getCode().equals(niceDTO.getSignguCode())){
niceDTO.setSignguCode(SignguCode.FUNERAL.getCode());
niceCiMapper.updateNiceCrtfSymkey(niceDTO);
}
if(SignguCode.FUNERAL.getCode().equals(niceDTO.getSignguCode())){
niceDTO.setSignguCode(SignguCode.TRAFFIC.getCode());
niceCiMapper.updateNiceCrtfSymkey(niceDTO);
}
// 공개키 정보 캐쉬 삭제
cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode());
cacheService.logCache();
//------------------------------------------------------------------------------------
return symResDTO;
}else{ return symkeyStatInfo;
throw BizRuntimeException.create(JsonUtils.toJson(symResDTO));
} }
}
//--------------------------------------------------------------------------------
// 대칭키 : symmetrickey
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청 // 아이핀 CI 요청
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
public IpinCiResponse requestCi(final NiceCiRequest reqDTO) { public IpinCiResEncData requestCi(final NiceCiRequest reqDTO) {
IpinCiResponse ipinCiResponse = niceCiService.requestCi(reqDTO); return niceCiService.requestCi(reqDTO);
ResponseDataHeader resHeader = ipinCiResponse.getDataHeader();
IpinCiResDataBody resBody = ipinCiResponse.getDataBody();
String resEncData = resBody.getEncData();
//IpinCiResEncData resEncData = JsonUtils.toObject(resBody.getEncData(), IpinCiResEncData.class);
//FIXME::응답무결성 체크
// 응답으로온 intigrety_value와 응답 enc_data를 Hmac한 값을 비교
// 무결성체크가 완료되면 데이터를 보낸 대칭키로 복호화하여 데이터를 확인
NiceCiInfo niceDTO = CmmNiceCiUtils.getSymkeyNiceCiInfo(reqDTO);
String checkHmac = CmmEnsUtils.encodeHmacSha256(niceDTO.getCurSymkeyHmacKey(), resEncData);
if(resBody.getIntegrityValue().equals(checkHmac)){
String decData = CmmEnsUtils.decodeAesData(resEncData, niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv());
resBody.setEncData(decData);
}
return ipinCiResponse;
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
private void updateNiceCerfInfoSync(final NiceCiInfo niceDTO, final NiceCiRequest reqDTO) { /**
//FIXME:: 교통시설운영처 또는 장사시설인 경우 sync ---------------------------------------- * <pre>
* Nice CI sync
* @param niceDTO NiceCiInfo
* @param reqDTO NiceCiRequest
* @param wrkDiv NiceCiWrkDiv
* </pre>
*/
private void updateNiceCerfInfoSync(final NiceCiInfo niceDTO, final NiceCiRequest reqDTO, final NiceCiWrkDiv wrkDiv) {
// 교통시설운영처 또는 장사시설인 경우 sync ----------------------------------------
if(SignguCode.TRAFFIC.getCode().equals(reqDTO.getSignguCode())){ if(SignguCode.TRAFFIC.getCode().equals(reqDTO.getSignguCode())){
niceDTO.setSignguCode(SignguCode.FUNERAL.getCode()); niceDTO.setSignguCode(SignguCode.FUNERAL.getCode());
niceCiMapper.updateNiceCrtfToken(niceDTO);
} }
if(SignguCode.FUNERAL.getCode().equals(reqDTO.getSignguCode())){ if(SignguCode.FUNERAL.getCode().equals(reqDTO.getSignguCode())){
niceDTO.setSignguCode(SignguCode.TRAFFIC.getCode()); niceDTO.setSignguCode(SignguCode.TRAFFIC.getCode());
}
switch(wrkDiv){
case TOKEN:
niceCiMapper.updateNiceCrtfToken(niceDTO); niceCiMapper.updateNiceCrtfToken(niceDTO);
break;
case PUBLIC_KEY:
niceCiMapper.updateNiceCrtfPublickey(niceDTO);
break;
case SYM_KEY:
niceCiMapper.updateNiceCrtfSymkey(niceDTO);
break;
default:
break;
} }
// 공개키 정보 캐쉬 삭제 // 공개키 정보 캐쉬 삭제

@ -1,10 +1,10 @@
package kr.xit.biz.nice.service; package kr.xit.biz.nice.service;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResEncData;
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.SymmetrickeyResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResDataBody;
import kr.xit.biz.ens.model.nice.NiceCiDTO.SymkeyStatInfo;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse;
/** /**
@ -35,7 +35,7 @@ public interface IBizNiceCiService {
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 공개키(Publickey) // 공개키(Publickey)
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
PublickeyResponse requestPublickey(final NiceCiRequest reqDTO); PublickeyResDataBody requestPublickey(final NiceCiRequest reqDTO);
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 공개키(Publickey) // 공개키(Publickey)
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
@ -43,7 +43,7 @@ public interface IBizNiceCiService {
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 대칭키 : symmetrickey // 대칭키 : symmetrickey
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
SymmetrickeyResponse requestRegSymmetrickey(final NiceCiRequest reqDTO); SymkeyStatInfo requestRegSymmetrickey(final NiceCiRequest reqDTO);
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 대칭키 : symmetrickey // 대칭키 : symmetrickey
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
@ -51,7 +51,7 @@ public interface IBizNiceCiService {
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청 // 아이핀 CI 요청
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
IpinCiResponse requestCi(final NiceCiRequest reqDTO); IpinCiResEncData requestCi(final NiceCiRequest reqDTO);
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청 // 아이핀 CI 요청

@ -4,21 +4,13 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import kr.xit.biz.ens.model.nice.NiceCiDTO.CommonResponseDataBody;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResDataBody;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResEncData;
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.ResponseDataHeader;
import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.ResponseDataHeader;
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;
import kr.xit.core.support.utils.JsonUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -45,7 +37,6 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping(value = "/api/biz/nice/v1") @RequestMapping(value = "/api/biz/nice/v1")
public class BizNiceCiController { public class BizNiceCiController {
private static final String PARAM1 = """ private static final String PARAM1 = """
{ {
"signguCode": "88328", "signguCode": "88328",
@ -73,7 +64,7 @@ public class BizNiceCiController {
name = "교통시설운영처", name = "교통시설운영처",
value = PARAM1), value = PARAM1),
@ExampleObject( @ExampleObject(
name = "장사시설", name = "승화원",
value = PARAM2) value = PARAM2)
}) })
}) })
@ -92,7 +83,7 @@ public class BizNiceCiController {
name = "교통시설운영처", name = "교통시설운영처",
value = PARAM1), value = PARAM1),
@ExampleObject( @ExampleObject(
name = "장사시설", name = "승화원",
value = PARAM2) value = PARAM2)
}) })
}) })
@ -103,13 +94,10 @@ public class BizNiceCiController {
return niceTokenResponse(tokenRevokeResponse.getDataHeader(), tokenRevokeResponse.getDataBody()); return niceTokenResponse(tokenRevokeResponse.getDataHeader(), tokenRevokeResponse.getDataBody());
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 기관용 Token
//--------------------------------------------------------------------------------
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 공개키(Publickey) // 공개키(Publickey)
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
/** /**
* *
* @param reqDTO * @param reqDTO
@ -123,19 +111,16 @@ public class BizNiceCiController {
name = "교통시설운영처", name = "교통시설운영처",
value = PARAM1), value = PARAM1),
@ExampleObject( @ExampleObject(
name = "장사시설", name = "승화원",
value = PARAM2) value = PARAM2)
}) })
}) })
@Operation(summary = "공개키 요청", description = "공개키 요청") @Operation(summary = "공개키 요청", description = "공개키 요청")
@PostMapping(value = "/requestPublickey", produces = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "/requestPublickey", produces = MediaType.APPLICATION_JSON_VALUE)
public ApiResponseDTO<?> requestPublickey(@RequestBody final NiceCiRequest reqDTO) { public ApiResponseDTO<?> requestPublickey(@RequestBody final NiceCiRequest reqDTO) {
final PublickeyResponse publickeyResponse = service.requestPublickey(reqDTO); return ApiResponseDTO.success(service.requestPublickey(reqDTO));
return response(publickeyResponse.getDataHeader(), publickeyResponse.getDataBody());
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 공개키(Publickey)
//--------------------------------------------------------------------------------
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 대칭키 : symmetrickey // 대칭키 : symmetrickey
@ -148,19 +133,15 @@ public class BizNiceCiController {
name = "교통시설운영처", name = "교통시설운영처",
value = PARAM1), value = PARAM1),
@ExampleObject( @ExampleObject(
name = "장사시설", name = "승화원",
value = PARAM2) value = PARAM2)
}) })
}) })
@Operation(summary = "대칭키(symmetrickey) 등록 요청", description = "대칭키(symmetrickey) 등록 요청") @Operation(summary = "대칭키(symmetrickey) 등록 요청", description = "대칭키(symmetrickey) 등록 요청")
@PostMapping(value = "/requestRegSymmetrickey", produces = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "/requestRegSymmetrickey", produces = MediaType.APPLICATION_JSON_VALUE)
public ApiResponseDTO<?> requestRegSymmetrickey(@RequestBody final NiceCiRequest reqDTO) { public ApiResponseDTO<?> requestRegSymmetrickey(@RequestBody final NiceCiRequest reqDTO) {
final SymmetrickeyResponse symResponse = service.requestRegSymmetrickey(reqDTO); return ApiResponseDTO.success(service.requestRegSymmetrickey(reqDTO));
return response(symResponse.getDataHeader(), symResponse.getDataBody());
} }
//--------------------------------------------------------------------------------
// 대칭키 : symmetrickey
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
@ -174,33 +155,17 @@ public class BizNiceCiController {
name = "교통시설운영처", name = "교통시설운영처",
value = PARAM1), value = PARAM1),
@ExampleObject( @ExampleObject(
name = "장사시설", name = "승화원",
value = PARAM2) value = PARAM2)
}) })
}) })
@Operation(summary = "아이핀 CI 요청", description = "아이핀 CI 요청") @Operation(summary = "아이핀 CI 요청", description = "아이핀 CI 요청")
@PostMapping(value = "/requestCi", produces = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "/requestCi", produces = MediaType.APPLICATION_JSON_VALUE)
public ApiResponseDTO<?> requestCi(@RequestBody final NiceCiRequest reqDTO) { public ApiResponseDTO<?> requestCi(@RequestBody final NiceCiRequest reqDTO) {
final IpinCiResponse ipinCiResponse = service.requestCi(reqDTO); return ApiResponseDTO.success(service.requestCi(reqDTO));
ResponseDataHeader resHeader = ipinCiResponse.getDataHeader();
IpinCiResDataBody resBody = ipinCiResponse.getDataBody();
IpinCiResEncData resEncData = JsonUtils.toObject(resBody.getEncData(), IpinCiResEncData.class);
if(ObjectUtils.isNotEmpty(resBody) && resHeader.getGwRsltCd().equals("1200") && resBody.getRspCd().equals("P000") && resEncData.getResultCd().equals("0000")) {
return ApiResponseDTO.success(resBody);
}
if(ObjectUtils.isNotEmpty(resBody)) {
return ApiResponseDTO.error(
String.format("%s[%s]", resHeader.getGwRsltCd(), resBody.getRspCd()),
String.format("%s[%s]", resHeader.getGwRsltMsg(), resEncData.getResultCd())
);
}
return ApiResponseDTO.error(String.format("%s[%s]", resHeader.getGwRsltCd(), resHeader.getGwRsltMsg()));
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청
//--------------------------------------------------------------------------------
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
private <T> ApiResponseDTO<T> niceTokenResponse(final ResponseDataHeader resHeader, final T t){ private <T> ApiResponseDTO<T> niceTokenResponse(final ResponseDataHeader resHeader, final T t){
@ -209,19 +174,4 @@ public class BizNiceCiController {
} }
return ApiResponseDTO.error(resHeader.getGwRsltCd(), resHeader.getGwRsltMsg()); return ApiResponseDTO.error(resHeader.getGwRsltCd(), resHeader.getGwRsltMsg());
} }
private ApiResponseDTO<?> response(final ResponseDataHeader resHeader, final CommonResponseDataBody resBody){
if(ObjectUtils.isNotEmpty(resBody) && resHeader.getGwRsltCd().equals("1200") && resBody.getRspCd().equals("P000") && resBody.getResultCd().equals("0000")) {
return ApiResponseDTO.success(resBody);
}
if(ObjectUtils.isNotEmpty(resBody)) {
return ApiResponseDTO.error(
String.format("%s[%s]", resHeader.getGwRsltCd(), resBody.getRspCd()),
String.format("%s[%s]", resHeader.getGwRsltMsg(), resBody.getResultCd())
);
}
return ApiResponseDTO.error(String.format("%s[%s]", resHeader.getGwRsltCd(), resHeader.getGwRsltMsg()));
}
} }

@ -6,6 +6,8 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import kr.xit.biz.cmm.service.ICmmEnsCacheService; import kr.xit.biz.cmm.service.ICmmEnsCacheService;
import kr.xit.biz.common.ApiConstants.NiceCiWrkDiv;
import kr.xit.biz.ens.model.nice.NiceCiDTO.CommonResponseDataBody;
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.NiceCiRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest;
import kr.xit.biz.ens.model.nice.NiceCiDTO.ResponseDataHeader; import kr.xit.biz.ens.model.nice.NiceCiDTO.ResponseDataHeader;
@ -22,6 +24,7 @@ import kr.xit.ens.nice.service.INiceCiService;
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.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.util.Base64Utils; import org.springframework.util.Base64Utils;
@ -145,19 +148,55 @@ public class CmmNiceCiUtils {
return map; return map;
} }
public static String getFromResultCd(NiceCiWrkDiv wrkDiv, String resultCd){
final String preFix = "err.api.nice";
return switch(wrkDiv) {
case PUBLIC_KEY -> messageSource.getMessage(preFix + ".pubKey." + resultCd);
case SYM_KEY -> messageSource.getMessage(preFix + ".symKey." + resultCd);
case CI -> messageSource.getMessage(preFix + ".ci." + resultCd);
default -> StringUtils.EMPTY;
};
}
/** /**
* <pre> * <pre>
* GW_RSLT_CD : "1200" TRAN_ID * Nice CI : ||CI
* -> , * RW_RSLT_CD - 1200 && rsp_cd - P000 && result_cd - 0000
* @param tranId * RW_RSLT_CD - 1200 && rsp_cd - P000 && result_cd != 0000 return
* @param resHeader * -> message-api.properties err.api.nice.[pubKey|symKey|ci].[]
* @param t * @param tranId String
* @return T * @param resHeader ResponseDataHeader
* @param resBody CommonResponseDataBody
* </pre> * </pre>
*/ */
public static <T> T checkTranIdAndReturn(final String tranId, final ResponseDataHeader resHeader, T t){ public static void checkApiResponse(final String tranId, final ResponseDataHeader resHeader,
final CommonResponseDataBody resBody, final NiceCiWrkDiv wrkDiv) {
// 실패
if(!resHeader.getGwRsltCd().equals("1200")) {
throw BizRuntimeException.create(resHeader.getGwRsltCd(), resHeader.getGwRsltMsg());
}
// 성공(1200)시 tranId 체크
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;
// 실패
if(ObjectUtils.isNotEmpty(resBody) && !resBody.getRspCd().equals("P000")) {
throw BizRuntimeException.create(
String.format("%s[%s]", resHeader.getGwRsltCd(), resBody.getRspCd()),
String.format("%s[%s]", resHeader.getGwRsltMsg(), resBody.getRspMsg())
);
}
// 실패
if(ObjectUtils.isNotEmpty(resBody) && !resBody.getResultCd().equals("0000")) {
throw BizRuntimeException.create(
String.format("%s[%s-%s]", resHeader.getGwRsltCd(), resBody.getRspCd(),
resBody.getResultCd()),
String.format("%s[%s]", resHeader.getGwRsltMsg(),
CmmNiceCiUtils.getFromResultCd(wrkDiv, resBody.getResultCd()))
);
}
} }
} }

@ -1,11 +1,11 @@
package kr.xit.ens.nice.service; package kr.xit.ens.nice.service;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResEncData;
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.NiceTokenResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResDataBody;
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.SymkeyStatInfo;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse;
/** /**
@ -36,7 +36,7 @@ public interface INiceCiService {
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 공개키(Publickey) // 공개키(Publickey)
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
PublickeyResponse requestPublickey(final NiceCiRequest reqDTO); PublickeyResDataBody requestPublickey(final NiceCiRequest reqDTO);
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 공개키(Publickey) // 공개키(Publickey)
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
@ -44,7 +44,7 @@ public interface INiceCiService {
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 대칭키 : symmetrickey // 대칭키 : symmetrickey
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
SymmetrickeyResponse requestRegSymmetrickey(final NiceCiRequest reqDTO, final SymkeyStatInfo requestRegSymmetrickey(final NiceCiRequest reqDTO, final
SymkeyRegInfo symkeyRegInfo); SymkeyRegInfo symkeyRegInfo);
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 대칭키 : symmetrickey // 대칭키 : symmetrickey
@ -53,7 +53,7 @@ public interface INiceCiService {
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청 // 아이핀 CI 요청
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
IpinCiResponse requestCi(final NiceCiRequest reqDTO); IpinCiResEncData requestCi(final NiceCiRequest reqDTO);
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청 // 아이핀 CI 요청
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------

@ -4,23 +4,8 @@ import egovframework.com.cmm.EgovMessageSource;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiReqDataBody; import kr.xit.biz.common.ApiConstants.NiceCiWrkDiv;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiReqEncData; import kr.xit.biz.ens.model.nice.NiceCiDTO.*;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiRequest;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiInfo;
import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest;
import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenRequest;
import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceTokenResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyReqDataBody;
import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyRequest;
import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.RequestDataHeader;
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.SymmetrickeyRequest;
import kr.xit.biz.ens.model.nice.NiceCiDTO.SymmetrickeyResponse;
import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse;
import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.exception.BizRuntimeException;
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;
@ -84,7 +69,6 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 기관용 Token // 기관용 Token
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
/** /**
* *
* @return TokenResponse * @return TokenResponse
@ -144,21 +128,17 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
); );
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 기관용 Token
//--------------------------------------------------------------------------------
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 공개키(Publickey) // 공개키(Publickey)
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
@Override @Override
@TraceLogging @TraceLogging
public PublickeyResponse requestPublickey(final NiceCiRequest reqDTO) { public PublickeyResDataBody requestPublickey(final NiceCiRequest reqDTO) {
final NiceCiInfo niceDTO = CmmNiceCiUtils.getNiceCiInfo(reqDTO); final NiceCiInfo niceDTO = CmmNiceCiUtils.getNiceCiInfo(reqDTO);
if(ObjectUtils.isEmpty(niceDTO.getAccessToken())) throw BizRuntimeException.create(messageSource.getMessage("fail.api.nice.token.info")); if(ObjectUtils.isEmpty(niceDTO.getAccessToken())) throw BizRuntimeException.create(messageSource.getMessage("fail.api.nice.token.info"));
final String todayDt = DateUtils.getTodayAndNowTime("yyyyMMddHHmmss"); final String todayDt = DateUtils.getTodayAndNowTime("yyyyMMddHHmmss");
final String tranId = CmmEnsUtils.generateLengthUuid(24); final String tranId = CmmEnsUtils.generateLengthUuid(24);
final PublickeyRequest pubReqDTO = PublickeyRequest.builder() final PublickeyRequest pubReqDTO = PublickeyRequest.builder()
.dataHeader(RequestDataHeader.builder() .dataHeader(RequestDataHeader.builder()
@ -185,18 +165,15 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
PublickeyResponse.class, PublickeyResponse.class,
headerMap headerMap
); );
CmmNiceCiUtils.checkApiResponse(tranId, pubResDTO.getDataHeader(), pubResDTO.getDataBody(), NiceCiWrkDiv.PUBLIC_KEY);
return CmmNiceCiUtils.checkTranIdAndReturn(tranId, pubResDTO.getDataHeader(), pubResDTO); return pubResDTO.getDataBody();
} }
//--------------------------------------------------------------------------------
// 공개키(Publickey)
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 대칭키 : symmetrickey // 대칭키 : symmetrickey
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
/** /**
* <pre> * <pre>
* 0. cache call * 0. cache call
@ -207,7 +184,7 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
* </pre> * </pre>
*/ */
@Override @Override
public SymmetrickeyResponse requestRegSymmetrickey(final NiceCiRequest reqDTO, final SymkeyRegInfo symkeyRegInfo) { public SymkeyStatInfo requestRegSymmetrickey(final NiceCiRequest reqDTO, final SymkeyRegInfo symkeyRegInfo) {
final NiceCiInfo niceDTO = CmmNiceCiUtils.getPublickeyNiceCiInfo(reqDTO); final NiceCiInfo niceDTO = CmmNiceCiUtils.getPublickeyNiceCiInfo(reqDTO);
// siteCode set // siteCode set
symkeyRegInfo.setSiteCode(niceDTO.getSiteCode()); symkeyRegInfo.setSiteCode(niceDTO.getSiteCode());
@ -241,8 +218,10 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
SymmetrickeyResponse.class, SymmetrickeyResponse.class,
headerMap headerMap
); );
SymmetrickeyResDataBody dataBody = symResDTO.getDataBody();
CmmNiceCiUtils.checkApiResponse(tranId, symResDTO.getDataHeader(), dataBody, NiceCiWrkDiv.SYM_KEY);
return CmmNiceCiUtils.checkTranIdAndReturn(tranId, symResDTO.getDataHeader(), symResDTO); return JsonUtils.toObject(dataBody.getSymkeyStatInfo(), SymkeyStatInfo.class);
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 대칭키 : symmetrickey // 대칭키 : symmetrickey
@ -251,9 +230,9 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청 // 아이핀 CI 요청
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
public IpinCiResponse requestCi(final NiceCiRequest reqDTO) { public IpinCiResEncData requestCi(final NiceCiRequest reqDTO) {
NiceCiInfo niceDTO = CmmNiceCiUtils.getSymkeyNiceCiInfo(reqDTO); final NiceCiInfo niceDTO = CmmNiceCiUtils.getSymkeyNiceCiInfo(reqDTO);
IpinCiReqEncData encDataDTO = IpinCiReqEncData.builder() final IpinCiReqEncData encDataDTO = IpinCiReqEncData.builder()
.siteCode(niceDTO.getSiteCode()) .siteCode(niceDTO.getSiteCode())
//.infoReqType() //default: 1-CI제공 //.infoReqType() //default: 1-CI제공
.juminId(reqDTO.getJuminId()) .juminId(reqDTO.getJuminId())
@ -266,7 +245,6 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
final String tranId = CmmEnsUtils.generateLengthUuid(24); final String tranId = CmmEnsUtils.generateLengthUuid(24);
final String jsonEncData = CmmEnsUtils.encodeAesData(niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv(), JsonUtils.toJson(encDataDTO)); final String jsonEncData = CmmEnsUtils.encodeAesData(niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv(), JsonUtils.toJson(encDataDTO));
final String integrityValue = CmmEnsUtils.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()
.cntyCd(CNTY_CD) .cntyCd(CNTY_CD)
@ -286,14 +264,12 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
String.format("%s %s", String.format("%s %s",
AUTH_TYPE_BASIC, AUTH_TYPE_BASIC,
Base64Utils.encodeToString( Base64Utils.encodeToString(
Base64Utils.encode(
String.format( String.format(
"%s:%s", "%s:%s",
niceDTO.getClientId(), niceDTO.getClientId(),
niceDTO.getClientSecret()).getBytes(StandardCharsets.UTF_8) niceDTO.getClientSecret()).getBytes(StandardCharsets.UTF_8)
) )
) )
)
); );
headerMap.put("ProductID", niceDTO.getProductId()); headerMap.put("ProductID", niceDTO.getProductId());
@ -305,10 +281,19 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
headerMap headerMap
); );
return CmmNiceCiUtils.checkTranIdAndReturn(tranId, ipinCiResponse.getDataHeader(), ipinCiResponse); final IpinCiResDataBody dataBody = ipinCiResponse.getDataBody();
CmmNiceCiUtils.checkApiResponse(tranId, ipinCiResponse.getDataHeader(), ipinCiResponse.getDataBody(), NiceCiWrkDiv.CI);
final String encData = dataBody.getEncData();
final String resIntegrityValue = dataBody.getIntegrityValue();
final String checkData = CmmEnsUtils.encodeHmacSha256(niceDTO.getCurSymkeyHmacKey(), encData);
if(resIntegrityValue.equals(checkData)){
final String decStr = CmmEnsUtils.decodeAesData(encData, niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv());
dataBody.setEncData(decStr);
return JsonUtils.toObject(decStr, IpinCiResEncData.class);
}
throw BizRuntimeException.create("CI 변환 응답 데이터에 오류가 있습니다(무결성 체크 오류)");
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청
//--------------------------------------------------------------------------------
} }

@ -1,6 +1,8 @@
package kr.xit.ens.nice.web; package kr.xit.ens.nice.web;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest;
import kr.xit.core.model.ApiResponseDTO; import kr.xit.core.model.ApiResponseDTO;
@ -33,6 +35,21 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping(value = "/api/ens/nice/v1") @RequestMapping(value = "/api/ens/nice/v1")
public class NiceCiController { public class NiceCiController {
private static final String PARAM1 = """
{
"signguCode": "88328",
"ffnlgCode": "11",
"juminId": "9901011263512"
}
""";
private static final String PARAM2 = """
{
"signguCode": "88316",
"ffnlgCode": "11",
"juminId": "9901011263512"
}
""";
private final INiceCiService service; private final INiceCiService service;
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
@ -50,13 +67,10 @@ public class NiceCiController {
return ApiResponseDTO.success(service.revokeToken(reqDTO)); return ApiResponseDTO.success(service.revokeToken(reqDTO));
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 기관용 Token
//--------------------------------------------------------------------------------
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 공개키(Publickey) // 공개키(Publickey)
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
/** /**
* *
* @return * @return
@ -67,8 +81,6 @@ public class NiceCiController {
return ApiResponseDTO.success(service.requestPublickey(reqDTO)); return ApiResponseDTO.success(service.requestPublickey(reqDTO));
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 공개키(Publickey)
//--------------------------------------------------------------------------------
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 대칭키 : symmetrickey // 대칭키 : symmetrickey
@ -78,20 +90,27 @@ public class NiceCiController {
public ApiResponseDTO<?> requestRegSymmetrickey(@RequestBody final NiceCiRequest reqDTO) { public ApiResponseDTO<?> requestRegSymmetrickey(@RequestBody final NiceCiRequest reqDTO) {
return ApiResponseDTO.success(service.requestRegSymmetrickey(reqDTO, CmmNiceCiUtils.getSymkeyRegInfo())); return ApiResponseDTO.success(service.requestRegSymmetrickey(reqDTO, CmmNiceCiUtils.getSymkeyRegInfo()));
} }
//--------------------------------------------------------------------------------
// 대칭키 : symmetrickey
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청 // 아이핀 CI 요청
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = {
@Content(
mediaType = "application/json",
examples = {
@ExampleObject(
name = "교통시설운영처",
value = PARAM1),
@ExampleObject(
name = "승화원",
value = PARAM2)
})
})
@Operation(summary = "아이핀 CI 요청", description = "아이핀 CI 요청") @Operation(summary = "아이핀 CI 요청", description = "아이핀 CI 요청")
@PostMapping(value = "/requestCi", produces = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "/requestCi", produces = MediaType.APPLICATION_JSON_VALUE)
public ApiResponseDTO<?> requestCi(@RequestBody final NiceCiRequest reqDTO) { public ApiResponseDTO<?> requestCi(@RequestBody final NiceCiRequest reqDTO) {
return ApiResponseDTO.success(service.requestCi(reqDTO)); return ApiResponseDTO.success(service.requestCi(reqDTO));
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청
//--------------------------------------------------------------------------------
} }

@ -8,3 +8,32 @@ fail.api.nice.invalid.tranId=NICE \uC778\uC99D \uC694\uCCAD\uC5D0 \uC2E4\uD328\u
fail.api.rlaybsnm.info=\uBB38\uC11C\uC911\uACC4\uC790 \uC778\uC99D \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. fail.api.rlaybsnm.info=\uBB38\uC11C\uC911\uACC4\uC790 \uC778\uC99D \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.
fail.api.kt.token.request=KT \uD1A0\uD070 \uC694\uCCAD\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4. fail.api.kt.token.request=KT \uD1A0\uD070 \uC694\uCCAD\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.
err.api.nice.pubKey.0000=\uACF5\uAC1C\uD0A4\uBC1C\uAE09
err.api.nice.pubKey.0001=\uD544\uC218 \uC785\uB825\uAC12 \uC624\uB958
err.api.nice.pubKey.0003=\uACF5\uAC1C\uD0A4 \uBC1C\uAE09 \uB300\uC0C1 \uD68C\uC6D0\uC0AC \uC544\uB2D8
err.api.nice.pubKey.0099=\uAE30\uD0C0 \uC624\uB958
err.api.nice.symKey.0000=\uB300\uCE6D\uD0A4 \uBC1C\uAE09
err.api.nice.symKey.0001=\uACF5\uAC1C\uD0A4 \uAE30\uAC04 \uB9CC\uB8CC
err.api.nice.symKey.0002=\uACF5\uAC1C\uD0A4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C
err.api.nice.symKey.0003=\uACF5\uAC1C\uD0A4\uB97C \uBC1C\uAE09\uD55C \uD68C\uC6D0\uC0AC \uC544\uB2D8
err.api.nice.symKey.0004=\uBCF5\uD638\uD654 \uC624\uB958
err.api.nice.symKey.0005=\uD544\uC218 \uC785\uB825\uAC12 \uC624\uB958(key_version, key_info \uB0B4 \uD544\uC218\uAC12 \uD655\uC778)
err.api.nice.symKey.0006=\uB300\uCE6D\uD0A4 \uB4F1\uB85D \uAC00\uB2A5 \uD68C\uC6D0\uC0AC \uC544\uB2D8
err.api.nice.symKey.0007=key \uC911\uBCF5 \uC624\uB958 (\uD604\uC7AC \uBC0F \uC9C1\uC804\uC5D0 \uC0AC\uC6A9\uD55C key \uC0AC\uC6A9 \uBD88\uAC00)
err.api.nice.symKey.0008=\uC694\uCCAD \uC0AC\uC774\uD2B8 \uCF54\uB4DC\uC640 \uACF5\uAC1C\uD0A4 \uBC1C\uAE09 \uC0AC\uC774\uD2B8 \uCF54\uB4DC \uB2E4\uB984
err.api.nice.symKey.0099=\uAE30\uD0C0 \uC624\uB958
err.api.nice.ci.0000=\uCC98\uB9AC\uC644\uB8CC
err.api.nice.ci.0001=\uB300\uCE6D\uD0A4 \uAE30\uAC04 \uB9CC\uB8CC
err.api.nice.ci.0002=\uB300\uCE6D\uD0A4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C
err.api.nice.ci.0003=\uB300\uCE6D\uD0A4\uB97C \uBC1C\uAE09\uD55C \uD68C\uC6D0\uC0AC \uC544\uB2D8
err.api.nice.ci.0004=\uBCF5\uD638\uD654 \uC624\uB958
err.api.nice.ci.0005=\uD544\uC218 \uC785\uB825\uAC12 \uC624\uB958(integrity_value, enc_data \uB0B4 \uD544\uC218\uAC12 \uD655\uC778)
err.api.nice.ci.0006=\uB370\uC774\uD130 \uBB34\uACB0\uC131 \uC624\uB958 (hmac\uAC12 \uBD88\uC77C\uCE58)
err.api.nice.ci.0007=\uC815\uBCF4\uC694\uCCAD\uC720\uD615 \uC785\uB825\uAC12 \uC624\uB958 (info_req_type\uC774 1 \uC544\uB2D8)
err.api.nice.ci.0008=\uC8FC\uBBFC\uBC88\uD638 \uC720\uD6A8\uC131 \uC624\uB958 (\uC0DD\uB144\uC6D4\uC77C \uC720\uD6A8\uC131 \uBC0F \uC22B\uC790 \uC544\uB2D8)
err.api.nice.ci.0009=\uAC70\uB798\uC694\uCCAD\uC2DC\uAC04 \uD3EC\uBA67\uC624\uB958 (req_dtim \uC790\uB9BF\uC218 \uBC0F \uC22B\uC790 \uC544\uB2D8)
err.api.nice.ci.0099=\uAE30\uD0C0 \uC624\uB958

@ -1,5 +1,7 @@
package kr.xit.biz.common; package kr.xit.biz.common;
import lombok.Getter;
/** /**
* <pre> * <pre>
* description : * description :
@ -29,6 +31,7 @@ public class ApiConstants {
* REPORT : - * REPORT : -
* </pre> * </pre>
*/ */
@Getter
public enum Categories { public enum Categories {
DEFAULT("Default") DEFAULT("Default")
, BILL("BILL") , BILL("BILL")
@ -44,9 +47,6 @@ public class ApiConstants {
this.code = code; this.code = code;
} }
public String getCode() {
return this.code;
}
} }
/** /**
@ -72,6 +72,7 @@ public class ApiConstants {
* </pre> * </pre>
* *
*/ */
@Getter
public enum Error { public enum Error {
INVALID_VALUE("INVALID_VALUE") INVALID_VALUE("INVALID_VALUE")
, UNIDENTIFIED_USER("UNIDENTIFIED_USER") , UNIDENTIFIED_USER("UNIDENTIFIED_USER")
@ -87,15 +88,13 @@ public class ApiConstants {
this.code = code; this.code = code;
} }
public String getCode() {
return this.code;
}
} }
/** /**
* *
* SENT() > RECEIVED() > READ()/EXPIRED( ) * SENT() > RECEIVED() > READ()/EXPIRED( )
*/ */
@Getter
public enum DocBoxStatus { public enum DocBoxStatus {
SENT("SENT") SENT("SENT")
, RECEIVED("RECEIVED") , RECEIVED("RECEIVED")
@ -109,14 +108,12 @@ public class ApiConstants {
this.code = code; this.code = code;
} }
public String getCode() {
return this.code;
}
} }
/** /**
* : ENS003 * : ENS003
*/ */
@Getter
public enum SndngProcessStatus { public enum SndngProcessStatus {
ACCEPT("accept"), ACCEPT("accept"),
ACCEPT_OK("accept-ok"), ACCEPT_OK("accept-ok"),
@ -141,14 +138,12 @@ public class ApiConstants {
this.code = code; this.code = code;
} }
public String getCode() {
return this.code;
}
} }
/** /**
* *
*/ */
@Getter
public enum SndngSeCode { public enum SndngSeCode {
SMS("SMS"), SMS("SMS"),
KAKAO_MY_DOC("KKO-MY-DOC"), KAKAO_MY_DOC("KKO-MY-DOC"),
@ -161,14 +156,12 @@ public class ApiConstants {
this.code = code; this.code = code;
} }
public String getCode() {
return this.code;
}
} }
/** /**
* SignguCode * SignguCode
*/ */
@Getter
public enum SignguCode { public enum SignguCode {
/** /**
* *
@ -186,8 +179,12 @@ public class ApiConstants {
this.code = code; this.code = code;
} }
public String getCode() {
return this.code;
} }
public enum NiceCiWrkDiv {
TOKEN,
PUBLIC_KEY,
SYM_KEY,
CI
} }
} }

Loading…
Cancel
Save