diff --git a/mens-api/src/main/java/kr/xit/biz/nice/service/BizNiceCiService.java b/mens-api/src/main/java/kr/xit/biz/nice/service/BizNiceCiService.java index fe8038f..20ba336 100644 --- a/mens-api/src/main/java/kr/xit/biz/nice/service/BizNiceCiService.java +++ b/mens-api/src/main/java/kr/xit/biz/nice/service/BizNiceCiService.java @@ -4,7 +4,6 @@ import egovframework.com.cmm.EgovMessageSource; import javax.transaction.Transactional; import kr.xit.biz.cmm.service.CmmEnsCacheService; import kr.xit.biz.common.ApiConstants.SignguCode; -import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiReqEncData; import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResDataBody; import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiInfo; @@ -22,8 +21,6 @@ import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResDataBody; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; import kr.xit.biz.nice.mapper.IBizNiceCiMapper; import kr.xit.core.exception.BizRuntimeException; -import kr.xit.core.support.utils.DateUtils; -import kr.xit.core.support.utils.IpMacUtils; import kr.xit.core.support.utils.JsonUtils; import kr.xit.ens.cmm.CmmEnsUtils; import kr.xit.ens.nice.cmm.CmmNiceCiUtils; @@ -288,17 +285,7 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic // 아이핀 CI 요청 //-------------------------------------------------------------------------------- public IpinCiResponse requestCi(final NiceCiRequest reqDTO) { - NiceCiInfo niceDTO = CmmNiceCiUtils.getSymkeyNiceCiInfo(reqDTO); - IpinCiReqEncData encDataDTO = IpinCiReqEncData.builder() - .siteCode(niceDTO.getSiteCode()) - //.infoReqType() //default: 1-CI제공 - .juminId(reqDTO.getJuminId()) - .reqNo(CmmEnsUtils.generateLengthUuid(30)) - .reqDtim(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss")) - .clientIp(IpMacUtils.getIpAddress().get(0)) - .build(); - - IpinCiResponse ipinCiResponse = niceCiService.requestCi(CmmEnsUtils.generateLengthUuid(24), encDataDTO, niceDTO); + IpinCiResponse ipinCiResponse = niceCiService.requestCi(reqDTO); ResponseDataHeader resHeader = ipinCiResponse.getDataHeader(); IpinCiResDataBody resBody = ipinCiResponse.getDataBody(); @@ -308,6 +295,7 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic //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()); diff --git a/mens-api/src/main/java/kr/xit/biz/nice/web/BizNiceCiController.java b/mens-api/src/main/java/kr/xit/biz/nice/web/BizNiceCiController.java index c38b5c3..5b231fb 100644 --- a/mens-api/src/main/java/kr/xit/biz/nice/web/BizNiceCiController.java +++ b/mens-api/src/main/java/kr/xit/biz/nice/web/BizNiceCiController.java @@ -45,6 +45,21 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping(value = "/api/biz/nice/v1") public class BizNiceCiController { + + private static final String PARAM1 = """ + { + "signguCode": "88328", + "ffnlgCode": "11", + "juminId": "9901011263512" + } + """; + private static final String PARAM2 = """ + { + "signguCode": "88316", + "ffnlgCode": "11", + "juminId": "9901011263512" + } + """; private final IBizNiceCiService service; //-------------------------------------------------------------------------------- @@ -56,20 +71,10 @@ public class BizNiceCiController { examples = { @ExampleObject( name = "교통시설운영처", - value = """ - { - "signguCode": "88328", - "ffnlgCode": "11" - } - """), + value = PARAM1), @ExampleObject( name = "장사시설", - value = """ - { - "signguCode": "88316", - "ffnlgCode": "11" - } - """) + value = PARAM2) }) }) @Operation(summary = "기관용 토큰 발급 요청", description = "기관용 토큰 발급 요청") @@ -85,20 +90,10 @@ public class BizNiceCiController { examples = { @ExampleObject( name = "교통시설운영처", - value = """ - { - "signguCode": "88328", - "ffnlgCode": "11" - } - """), + value = PARAM1), @ExampleObject( name = "장사시설", - value = """ - { - "signguCode": "88316", - "ffnlgCode": "11" - } - """) + value = PARAM2) }) }) @Operation(summary = "기관용 토큰 폐기", description = "기관용 토큰 폐기") @@ -126,20 +121,10 @@ public class BizNiceCiController { examples = { @ExampleObject( name = "교통시설운영처", - value = """ - { - "signguCode": "88328", - "ffnlgCode": "11" - } - """), + value = PARAM1), @ExampleObject( name = "장사시설", - value = """ - { - "signguCode": "88316", - "ffnlgCode": "11" - } - """) + value = PARAM2) }) }) @Operation(summary = "공개키 요청", description = "공개키 요청") @@ -161,20 +146,10 @@ public class BizNiceCiController { examples = { @ExampleObject( name = "교통시설운영처", - value = """ - { - "signguCode": "88328", - "ffnlgCode": "11" - } - """), + value = PARAM1), @ExampleObject( name = "장사시설", - value = """ - { - "signguCode": "88316", - "ffnlgCode": "11" - } - """) + value = PARAM2) }) }) @Operation(summary = "대칭키(symmetrickey) 등록 요청", description = "대칭키(symmetrickey) 등록 요청") @@ -197,20 +172,10 @@ public class BizNiceCiController { examples = { @ExampleObject( name = "교통시설운영처", - value = """ - { - "signguCode": "88328", - "ffnlgCode": "11" - } - """), + value = PARAM1), @ExampleObject( name = "장사시설", - value = """ - { - "signguCode": "88316", - "ffnlgCode": "11" - } - """) + value = PARAM2) }) }) @Operation(summary = "아이핀 CI 요청", description = "아이핀 CI 요청") diff --git a/mens-api/src/main/java/kr/xit/ens/nice/cmm/CmmNiceCiUtils.java b/mens-api/src/main/java/kr/xit/ens/nice/cmm/CmmNiceCiUtils.java index 5b6b0e5..8767632 100644 --- a/mens-api/src/main/java/kr/xit/ens/nice/cmm/CmmNiceCiUtils.java +++ b/mens-api/src/main/java/kr/xit/ens/nice/cmm/CmmNiceCiUtils.java @@ -85,6 +85,7 @@ public class CmmNiceCiUtils { } // 2. 공개키 발급 처리 + //TODO::에러 처리 - throw exception bizNiceService.requestPublickey(reqDTO); return cacheService.getNiceCiInfoCache(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); @@ -105,6 +106,7 @@ public class CmmNiceCiUtils { if(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss").compareTo(niceDTO.getCurSymkeyValidDtim()) < 0) return niceDTO; // 대칭키 발행 등록 + //TODO::에러 처리 - throw exception bizNiceService.requestRegSymmetrickey(reqDTO); return cacheService.getNiceCiInfoCache(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); diff --git a/mens-api/src/main/java/kr/xit/ens/nice/service/INiceCiService.java b/mens-api/src/main/java/kr/xit/ens/nice/service/INiceCiService.java index e595732..a6d6eea 100644 --- a/mens-api/src/main/java/kr/xit/ens/nice/service/INiceCiService.java +++ b/mens-api/src/main/java/kr/xit/ens/nice/service/INiceCiService.java @@ -1,8 +1,6 @@ package kr.xit.ens.nice.service; -import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiReqEncData; 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.NiceTokenResponse; import kr.xit.biz.ens.model.nice.NiceCiDTO.PublickeyResponse; @@ -55,7 +53,7 @@ public interface INiceCiService { //-------------------------------------------------------------------------------- // 아이핀 CI 요청 //-------------------------------------------------------------------------------- - IpinCiResponse requestCi(final String tranId, final IpinCiReqEncData encDataDTO, final NiceCiInfo niceDTO); + IpinCiResponse requestCi(final NiceCiRequest reqDTO); //-------------------------------------------------------------------------------- // 아이핀 CI 요청 //-------------------------------------------------------------------------------- diff --git a/mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiService.java b/mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiService.java index 4a37428..2e76f97 100644 --- a/mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiService.java +++ b/mens-api/src/main/java/kr/xit/ens/nice/service/NiceCiService.java @@ -25,6 +25,7 @@ import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.spring.annotation.TraceLogging; import kr.xit.core.spring.util.ApiWebClientUtil; import kr.xit.core.support.utils.DateUtils; +import kr.xit.core.support.utils.IpMacUtils; import kr.xit.core.support.utils.JsonUtils; import kr.xit.ens.cmm.CmmEnsUtils; import kr.xit.ens.nice.cmm.CmmNiceCiUtils; @@ -250,9 +251,19 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer //-------------------------------------------------------------------------------- // 아이핀 CI 요청 //-------------------------------------------------------------------------------- - public IpinCiResponse requestCi(final String tranId, final IpinCiReqEncData encDataDTO, final NiceCiInfo niceDTO) { + public IpinCiResponse requestCi(final NiceCiRequest reqDTO) { + NiceCiInfo niceDTO = CmmNiceCiUtils.getSymkeyNiceCiInfo(reqDTO); + IpinCiReqEncData encDataDTO = IpinCiReqEncData.builder() + .siteCode(niceDTO.getSiteCode()) + //.infoReqType() //default: 1-CI제공 + .juminId(reqDTO.getJuminId()) + .reqNo(CmmEnsUtils.generateLengthUuid(30)) + .reqDtim(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss")) + .clientIp(IpMacUtils.getIpAddress().get(0)) + .build(); CmmEnsUtils.validate(encDataDTO); + final String tranId = CmmEnsUtils.generateLengthUuid(24); final String jsonEncData = CmmEnsUtils.encodeAesData(niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv(), JsonUtils.toJson(encDataDTO)); final String integrityValue = CmmEnsUtils.encodeHmacSha256(niceDTO.getCurSymkeyHmacKey(), jsonEncData); diff --git a/mens-api/src/main/java/kr/xit/ens/nice/web/NiceCiController.java b/mens-api/src/main/java/kr/xit/ens/nice/web/NiceCiController.java index f75a3c9..9edcc2e 100644 --- a/mens-api/src/main/java/kr/xit/ens/nice/web/NiceCiController.java +++ b/mens-api/src/main/java/kr/xit/ens/nice/web/NiceCiController.java @@ -2,13 +2,8 @@ package kr.xit.ens.nice.web; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; -import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiReqEncData; -import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiInfo; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest; import kr.xit.core.model.ApiResponseDTO; -import kr.xit.core.support.utils.DateUtils; -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.service.INiceCiService; import lombok.RequiredArgsConstructor; @@ -94,24 +89,7 @@ public class NiceCiController { @Operation(summary = "아이핀 CI 요청", description = "아이핀 CI 요청") @PostMapping(value = "/requestCi", produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponseDTO requestCi(@RequestBody final NiceCiRequest reqDTO) { - NiceCiInfo niceDTO = CmmNiceCiUtils.getNiceCiInfo(reqDTO); - - IpinCiReqEncData encDataDTO = IpinCiReqEncData.builder() - .siteCode(niceDTO.getSiteCode()) - //.infoReqType() //default: 1-CI제공 - .juminId(reqDTO.getJuminId()) - .reqNo(CmmEnsUtils.generateLengthUuid(30)) - .reqDtim(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss")) - .clientIp(IpMacUtils.getIpAddress().get(0)) - .build(); - - return ApiResponseDTO.success( - service.requestCi( - CmmEnsUtils.generateLengthUuid(24), - encDataDTO, - CmmNiceCiUtils.getPublickeyNiceCiInfo(reqDTO) - ) - ); + return ApiResponseDTO.success(service.requestCi(reqDTO)); } //-------------------------------------------------------------------------------- // 아이핀 CI 요청 diff --git a/mens-core/src/main/java/kr/xit/biz/ens/model/nice/NiceCiDTO.java b/mens-core/src/main/java/kr/xit/biz/ens/model/nice/NiceCiDTO.java index 6be5a62..36ffb04 100644 --- a/mens-core/src/main/java/kr/xit/biz/ens/model/nice/NiceCiDTO.java +++ b/mens-core/src/main/java/kr/xit/biz/ens/model/nice/NiceCiDTO.java @@ -57,16 +57,6 @@ public class NiceCiDTO { @NotEmpty(message = "과태료 코드는 필수 입니다") private String ffnlgCode = "11"; - /** - *
-         * TRAN_ID : 요청한값 그대로 return
-         * 고유번호 : 최대 24
-         * 
- */ -// @Schema(requiredMode = RequiredMode.AUTO, title = "TRAN_ID", example = "20230906120000") -// @Size(max = 24, message = "TRAN_ID는 24자를 넘을 수 없습니다.") -// private String tranId;; - /** * 주민Id */ @@ -690,14 +680,13 @@ public class NiceCiDTO { */ @Schema(requiredMode = RequiredMode.REQUIRED, title = "정보요청유형", description = "정보요청유형", example = "1") @NotEmpty(message = "정보요청유형은 필수 입니다(1:CI요청)") - @Size(max = 1) private final String infoReqType = "1"; /** * 주민번호 13자리 */ @Schema(requiredMode = RequiredMode.REQUIRED, title = "주민번호", description = "주민번호13자리", example = " ") - @Size(min = 13, max = 13, message = "주민번호(13자리)는 필수 입니다") + @NotEmpty(message = "주민번호(13자리)는 필수 입니다") private String juminId; /** @@ -705,14 +694,13 @@ public class NiceCiDTO { */ @Schema(requiredMode = RequiredMode.REQUIRED, title = "요청번호", description = "이용기관에서 서비스에 대한 요청거래를 확인하기 위한 고유값", example = " ") @NotEmpty(message = "요청번호는 필수 입니다(30자리)") - @Size(max = 30) private String reqNo; /** * 거래요청시간 : YYYYMMDDHH24MISS */ @Schema(requiredMode = RequiredMode.REQUIRED, title = "거래요청시간", description = "거래요청시간(YYYYMMDDHH24MISS)", example = " ") - @Size(min = 14, max = 14, message = "거래요청시간(14자리)은 필수 입니다") + @NotEmpty(message = "거래요청시간(14자리)은 필수 입니다") private String reqDtim; /**