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 b49f59f..85f6ecc 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 @@ -17,6 +17,7 @@ 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.service.AbstractService; +import kr.xit.core.support.utils.JsonUtils; import kr.xit.ens.nice.cmm.CmmNiceCiUtils; import kr.xit.ens.nice.service.INiceCiService; import lombok.RequiredArgsConstructor; @@ -64,8 +65,29 @@ public class BizNiceCiService extends AbstractService implements IBizNiceCiServi @Override @Transactional public NiceTokenResponse generateToken(final NiceCiRequest reqDTO){ - final NiceTokenResponse tokenResponse = niceCiService.generateToken(reqDTO); - final ResponseDataHeader dataHeader = tokenResponse.getDataHeader(); + + NiceTokenResponse tokenResponse = niceCiService.generateToken(reqDTO); + ResponseDataHeader dataHeader = tokenResponse.getDataHeader(); + + // token이 만료 및 폐기된 상태 + if(dataHeader.getGwRsltCd().equals("1800")){ + // 1. 토큰 폐기 + try { + final TokenRevokeResponse revokeResDTO = revokeToken(reqDTO); + + if(!(revokeResDTO.getDataHeader().getGwRsltCd().equals("1200") && revokeResDTO.getDataBody().isResult())){ + throw BizRuntimeException.create(JsonUtils.toJson(revokeResDTO.getDataHeader())); + } + } catch (BizRuntimeException be){ + throw be; + } catch (Exception e){ + throw BizRuntimeException.create(e.getMessage()); + } + + // 토큰 폐기후 재발급 + tokenResponse = niceCiService.generateToken(reqDTO); + dataHeader = tokenResponse.getDataHeader(); + } if(dataHeader.getGwRsltCd().equals("1200")){ final TokenResDataBody dataBody = tokenResponse.getDataBody(); 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 c5cd16a..9da1639 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 @@ -12,14 +12,12 @@ 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; import kr.xit.biz.ens.model.nice.NiceCiDTO.SymkeyRegInfo; -import kr.xit.biz.ens.model.nice.NiceCiDTO.TokenRevokeResponse; import kr.xit.biz.nice.service.IBizNiceCiService; import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.spring.util.ApiSpringUtils; import kr.xit.core.spring.util.CoreSpringUtils; import kr.xit.core.spring.util.MessageUtil; 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.service.INiceCiService; import lombok.AccessLevel; @@ -70,9 +68,8 @@ public class CmmNiceCiUtils { * 공개키 정보 조회 * 0. cache call * --> 공개키 잔여일 기준 보다 작으면 - * 1. 토큰 폐기 - * 2. 공개키 재발급 - * 4. cache reload + * 1. 공개키 재발급 + * 2. cache reload * @param reqDTO NiceCiRequest * @return NiceCiRequest * @@ -84,12 +81,12 @@ public class CmmNiceCiUtils { if(StringUtils.isNotEmpty(niceDTO.getValidDtim()) && DateUtils.getTodayAndNowTime(ApiConstants.FMT_DT_EMPTY_DLT).compareTo(niceDTO.getValidDtim()) < 0) return niceDTO; - // 1. 토큰 폐기 - TokenRevokeResponse revokeResDTO = bizNiceService.revokeToken(reqDTO); - - if(!(revokeResDTO.getDataHeader().getGwRsltCd().equals("1200") && revokeResDTO.getDataBody().isResult())){ - throw BizRuntimeException.create(JsonUtils.toJson(revokeResDTO.getDataHeader())); - } +// // 1. 토큰 폐기 +// TokenRevokeResponse revokeResDTO = bizNiceService.revokeToken(reqDTO); +// +// if(!(revokeResDTO.getDataHeader().getGwRsltCd().equals("1200") && revokeResDTO.getDataBody().isResult())){ +// throw BizRuntimeException.create(JsonUtils.toJson(revokeResDTO.getDataHeader())); +// } // 2. 공개키 발급 처리 //TODO::에러 처리 - throw exception