fix: kt API fix
parent
4f3eae2e02
commit
5b17c96d41
@ -1,233 +0,0 @@
|
||||
package kr.xit.ens.nice.service;
|
||||
|
||||
import kr.xit.biz.ens.model.nice.NiceCiDTO.*;
|
||||
import kr.xit.core.spring.annotation.TraceLogging;
|
||||
import kr.xit.core.support.utils.DateUtils;
|
||||
import kr.xit.core.support.utils.JsonUtils;
|
||||
import kr.xit.ens.cmm.CmmEnsUtils;
|
||||
import kr.xit.ens.nice.cmm.CmmNiceCiUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* description :
|
||||
*
|
||||
* packageName : kr.xit.ens.nice.service
|
||||
* fileName : NiceCiService
|
||||
* author : limju
|
||||
* date : 2023-09-06
|
||||
* ======================================================================
|
||||
* 변경일 변경자 변경 내용
|
||||
* ----------------------------------------------------------------------
|
||||
* 2023-09-06 limju 최초 생성
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
//FIXME : client_id, client_secret, access_token DB 처리후 반영 필요
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class NiceCiDummyTestService extends EgovAbstractServiceImpl {
|
||||
private static final String CNTY_CD = "ko";
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// 기관용 Token
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @return TokenResponse
|
||||
*/
|
||||
@TraceLogging
|
||||
public NiceTokenResponse generateToken(){
|
||||
final NiceTokenRequest tokenRequest = NiceTokenRequest.builder().build();
|
||||
CmmEnsUtils.validate(tokenRequest);
|
||||
|
||||
log.debug("{}", tokenRequest);
|
||||
|
||||
return NiceTokenResponse.builder()
|
||||
.dataHeader(ResponseDataHeader.builder()
|
||||
.gwRsltCd("1200")
|
||||
.gwRsltMsg("오류없음")
|
||||
.build())
|
||||
.dataBody(TokenResDataBody.builder()
|
||||
.accessToken("ff5e27fe-8b5d-49db-ab1e-0ccf07de6ac1")
|
||||
.tokenType("bearer")
|
||||
.expiresIn(1576983059)
|
||||
.scope("default")
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Authorization : Basic + Base64Encoding(access_token:current_timestamp:client_id)
|
||||
* - access_token : 만료할 access_token
|
||||
* - client_id : access_token발급에 사용된 client_id
|
||||
* - current_timestamp
|
||||
* Date currentDate = new Date();
|
||||
* long current_timestamp = currentDate.getTime() /1000
|
||||
* @return
|
||||
* </pre>
|
||||
*/
|
||||
@TraceLogging
|
||||
public TokenRevokeResponse revokeToken(){
|
||||
|
||||
return TokenRevokeResponse.builder()
|
||||
.dataHeader(ResponseDataHeader.builder()
|
||||
.gwRsltCd("1200")
|
||||
.gwRsltMsg("오류없음")
|
||||
.build())
|
||||
.dataBody(TokenRevokeResDataBody.builder()
|
||||
.result(true)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
// 기관용 Token
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// 공개키(Publickey)
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
public PublickeyResponse requestPublickey() {
|
||||
final String todayDt = DateUtils.getTodayAndNowTime("yyyyMMddHHmmss");
|
||||
|
||||
final PublickeyRequest pubReqDTO = PublickeyRequest.builder()
|
||||
.dataHeader(RequestDataHeader.builder()
|
||||
.cntyCd(CNTY_CD)
|
||||
.tranId(CmmEnsUtils.generateLengthUuid(24))
|
||||
.build())
|
||||
.dataBody(PublickeyReqDataBody.builder()
|
||||
.reqDtim(todayDt)
|
||||
.build())
|
||||
.build();
|
||||
log.debug("{}", pubReqDTO);
|
||||
CmmEnsUtils.validate(pubReqDTO);
|
||||
|
||||
return PublickeyResponse.builder()
|
||||
.dataHeader(ResponseDataHeader.builder()
|
||||
.gwRsltCd("1200")
|
||||
.gwRsltMsg("오류없음")
|
||||
.tranId(pubReqDTO.getDataHeader().getTranId())
|
||||
.cntyCd(pubReqDTO.getDataHeader().getCntyCd())
|
||||
.build())
|
||||
.dataBody(PublickeyResDataBody.builder()
|
||||
.rspCd("P000")
|
||||
.rspMsg("")
|
||||
.resultCd("0000")
|
||||
.siteCode("AAAABBBBCCCCDD==")
|
||||
.keyVersion("20210121ca8c1612-2c2d-IPaa-aad1-xxxxxxxxxxxx")
|
||||
.publicKey("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUpwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ51s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQAB")
|
||||
.validDtim("20220121181550")
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// 공개키(Publickey)
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// 대칭키 : symmetrickey
|
||||
//--------------------------------------------------------------------------------
|
||||
public SymmetrickeyResponse requestRegSymmetrickey(final NiceCiRequest reqDTO) {
|
||||
final NiceCiInfo niceDTO = CmmNiceCiUtils.getPublickeyNiceCiInfo(reqDTO);
|
||||
final SymkeyRegInfo symkeyRegInfo = CmmNiceCiUtils.getSymkeyRegInfo();
|
||||
|
||||
//FIXME::NICE 연계이후 comment 제거
|
||||
//String encSymkeyRegInfo = encodeString(niceDTO.getPublicKey(), JsonUtils.toJson(symkeyRegInfo));
|
||||
String encSymkeyRegInfo = "encodeStringniceDTOgetPublicKeyJsonUtilstoJsonsymkeyRegInfo";
|
||||
|
||||
SymmetrickeyRequest symReqDTO = SymmetrickeyRequest.builder()
|
||||
.dataHeader(RequestDataHeader.builder()
|
||||
.cntyCd(CNTY_CD)
|
||||
.tranId(CmmEnsUtils.generateLengthUuid(24))
|
||||
.build())
|
||||
.dataBody(SymmetrickeyReqDataBody.builder()
|
||||
.pubkeyVersion(niceDTO.getKeyVersion())
|
||||
.symkeyRegInfo(encSymkeyRegInfo)
|
||||
.build())
|
||||
.build();
|
||||
CmmEnsUtils.validate(symReqDTO);
|
||||
|
||||
return SymmetrickeyResponse.builder()
|
||||
.dataHeader(ResponseDataHeader.builder()
|
||||
.gwRsltCd("1200")
|
||||
.gwRsltMsg("오류없음")
|
||||
.tranId(symReqDTO.getDataHeader().getTranId())
|
||||
.cntyCd(symReqDTO.getDataHeader().getCntyCd())
|
||||
.build())
|
||||
.dataBody(SymmetrickeyResDataBody.builder()
|
||||
.rspCd("P000")
|
||||
.rspMsg("")
|
||||
.resultCd("0000") // "0007"
|
||||
.symkeyStatInfo(JsonUtils.toJson(SymkeyStatInfo.builder()
|
||||
.curSymkeyVersion("20210507CD4BB74D-6716-IP05-8296-xxxxxxxxxxxx")
|
||||
.curValidDtim("20220507141444")
|
||||
.befSymkeyVersion("202105075A65ABFF-AFE6-IPFF-8B6F-xxxxxxxxxxxx")
|
||||
.befValidDtim("20220507141241")
|
||||
.build()))
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
// 대칭키 : symmetrickey
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// 아이핀 CI 요청
|
||||
//--------------------------------------------------------------------------------
|
||||
public IpinCiResponse requestCi(final IpinCiReqEncData encDataDTO, final NiceCiInfo niceDTO) {
|
||||
CmmEnsUtils.validate(encDataDTO);
|
||||
|
||||
final String jsonEncData = CmmEnsUtils.encodeAesData(niceDTO.getCurSymkeyKey(), niceDTO.getCurSymkeyIv(), JsonUtils.toJson(encDataDTO));
|
||||
final String integrityValue = CmmEnsUtils.encodeHmacSha256(niceDTO.getCurSymkeyHmacKey(), jsonEncData);
|
||||
|
||||
final IpinCiRequest ipinCiRequest = IpinCiRequest.builder()
|
||||
.dataHeader(RequestDataHeader.builder()
|
||||
.cntyCd(CNTY_CD)
|
||||
.tranId(CmmEnsUtils.generateLengthUuid(24))
|
||||
.build())
|
||||
.dataBody(IpinCiReqDataBody.builder()
|
||||
.symkeyVersion(niceDTO.getCurSymkeyVersion())
|
||||
.encData(jsonEncData)
|
||||
.integrityValue(integrityValue)
|
||||
.build())
|
||||
.build();
|
||||
CmmEnsUtils.validate(ipinCiRequest);
|
||||
|
||||
|
||||
return IpinCiResponse.builder()
|
||||
.dataHeader(ResponseDataHeader.builder()
|
||||
.gwRsltCd("1200")
|
||||
.gwRsltMsg("오류없음")
|
||||
.tranId(ipinCiRequest.getDataHeader().getTranId())
|
||||
.cntyCd(ipinCiRequest.getDataHeader().getCntyCd())
|
||||
.build())
|
||||
.dataBody(IpinCiResDataBody.builder()
|
||||
.rspCd("P000")
|
||||
.resMsg("")
|
||||
.encData(JsonUtils.toJson(
|
||||
IpinCiResEncData.builder()
|
||||
.resultCd("0000")
|
||||
.ci1("")
|
||||
.ci2("")
|
||||
.updtCnt("1")
|
||||
.txUniqueNo("")
|
||||
.build()
|
||||
))
|
||||
.integrityValue("")
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
// 아이핀 CI 요청
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
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.NiceCiDummyTestService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.nice.web
|
||||
* fileName : NiceCiDummyTestController
|
||||
* author : limju
|
||||
* date : 2023-09-06
|
||||
* ======================================================================
|
||||
* 변경일 변경자 변경 내용
|
||||
* ----------------------------------------------------------------------
|
||||
* 2023-09-06 limju 최초 생성
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "NiceCiDummyTestController", description = "Nice CI Dummy Test")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/ens/nice/test")
|
||||
public class NiceCiDummyTestController {
|
||||
private final NiceCiDummyTestService service;
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// 기관용 Token
|
||||
//--------------------------------------------------------------------------------
|
||||
@Operation(summary = "기관용 토큰 발급 요청", description = "기관용 토큰 발급 요청")
|
||||
@PostMapping(value = "/generateToken", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ApiResponseDTO<?> generateToken() {
|
||||
return ApiResponseDTO.success(service.generateToken());
|
||||
}
|
||||
|
||||
@Operation(summary = "기관용 토큰 폐기", description = "기관용 토큰 폐기")
|
||||
@PostMapping(value = "/revokeToken", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ApiResponseDTO<?> revokeToken() {
|
||||
return ApiResponseDTO.success(service.revokeToken());
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
// 기관용 Token
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// 공개키(Publickey)
|
||||
//--------------------------------------------------------------------------------
|
||||
@Operation(summary = "공개키 요청", description = "공개키 요청")
|
||||
@PostMapping(value = "/requestPublickey", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ApiResponseDTO<?> requestPublickey() {
|
||||
return ApiResponseDTO.success(service.requestPublickey());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// 공개키(Publickey)
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// 대칭키 : symmetrickey
|
||||
//--------------------------------------------------------------------------------
|
||||
@Operation(summary = "대칭키(symmetrickey) 등록 요청", description = "대칭키(symmetrickey) 등록 요청")
|
||||
@PostMapping(value = "/requestRegSymmetrickey", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ApiResponseDTO<?> requestRegSymmetrickey(@RequestBody NiceCiRequest reqDTO) {
|
||||
return ApiResponseDTO.success(service.requestRegSymmetrickey(reqDTO));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// 대칭키 : symmetrickey
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
@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(
|
||||
encDataDTO,
|
||||
CmmNiceCiUtils.getPublickeyNiceCiInfo(reqDTO)
|
||||
)
|
||||
);
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
// 아이핀 CI 요청
|
||||
//--------------------------------------------------------------------------------
|
||||
}
|
Loading…
Reference in New Issue