feat: KT, Nice API 반영

dev
gitea-관리자 1 year ago
parent 180fc9b927
commit d55c3302e1

@ -4,7 +4,6 @@ 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.SignguCode; 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.IpinCiResDataBody;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResponse; 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;
@ -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.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.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.cmm.CmmEnsUtils;
import kr.xit.ens.nice.cmm.CmmNiceCiUtils; import kr.xit.ens.nice.cmm.CmmNiceCiUtils;
@ -288,17 +285,7 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
// 아이핀 CI 요청 // 아이핀 CI 요청
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
public IpinCiResponse requestCi(final NiceCiRequest reqDTO) { public IpinCiResponse requestCi(final NiceCiRequest reqDTO) {
NiceCiInfo niceDTO = CmmNiceCiUtils.getSymkeyNiceCiInfo(reqDTO); IpinCiResponse ipinCiResponse = niceCiService.requestCi(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);
ResponseDataHeader resHeader = ipinCiResponse.getDataHeader(); ResponseDataHeader resHeader = ipinCiResponse.getDataHeader();
IpinCiResDataBody resBody = ipinCiResponse.getDataBody(); IpinCiResDataBody resBody = ipinCiResponse.getDataBody();
@ -308,6 +295,7 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic
//FIXME::응답무결성 체크 //FIXME::응답무결성 체크
// 응답으로온 intigrety_value와 응답 enc_data를 Hmac한 값을 비교 // 응답으로온 intigrety_value와 응답 enc_data를 Hmac한 값을 비교
// 무결성체크가 완료되면 데이터를 보낸 대칭키로 복호화하여 데이터를 확인 // 무결성체크가 완료되면 데이터를 보낸 대칭키로 복호화하여 데이터를 확인
NiceCiInfo niceDTO = CmmNiceCiUtils.getSymkeyNiceCiInfo(reqDTO);
String checkHmac = CmmEnsUtils.encodeHmacSha256(niceDTO.getCurSymkeyHmacKey(), resEncData); String checkHmac = CmmEnsUtils.encodeHmacSha256(niceDTO.getCurSymkeyHmacKey(), resEncData);
if(resBody.getIntegrityValue().equals(checkHmac)){ if(resBody.getIntegrityValue().equals(checkHmac)){
String decData = CmmEnsUtils.decodeAesData(resEncData, niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv()); String decData = CmmEnsUtils.decodeAesData(resEncData, niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv());

@ -45,6 +45,21 @@ 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 = """
{
"signguCode": "88328",
"ffnlgCode": "11",
"juminId": "9901011263512"
}
""";
private static final String PARAM2 = """
{
"signguCode": "88316",
"ffnlgCode": "11",
"juminId": "9901011263512"
}
""";
private final IBizNiceCiService service; private final IBizNiceCiService service;
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
@ -56,20 +71,10 @@ public class BizNiceCiController {
examples = { examples = {
@ExampleObject( @ExampleObject(
name = "교통시설운영처", name = "교통시설운영처",
value = """ value = PARAM1),
{
"signguCode": "88328",
"ffnlgCode": "11"
}
"""),
@ExampleObject( @ExampleObject(
name = "장사시설", name = "장사시설",
value = """ value = PARAM2)
{
"signguCode": "88316",
"ffnlgCode": "11"
}
""")
}) })
}) })
@Operation(summary = "기관용 토큰 발급 요청", description = "기관용 토큰 발급 요청") @Operation(summary = "기관용 토큰 발급 요청", description = "기관용 토큰 발급 요청")
@ -85,20 +90,10 @@ public class BizNiceCiController {
examples = { examples = {
@ExampleObject( @ExampleObject(
name = "교통시설운영처", name = "교통시설운영처",
value = """ value = PARAM1),
{
"signguCode": "88328",
"ffnlgCode": "11"
}
"""),
@ExampleObject( @ExampleObject(
name = "장사시설", name = "장사시설",
value = """ value = PARAM2)
{
"signguCode": "88316",
"ffnlgCode": "11"
}
""")
}) })
}) })
@Operation(summary = "기관용 토큰 폐기", description = "기관용 토큰 폐기") @Operation(summary = "기관용 토큰 폐기", description = "기관용 토큰 폐기")
@ -126,20 +121,10 @@ public class BizNiceCiController {
examples = { examples = {
@ExampleObject( @ExampleObject(
name = "교통시설운영처", name = "교통시설운영처",
value = """ value = PARAM1),
{
"signguCode": "88328",
"ffnlgCode": "11"
}
"""),
@ExampleObject( @ExampleObject(
name = "장사시설", name = "장사시설",
value = """ value = PARAM2)
{
"signguCode": "88316",
"ffnlgCode": "11"
}
""")
}) })
}) })
@Operation(summary = "공개키 요청", description = "공개키 요청") @Operation(summary = "공개키 요청", description = "공개키 요청")
@ -161,20 +146,10 @@ public class BizNiceCiController {
examples = { examples = {
@ExampleObject( @ExampleObject(
name = "교통시설운영처", name = "교통시설운영처",
value = """ value = PARAM1),
{
"signguCode": "88328",
"ffnlgCode": "11"
}
"""),
@ExampleObject( @ExampleObject(
name = "장사시설", name = "장사시설",
value = """ value = PARAM2)
{
"signguCode": "88316",
"ffnlgCode": "11"
}
""")
}) })
}) })
@Operation(summary = "대칭키(symmetrickey) 등록 요청", description = "대칭키(symmetrickey) 등록 요청") @Operation(summary = "대칭키(symmetrickey) 등록 요청", description = "대칭키(symmetrickey) 등록 요청")
@ -197,20 +172,10 @@ public class BizNiceCiController {
examples = { examples = {
@ExampleObject( @ExampleObject(
name = "교통시설운영처", name = "교통시설운영처",
value = """ value = PARAM1),
{
"signguCode": "88328",
"ffnlgCode": "11"
}
"""),
@ExampleObject( @ExampleObject(
name = "장사시설", name = "장사시설",
value = """ value = PARAM2)
{
"signguCode": "88316",
"ffnlgCode": "11"
}
""")
}) })
}) })
@Operation(summary = "아이핀 CI 요청", description = "아이핀 CI 요청") @Operation(summary = "아이핀 CI 요청", description = "아이핀 CI 요청")

