diff --git a/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java b/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java index e1289f4..db3d8d9 100644 --- a/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java +++ b/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java @@ -45,8 +45,9 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { /** * Nice CI 인증 관련 정보 cache load - * @param dto NiceCiRequestDTO - * @return CrtfInfo + * @param signguCode String + * @param ffnlgCode String + * @return NiceCiInfo */ @Transactional(readOnly = true) @Cacheable(cacheNames = "niceCiInfo", keyGenerator = "simpleKeyGenerator") @@ -56,8 +57,8 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { /** * Nice CI 인증 관련 정보 cache remove - * @param signguCode - * @param ffnlgCode + * @param signguCode String + * @param ffnlgCode String */ @Transactional(readOnly = true) @CacheEvict(cacheNames = "niceCiInfo", keyGenerator = "simpleKeyGenerator") @@ -65,9 +66,8 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { } /** - * KT / KAKAO 인증 관련 정보 cache load - * @param signguCode - * @param ffnlgCode + * KT / KAKAO / postplus / epost 문서중개자 관련 정보 cache load + * @param dto CmmEnsRequestDTO * @return CmmEnsRlaybsnmDTO */ @Transactional(readOnly = true) @@ -77,9 +77,8 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { } /** - * KT / KAKAO 인증 관련 정보 cache remove - * @param signguCode - * @param ffnlgCode + * KT / KAKAO / postplus / epost 문서중개자 관련 정보 cache remove + * @param dto CmmEnsRequestDTO */ @Transactional(readOnly = true) @CacheEvict(cacheNames = "rlaybsnmInfo", keyGenerator = "simpleKeyGenerator") @@ -95,7 +94,7 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { Cache cache = ((CaffeineCache) cacheManager.getCache(cacheName)).getNativeCache(); for(Object key : cache.asMap().keySet()) { - Object value = cache.getIfPresent(key); + //Object value = cache.getIfPresent(key); log.info("key: {}", key); //log.info("key: {} - value: {}", key, value.toString()); } 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 699cfc5..3496f7f 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 @@ -3,26 +3,21 @@ package kr.xit.biz.nice.service; import egovframework.com.cmm.EgovMessageSource; import javax.transaction.Transactional; 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.ens.model.nice.NiceCiDTO.IpinCiResDataBody; -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.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.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.SymkeyRegInfo; 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.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.JsonUtils; -import kr.xit.ens.cmm.CmmEnsUtils; import kr.xit.ens.nice.cmm.CmmNiceCiUtils; import kr.xit.ens.nice.service.INiceCiService; import lombok.RequiredArgsConstructor; @@ -58,7 +53,6 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic //-------------------------------------------------------------------------------- // 기관용 Token //-------------------------------------------------------------------------------- - /** *
* NICE 토큰 발급 요청 @@ -76,8 +70,8 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic final ResponseDataHeader dataHeader = tokenResponse.getDataHeader(); if(dataHeader.getGwRsltCd().equals("1200")){ - TokenResDataBody dataBody = tokenResponse.getDataBody(); - NiceCiInfo niceDTO = NiceCiInfo.builder() + final TokenResDataBody dataBody = tokenResponse.getDataBody(); + final NiceCiInfo niceDTO = NiceCiInfo.builder() .signguCode(reqDTO.getSignguCode()) .ffnlgCode(reqDTO.getFfnlgCode()) .accessToken(dataBody.getAccessToken()) @@ -91,7 +85,7 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic // 공개키 정보 캐쉬 삭제 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 @Override public TokenRevokeResponse revokeToken(final NiceCiRequest reqDTO){ - TokenRevokeResponse resDTO = niceCiService.revokeToken(reqDTO); - + final TokenRevokeResponse resDTO = niceCiService.revokeToken(reqDTO); final ResponseDataHeader dataHeader = resDTO.getDataHeader(); + if(dataHeader.getGwRsltCd().equals("1200")){ - TokenRevokeResDataBody dataBody = resDTO.getDataBody(); + final TokenRevokeResDataBody dataBody = resDTO.getDataBody(); if(dataBody.isResult()){ - NiceCiInfo niceDTO = NiceCiInfo.builder() + final NiceCiInfo niceDTO = NiceCiInfo.builder() .signguCode(reqDTO.getSignguCode()) .ffnlgCode(reqDTO.getFfnlgCode()) .accessToken(null) @@ -131,7 +125,7 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic // 공개키 정보 캐쉬 삭제 cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode()); - updateNiceCerfInfoSync(niceDTO, reqDTO); + updateNiceCerfInfoSync(niceDTO, reqDTO, NiceCiWrkDiv.TOKEN); }else{ throw BizRuntimeException.create("토큰을 폐기하지 못했습니다."); } @@ -139,13 +133,10 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic return resDTO; } //-------------------------------------------------------------------------------- - // 기관용 Token - //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // 공개키(Publickey) //-------------------------------------------------------------------------------- - /** ** 공개키 요청 @@ -157,59 +148,30 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic */ @Transactional @Override - public PublickeyResponse requestPublickey(final NiceCiRequest reqDTO) { + public PublickeyResDataBody requestPublickey(final NiceCiRequest reqDTO) { final NiceCiInfo niceDTO = CmmNiceCiUtils.getNiceCiInfo(reqDTO); if(ObjectUtils.isEmpty(niceDTO.getAccessToken())) throw BizRuntimeException.create(messageSource.getMessage("fail.api.nice.token.info")); - final PublickeyResponse pubResDTO = niceCiService.requestPublickey(reqDTO); - - //FIXME::공개키 정보 갱신 - Error code enum 전환 - final ResponseDataHeader dataHeader = pubResDTO.getDataHeader(); - final PublickeyResDataBody dataBody = pubResDTO.getDataBody(); + final PublickeyResDataBody dataBody = niceCiService.requestPublickey(reqDTO); // 3. 공개키 정보 update - if(ObjectUtils.isNotEmpty(dataBody) - && dataHeader.getGwRsltCd().equals("1200") - && dataBody.getRspCd().equals("P000") - && dataBody.getResultCd().equals("0000")){ - niceDTO.setSiteCode(dataBody.getSiteCode()); - niceDTO.setKeyVersion(dataBody.getKeyVersion()); - niceDTO.setPublicKey(dataBody.getPublicKey()); - niceDTO.setValidDtim(dataBody.getValidDtim()); - niceCiMapper.updateNiceCrtfPublickey(niceDTO); - // 공개키 정보 캐쉬 삭제 - cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode()); - - //FIXME:: 교통시설운영처 또는 장사시설인 경우 sync ---------------------------------------- - if(SignguCode.TRAFFIC.getCode().equals(niceDTO.getSignguCode())){ - niceDTO.setSignguCode(SignguCode.FUNERAL.getCode()); - niceCiMapper.updateNiceCrtfPublickey(niceDTO); - } - - if(SignguCode.FUNERAL.getCode().equals(niceDTO.getSignguCode())){ - niceDTO.setSignguCode(SignguCode.TRAFFIC.getCode()); - niceCiMapper.updateNiceCrtfPublickey(niceDTO); - } - // 공개키 정보 캐쉬 삭제 - cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode()); - cacheService.logCache(); - //------------------------------------------------------------------------------------ + niceDTO.setSiteCode(dataBody.getSiteCode()); + niceDTO.setKeyVersion(dataBody.getKeyVersion()); + niceDTO.setPublicKey(dataBody.getPublicKey()); + niceDTO.setValidDtim(dataBody.getValidDtim()); + niceCiMapper.updateNiceCrtfPublickey(niceDTO); + // 공개키 정보 캐쉬 삭제 + cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode()); - return pubResDTO; - } + updateNiceCerfInfoSync(niceDTO, reqDTO, NiceCiWrkDiv.PUBLIC_KEY); - //FIXME::에러처리 방안 설정후 적용 할 것 - throw BizRuntimeException.create(JsonUtils.toJson(dataHeader)); + return dataBody; } - - //-------------------------------------------------------------------------------- - // 공개키(Publickey) //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // 대칭키 : symmetrickey //-------------------------------------------------------------------------------- - /** ** 0. cache call @@ -221,109 +183,78 @@ public class BizNiceCiService extends EgovAbstractServiceImpl implements IBizNic */ @Transactional @Override - public SymmetrickeyResponse requestRegSymmetrickey(final NiceCiRequest reqDTO) { - final String signguCode = reqDTO.getSignguCode(); - final String ffnlgCode = reqDTO.getFfnlgCode(); - - //FIXME::NICE 연계이후 메소드 교체 + public SymkeyStatInfo requestRegSymmetrickey(final NiceCiRequest reqDTO) { final SymkeyRegInfo symkeyRegInfo = CmmNiceCiUtils.getSymkeyRegInfo(); - SymmetrickeyResponse symResDTO = niceCiService.requestRegSymmetrickey(reqDTO, symkeyRegInfo); - - 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()) - .ffnlgCode(reqDTO.getFfnlgCode()) - .build(); - niceDTO.setBefSymkeyVersion(symkeyStatInfo.getBefSymkeyVersion()); - niceDTO.setBefSymkeyValidDtim(symkeyStatInfo.getBefValidDtim()); - niceDTO.setBefSymkeyKey(niceDTO.getCurSymkeyKey()); - niceDTO.setBefSymkeyIv(niceDTO.getCurSymkeyIv()); - niceDTO.setBefSymkeyHmacKey(niceDTO.getCurSymkeyHmacKey()); - - niceDTO.setCurSymkeyVersion(symkeyStatInfo.getCurSymkeyVersion()); - niceDTO.setCurSymkeyValidDtim(symkeyStatInfo.getCurValidDtim()); - niceDTO.setCurSymkeyKey(symkeyRegInfo.getKey()); - niceDTO.setCurSymkeyIv(symkeyRegInfo.getIv()); - niceDTO.setCurSymkeyHmacKey(symkeyRegInfo.getHmacKey()); - - niceCiMapper.updateNiceCrtfSymkey(niceDTO); - // 공개키 정보 캐쉬 삭제 - cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode()); - - //FIXME:: 교통시설운영처 또는 장사시설인 경우 sync ---------------------------------------- - 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(); - //------------------------------------------------------------------------------------ + final SymkeyStatInfo symkeyStatInfo = niceCiService.requestRegSymmetrickey(reqDTO, symkeyRegInfo); + final NiceCiInfo niceDTO = NiceCiInfo.builder() + .signguCode(reqDTO.getSignguCode()) + .ffnlgCode(reqDTO.getFfnlgCode()) + .build(); + + niceDTO.setBefSymkeyVersion(symkeyStatInfo.getBefSymkeyVersion()); + niceDTO.setBefSymkeyValidDtim(symkeyStatInfo.getBefValidDtim()); + niceDTO.setBefSymkeyKey(niceDTO.getCurSymkeyKey()); + niceDTO.setBefSymkeyIv(niceDTO.getCurSymkeyIv()); + niceDTO.setBefSymkeyHmacKey(niceDTO.getCurSymkeyHmacKey()); + + niceDTO.setCurSymkeyVersion(symkeyStatInfo.getCurSymkeyVersion()); + niceDTO.setCurSymkeyValidDtim(symkeyStatInfo.getCurValidDtim()); + niceDTO.setCurSymkeyKey(symkeyRegInfo.getKey()); + niceDTO.setCurSymkeyIv(symkeyRegInfo.getIv()); + niceDTO.setCurSymkeyHmacKey(symkeyRegInfo.getHmacKey()); + + niceCiMapper.updateNiceCrtfSymkey(niceDTO); + // 공개키 정보 캐쉬 삭제 + cacheService.removeNiceCiInfoCache(niceDTO.getSignguCode(), niceDTO.getFfnlgCode()); - return symResDTO; + updateNiceCerfInfoSync(niceDTO, reqDTO, NiceCiWrkDiv.SYM_KEY); - }else{ - throw BizRuntimeException.create(JsonUtils.toJson(symResDTO)); - } + return symkeyStatInfo; } //-------------------------------------------------------------------------------- - // 대칭키 : symmetrickey - //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // 아이핀 CI 요청 //-------------------------------------------------------------------------------- - public IpinCiResponse requestCi(final NiceCiRequest reqDTO) { - IpinCiResponse ipinCiResponse = 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; + public IpinCiResEncData requestCi(final NiceCiRequest reqDTO) { + return niceCiService.requestCi(reqDTO); } - - //-------------------------------------------------------------------------------- - // 아이핀 CI 요청 //-------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------- - - - - private void updateNiceCerfInfoSync(final NiceCiInfo niceDTO, final NiceCiRequest reqDTO) { - //FIXME:: 교통시설운영처 또는 장사시설인 경우 sync ---------------------------------------- + /** + ** 카카오페이 전자문서 발송 요청 에러 코드 */ + @Getter public enum Error { INVALID_VALUE("INVALID_VALUE") , UNIDENTIFIED_USER("UNIDENTIFIED_USER") @@ -87,15 +88,13 @@ public class ApiConstants { this.code = code; } - public String getCode() { - return this.code; - } } /** * 카카오페이 문서 상태 * SENT(송신) > RECEIVED(수신) > READ(열람)/EXPIRED(미열람자료의 기한만료) */ + @Getter public enum DocBoxStatus { SENT("SENT") , RECEIVED("RECEIVED") @@ -109,14 +108,12 @@ public class ApiConstants { this.code = code; } - public String getCode() { - return this.code; - } } /** * 발송처리상태 : ENS003 */ + @Getter public enum SndngProcessStatus { ACCEPT("accept"), ACCEPT_OK("accept-ok"), @@ -141,14 +138,12 @@ public class ApiConstants { this.code = code; } - public String getCode() { - return this.code; - } } /** * 발송구분코드 */ + @Getter public enum SndngSeCode { SMS("SMS"), KAKAO_MY_DOC("KKO-MY-DOC"), @@ -161,14 +156,12 @@ public class ApiConstants { this.code = code; } - public String getCode() { - return this.code; - } } /** * SignguCode */ + @Getter public enum SignguCode { /** * 교통시설운영처 @@ -186,8 +179,12 @@ public class ApiConstants { this.code = code; } - public String getCode() { - return this.code; - } + } + + public enum NiceCiWrkDiv { + TOKEN, + PUBLIC_KEY, + SYM_KEY, + CI } }+ * 교통시설운영처와 승화원의 Nice CI 정보 sync + * @param niceDTO NiceCiInfo + * @param reqDTO NiceCiRequest + * @param wrkDiv NiceCiWrkDiv + *+ */ + private void updateNiceCerfInfoSync(final NiceCiInfo niceDTO, final NiceCiRequest reqDTO, final NiceCiWrkDiv wrkDiv) { + // 교통시설운영처 또는 장사시설인 경우 sync ---------------------------------------- if(SignguCode.TRAFFIC.getCode().equals(reqDTO.getSignguCode())){ niceDTO.setSignguCode(SignguCode.FUNERAL.getCode()); - niceCiMapper.updateNiceCrtfToken(niceDTO); } if(SignguCode.FUNERAL.getCode().equals(reqDTO.getSignguCode())){ niceDTO.setSignguCode(SignguCode.TRAFFIC.getCode()); - niceCiMapper.updateNiceCrtfToken(niceDTO); + } + + switch(wrkDiv){ + case TOKEN: + niceCiMapper.updateNiceCrtfToken(niceDTO); + break; + case PUBLIC_KEY: + niceCiMapper.updateNiceCrtfPublickey(niceDTO); + break; + case SYM_KEY: + niceCiMapper.updateNiceCrtfSymkey(niceDTO); + break; + default: + break; + } // 공개키 정보 캐쉬 삭제 diff --git a/mens-api/src/main/java/kr/xit/biz/nice/service/IBizNiceCiService.java b/mens-api/src/main/java/kr/xit/biz/nice/service/IBizNiceCiService.java index ee30e27..1e7cd74 100644 --- a/mens-api/src/main/java/kr/xit/biz/nice/service/IBizNiceCiService.java +++ b/mens-api/src/main/java/kr/xit/biz/nice/service/IBizNiceCiService.java @@ -1,10 +1,10 @@ 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.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.PublickeyResDataBody; +import kr.xit.biz.ens.model.nice.NiceCiDTO.SymkeyStatInfo; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; /** @@ -35,7 +35,7 @@ public interface IBizNiceCiService { //-------------------------------------------------------------------------------- // 공개키(Publickey) //-------------------------------------------------------------------------------- - PublickeyResponse requestPublickey(final NiceCiRequest reqDTO); + PublickeyResDataBody requestPublickey(final NiceCiRequest reqDTO); //-------------------------------------------------------------------------------- // 공개키(Publickey) //-------------------------------------------------------------------------------- @@ -43,7 +43,7 @@ public interface IBizNiceCiService { //-------------------------------------------------------------------------------- // 대칭키 : symmetrickey //-------------------------------------------------------------------------------- - SymmetrickeyResponse requestRegSymmetrickey(final NiceCiRequest reqDTO); + SymkeyStatInfo requestRegSymmetrickey(final NiceCiRequest reqDTO); //-------------------------------------------------------------------------------- // 대칭키 : symmetrickey //-------------------------------------------------------------------------------- @@ -51,7 +51,7 @@ public interface IBizNiceCiService { //-------------------------------------------------------------------------------- // 아이핀 CI 요청 //-------------------------------------------------------------------------------- - IpinCiResponse requestCi(final NiceCiRequest reqDTO); + IpinCiResEncData requestCi(final NiceCiRequest reqDTO); //-------------------------------------------------------------------------------- // 아이핀 CI 요청 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 5b231fb..d6a7e65 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 @@ -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.ExampleObject; 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.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.ResponseDataHeader; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; import kr.xit.biz.nice.service.IBizNiceCiService; import kr.xit.core.model.ApiResponseDTO; -import kr.xit.core.support.utils.JsonUtils; import lombok.RequiredArgsConstructor; -import org.apache.commons.lang3.ObjectUtils; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -45,7 +37,6 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping(value = "/api/biz/nice/v1") public class BizNiceCiController { - private static final String PARAM1 = """ { "signguCode": "88328", @@ -73,7 +64,7 @@ public class BizNiceCiController { name = "교통시설운영처", value = PARAM1), @ExampleObject( - name = "장사시설", + name = "승화원", value = PARAM2) }) }) @@ -92,7 +83,7 @@ public class BizNiceCiController { name = "교통시설운영처", value = PARAM1), @ExampleObject( - name = "장사시설", + name = "승화원", value = PARAM2) }) }) @@ -103,13 +94,10 @@ public class BizNiceCiController { return niceTokenResponse(tokenRevokeResponse.getDataHeader(), tokenRevokeResponse.getDataBody()); } //-------------------------------------------------------------------------------- - // 기관용 Token - //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // 공개키(Publickey) //-------------------------------------------------------------------------------- - /** * * @param reqDTO @@ -123,19 +111,16 @@ public class BizNiceCiController { name = "교통시설운영처", value = PARAM1), @ExampleObject( - name = "장사시설", + name = "승화원", value = PARAM2) }) }) @Operation(summary = "공개키 요청", description = "공개키 요청") @PostMapping(value = "/requestPublickey", produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponseDTO> requestPublickey(@RequestBody final NiceCiRequest reqDTO) { - final PublickeyResponse publickeyResponse = service.requestPublickey(reqDTO); - return response(publickeyResponse.getDataHeader(), publickeyResponse.getDataBody()); + return ApiResponseDTO.success(service.requestPublickey(reqDTO)); } //-------------------------------------------------------------------------------- - // 공개키(Publickey) - //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // 대칭키 : symmetrickey @@ -148,19 +133,15 @@ public class BizNiceCiController { name = "교통시설운영처", value = PARAM1), @ExampleObject( - name = "장사시설", + name = "승화원", value = PARAM2) }) }) @Operation(summary = "대칭키(symmetrickey) 등록 요청", description = "대칭키(symmetrickey) 등록 요청") @PostMapping(value = "/requestRegSymmetrickey", produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponseDTO> requestRegSymmetrickey(@RequestBody final NiceCiRequest reqDTO) { - final SymmetrickeyResponse symResponse = service.requestRegSymmetrickey(reqDTO); - return response(symResponse.getDataHeader(), symResponse.getDataBody()); + return ApiResponseDTO.success(service.requestRegSymmetrickey(reqDTO)); } - - //-------------------------------------------------------------------------------- - // 대칭키 : symmetrickey //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- @@ -174,33 +155,17 @@ public class BizNiceCiController { name = "교통시설운영처", value = PARAM1), @ExampleObject( - name = "장사시설", + name = "승화원", value = PARAM2) }) }) @Operation(summary = "아이핀 CI 요청", description = "아이핀 CI 요청") @PostMapping(value = "/requestCi", produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponseDTO> requestCi(@RequestBody final NiceCiRequest reqDTO) { - final IpinCiResponse ipinCiResponse = 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())); + return ApiResponseDTO.success(service.requestCi(reqDTO)); } //-------------------------------------------------------------------------------- - // 아이핀 CI 요청 - //-------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------- privateApiResponseDTO niceTokenResponse(final ResponseDataHeader resHeader, final T t){ @@ -209,19 +174,4 @@ public class BizNiceCiController { } 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())); - } } 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 8767632..5b9f755 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 @@ -6,6 +6,8 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; 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.NiceCiRequest; 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.NoArgsConstructor; import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.http.HttpHeaders; import org.springframework.util.Base64Utils; @@ -145,19 +148,55 @@ public class CmmNiceCiUtils { 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; + }; + } + /** * - * GW_RSLT_CD : "1200" 성공인 경우 TRAN_ID 체크 - * -> 요청한 응답 인지 체크, 아니면 오류 처리 - * @param tranId - * @param resHeader - * @param t - * @return T - + * Nice CI 에러 처리 : 공개키요청|대칭키등록|아이핀CI요청 + * RW_RSLT_CD - 1200 && rsp_cd - P000 && result_cd - 0000인 경우만 정상 처리 + * RW_RSLT_CD - 1200 && rsp_cd - P000 && result_cd != 0000 인 경우 해당 업무 에러 메세지 return + * -> message-api.properties err.api.nice.[pubKey|symKey|ci].[에러코드] 메세지 + * @param tranId String + * @param resHeader ResponseDataHeader + * @param resBody CommonResponseDataBody **/ - public staticT 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")); - 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())) + ); + } } } 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 a6d6eea..6c5b53b 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,11 +1,11 @@ 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.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.SymmetrickeyResponse; +import kr.xit.biz.ens.model.nice.NiceCiDTO.SymkeyStatInfo; import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; /** @@ -36,7 +36,7 @@ public interface INiceCiService { //-------------------------------------------------------------------------------- // 공개키(Publickey) //-------------------------------------------------------------------------------- - PublickeyResponse requestPublickey(final NiceCiRequest reqDTO); + PublickeyResDataBody requestPublickey(final NiceCiRequest reqDTO); //-------------------------------------------------------------------------------- // 공개키(Publickey) //-------------------------------------------------------------------------------- @@ -44,7 +44,7 @@ public interface INiceCiService { //-------------------------------------------------------------------------------- // 대칭키 : symmetrickey //-------------------------------------------------------------------------------- - SymmetrickeyResponse requestRegSymmetrickey(final NiceCiRequest reqDTO, final + SymkeyStatInfo requestRegSymmetrickey(final NiceCiRequest reqDTO, final SymkeyRegInfo symkeyRegInfo); //-------------------------------------------------------------------------------- // 대칭키 : symmetrickey @@ -53,7 +53,7 @@ public interface INiceCiService { //-------------------------------------------------------------------------------- // 아이핀 CI 요청 //-------------------------------------------------------------------------------- - IpinCiResponse requestCi(final NiceCiRequest reqDTO); + IpinCiResEncData 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 2e76f97..b7b4344 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 @@ -4,23 +4,8 @@ import egovframework.com.cmm.EgovMessageSource; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; -import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiReqDataBody; -import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiReqEncData; -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.biz.common.ApiConstants.NiceCiWrkDiv; +import kr.xit.biz.ens.model.nice.NiceCiDTO.*; import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.spring.annotation.TraceLogging; import kr.xit.core.spring.util.ApiWebClientUtil; @@ -84,7 +69,6 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer //-------------------------------------------------------------------------------- // 기관용 Token //-------------------------------------------------------------------------------- - /** * * @return TokenResponse @@ -144,21 +128,17 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer ); } //-------------------------------------------------------------------------------- - // 기관용 Token - //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // 공개키(Publickey) //-------------------------------------------------------------------------------- - @Override @TraceLogging - public PublickeyResponse requestPublickey(final NiceCiRequest reqDTO) { + public PublickeyResDataBody requestPublickey(final NiceCiRequest reqDTO) { final NiceCiInfo niceDTO = CmmNiceCiUtils.getNiceCiInfo(reqDTO); if(ObjectUtils.isEmpty(niceDTO.getAccessToken())) throw BizRuntimeException.create(messageSource.getMessage("fail.api.nice.token.info")); final String todayDt = DateUtils.getTodayAndNowTime("yyyyMMddHHmmss"); - final String tranId = CmmEnsUtils.generateLengthUuid(24); final PublickeyRequest pubReqDTO = PublickeyRequest.builder() .dataHeader(RequestDataHeader.builder() @@ -185,18 +165,15 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer PublickeyResponse.class, headerMap ); + CmmNiceCiUtils.checkApiResponse(tranId, pubResDTO.getDataHeader(), pubResDTO.getDataBody(), NiceCiWrkDiv.PUBLIC_KEY); - return CmmNiceCiUtils.checkTranIdAndReturn(tranId, pubResDTO.getDataHeader(), pubResDTO); + return pubResDTO.getDataBody(); } - - //-------------------------------------------------------------------------------- - // 공개키(Publickey) //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // 대칭키 : symmetrickey //-------------------------------------------------------------------------------- - /** * * 0. cache call @@ -207,7 +184,7 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer **/ @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); // siteCode set symkeyRegInfo.setSiteCode(niceDTO.getSiteCode()); @@ -241,8 +218,10 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer SymmetrickeyResponse.class, 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 @@ -251,9 +230,9 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer //-------------------------------------------------------------------------------- // 아이핀 CI 요청 //-------------------------------------------------------------------------------- - public IpinCiResponse requestCi(final NiceCiRequest reqDTO) { - NiceCiInfo niceDTO = CmmNiceCiUtils.getSymkeyNiceCiInfo(reqDTO); - IpinCiReqEncData encDataDTO = IpinCiReqEncData.builder() + public IpinCiResEncData requestCi(final NiceCiRequest reqDTO) { + final NiceCiInfo niceDTO = CmmNiceCiUtils.getSymkeyNiceCiInfo(reqDTO); + final IpinCiReqEncData encDataDTO = IpinCiReqEncData.builder() .siteCode(niceDTO.getSiteCode()) //.infoReqType() //default: 1-CI제공 .juminId(reqDTO.getJuminId()) @@ -266,7 +245,6 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer 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); - final IpinCiRequest ipinCiRequest = IpinCiRequest.builder() .dataHeader(RequestDataHeader.builder() .cntyCd(CNTY_CD) @@ -286,12 +264,10 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer String.format("%s %s", AUTH_TYPE_BASIC, Base64Utils.encodeToString( - Base64Utils.encode( - String.format( + String.format( "%s:%s", niceDTO.getClientId(), niceDTO.getClientSecret()).getBytes(StandardCharsets.UTF_8) - ) ) ) ); @@ -305,10 +281,19 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer 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 요청 - //-------------------------------------------------------------------------------- - } 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 9edcc2e..8db81b8 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 @@ -1,6 +1,8 @@ package kr.xit.ens.nice.web; 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 kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest; import kr.xit.core.model.ApiResponseDTO; @@ -33,6 +35,21 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping(value = "/api/ens/nice/v1") 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; //-------------------------------------------------------------------------------- @@ -50,13 +67,10 @@ public class NiceCiController { return ApiResponseDTO.success(service.revokeToken(reqDTO)); } //-------------------------------------------------------------------------------- - // 기관용 Token - //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // 공개키(Publickey) //-------------------------------------------------------------------------------- - /** * * @return @@ -67,8 +81,6 @@ public class NiceCiController { return ApiResponseDTO.success(service.requestPublickey(reqDTO)); } //-------------------------------------------------------------------------------- - // 공개키(Publickey) - //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // 대칭키 : symmetrickey @@ -78,20 +90,27 @@ public class NiceCiController { public ApiResponseDTO> requestRegSymmetrickey(@RequestBody final NiceCiRequest reqDTO) { return ApiResponseDTO.success(service.requestRegSymmetrickey(reqDTO, CmmNiceCiUtils.getSymkeyRegInfo())); } - - //-------------------------------------------------------------------------------- - // 대칭키 : symmetrickey //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // 아이핀 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 요청") @PostMapping(value = "/requestCi", produces = MediaType.APPLICATION_JSON_VALUE) public ApiResponseDTO> requestCi(@RequestBody final NiceCiRequest reqDTO) { return ApiResponseDTO.success(service.requestCi(reqDTO)); } //-------------------------------------------------------------------------------- - // 아이핀 CI 요청 - //-------------------------------------------------------------------------------- } diff --git a/mens-api/src/main/resources/egovframework/messages/message-api.properties b/mens-api/src/main/resources/egovframework/messages/message-api.properties index 18d1e52..1294452 100644 --- a/mens-api/src/main/resources/egovframework/messages/message-api.properties +++ b/mens-api/src/main/resources/egovframework/messages/message-api.properties @@ -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.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 + diff --git a/mens-core/src/main/java/kr/xit/biz/common/ApiConstants.java b/mens-core/src/main/java/kr/xit/biz/common/ApiConstants.java index 47fe69e..79a3a77 100644 --- a/mens-core/src/main/java/kr/xit/biz/common/ApiConstants.java +++ b/mens-core/src/main/java/kr/xit/biz/common/ApiConstants.java @@ -1,5 +1,7 @@ package kr.xit.biz.common; +import lombok.Getter; + /** ** description : @@ -29,6 +31,7 @@ public class ApiConstants { * REPORT : 문서확인 - 리포트 **/ + @Getter public enum Categories { DEFAULT("Default") , BILL("BILL") @@ -44,9 +47,6 @@ public class ApiConstants { this.code = code; } - public String getCode() { - return this.code; - } } /** @@ -72,6 +72,7 @@ public class ApiConstants { *