@ -85,6 +85,7 @@ public class CmmNiceCiUtils {
} }
// 2. 공개키 발급 처리 // 2. 공개키 발급 처리
//TODO::에러 처리 - throw exception
bizNiceService.requestPublickey(reqDTO); bizNiceService.requestPublickey(reqDTO);
return cacheService.getNiceCiInfoCache(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); return cacheService.getNiceCiInfoCache(reqDTO.getSignguCode(), reqDTO.getFfnlgCode());
@ -105,6 +106,7 @@ public class CmmNiceCiUtils {
if(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss").compareTo(niceDTO.getCurSymkeyValidDtim()) < 0) return niceDTO; if(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss").compareTo(niceDTO.getCurSymkeyValidDtim()) < 0) return niceDTO;
// 대칭키 발행 등록 // 대칭키 발행 등록
//TODO::에러 처리 - throw exception
bizNiceService.requestRegSymmetrickey(reqDTO); bizNiceService.requestRegSymmetrickey(reqDTO);
return cacheService.getNiceCiInfoCache(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); return cacheService.getNiceCiInfoCache(reqDTO.getSignguCode(), reqDTO.getFfnlgCode());

@ -1,8 +1,6 @@
package kr.xit.ens.nice.service; 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.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.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.PublickeyResponse;
@ -55,7 +53,7 @@ public interface INiceCiService {
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청 // 아이핀 CI 요청
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
IpinCiResponse requestCi(final String tranId, final IpinCiReqEncData encDataDTO, final NiceCiInfo niceDTO); IpinCiResponse requestCi(final NiceCiRequest reqDTO);
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청 // 아이핀 CI 요청
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------

@ -25,6 +25,7 @@ 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;
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.JsonUtils; import kr.xit.core.support.utils.JsonUtils;
import kr.xit.ens.cmm.CmmEnsUtils; import kr.xit.ens.cmm.CmmEnsUtils;
import kr.xit.ens.nice.cmm.CmmNiceCiUtils; import kr.xit.ens.nice.cmm.CmmNiceCiUtils;
@ -250,9 +251,19 @@ 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 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); CmmEnsUtils.validate(encDataDTO);
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);

@ -2,13 +2,8 @@ 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.tags.Tag; 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.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.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;
@ -94,24 +89,7 @@ public class NiceCiController {
@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) {
NiceCiInfo niceDTO = CmmNiceCiUtils.getNiceCiInfo(reqDTO); return ApiResponseDTO.success(service.requestCi(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)
)
);
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 아이핀 CI 요청 // 아이핀 CI 요청

@ -57,16 +57,6 @@ public class NiceCiDTO {
@NotEmpty(message = "과태료 코드는 필수 입니다") @NotEmpty(message = "과태료 코드는 필수 입니다")
private String ffnlgCode = "11"; private String ffnlgCode = "11";
/**
* <pre>
* TRAN_ID : return
* : 24
* </pre>
*/
// @Schema(requiredMode = RequiredMode.AUTO, title = "TRAN_ID", example = "20230906120000")
// @Size(max = 24, message = "TRAN_ID는 24자를 넘을 수 없습니다.")
// private String tranId;;
/** /**
* Id * Id
*/ */
@ -690,14 +680,13 @@ public class NiceCiDTO {
*/ */
@Schema(requiredMode = RequiredMode.REQUIRED, title = "정보요청유형", description = "정보요청유형", example = "1") @Schema(requiredMode = RequiredMode.REQUIRED, title = "정보요청유형", description = "정보요청유형", example = "1")
@NotEmpty(message = "정보요청유형은 필수 입니다(1:CI요청)") @NotEmpty(message = "정보요청유형은 필수 입니다(1:CI요청)")
@Size(max = 1)
private final String infoReqType = "1"; private final String infoReqType = "1";
/** /**
* 13 * 13
*/ */
@Schema(requiredMode = RequiredMode.REQUIRED, title = "주민번호", description = "주민번호13자리", example = " ") @Schema(requiredMode = RequiredMode.REQUIRED, title = "주민번호", description = "주민번호13자리", example = " ")
@Size(min = 13, max = 13, message = "주민번호(13자리)는 필수 입니다") @NotEmpty(message = "주민번호(13자리)는 필수 입니다")
private String juminId; private String juminId;
/** /**
@ -705,14 +694,13 @@ public class NiceCiDTO {
*/ */
@Schema(requiredMode = RequiredMode.REQUIRED, title = "요청번호", description = "이용기관에서 서비스에 대한 요청거래를 확인하기 위한 고유값", example = " ") @Schema(requiredMode = RequiredMode.REQUIRED, title = "요청번호", description = "이용기관에서 서비스에 대한 요청거래를 확인하기 위한 고유값", example = " ")
@NotEmpty(message = "요청번호는 필수 입니다(30자리)") @NotEmpty(message = "요청번호는 필수 입니다(30자리)")
@Size(max = 30)
private String reqNo; private String reqNo;
/** /**
* : YYYYMMDDHH24MISS * : YYYYMMDDHH24MISS
*/ */
@Schema(requiredMode = RequiredMode.REQUIRED, title = "거래요청시간", description = "거래요청시간(YYYYMMDDHH24MISS)", example = " ") @Schema(requiredMode = RequiredMode.REQUIRED, title = "거래요청시간", description = "거래요청시간(YYYYMMDDHH24MISS)", example = " ")
@Size(min = 14, max = 14, message = "거래요청시간(14자리)은 필수 입니다") @NotEmpty(message = "거래요청시간(14자리)은 필수 입니다")
private String reqDtim; private String reqDtim;
/** /**

Loading…
Cancel
Save