fix: webclient timeout exception 처리

토큰 유효기간 오류 메세지 처리
dev
gitea-관리자 1 year ago
parent ae62b3b2bc
commit 2239bb5d28

@ -1,6 +1,7 @@
package kr.xit.ens.kt.cmm;
import egovframework.com.cmm.EgovMessageSource;
import java.util.Objects;
import kr.xit.biz.cmm.service.ICmmEnsCacheService;
import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO;
import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO;
@ -55,7 +56,8 @@ public class CmmKtMmsUtils {
if(ObjectUtils.isEmpty(dto)) throw BizRuntimeException.create(messageSource.getMessage("fail.api.rlaybsnm.info"));
// 토큰 유효기간 체크
if(DateUtils.getTodayAndNowTime("yyyy-MM-dd HH:mm:ss").compareTo(dto.getKtTokenExpiresIn()) < 0) return dto;
if(DateUtils.getTodayAndNowTime("yyyy-MM-dd HH:mm:ss").compareTo(
Objects.requireNonNull(dto.getKtTokenExpiresIn(), () -> messageSource.getMessage("fail.api.kt.token.invalid.expired"))) < 0) return dto;
ktMmsService.requestToken(
KtMnsRequest.builder()

@ -5,6 +5,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import kr.xit.biz.cmm.service.ICmmEnsCacheService;
import kr.xit.biz.common.ApiConstants.NiceCiWrkDiv;
import kr.xit.biz.ens.model.nice.NiceCiDTO.CommonResponseDataBody;
@ -78,8 +79,7 @@ public class CmmNiceCiUtils {
final NiceCiInfo niceDTO = getNiceCiInfo(reqDTO);
if(ObjectUtils.isEmpty(niceDTO.getAccessToken())) throw BizRuntimeException.create(messageSource.getMessage("fail.api.nice.token.info"));
if(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss").compareTo(niceDTO.getValidDtim()) < 0) return niceDTO;
if(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss").compareTo(Objects.requireNonNull(niceDTO.getValidDtim(), () -> messageSource.getMessage("fail.api.nice.token.invalid.expired"))) < 0) return niceDTO;
// 1. 토큰 폐기
TokenRevokeResponse revokeResDTO = bizNiceService.revokeToken(reqDTO);
@ -106,7 +106,8 @@ public class CmmNiceCiUtils {
*/
public static NiceCiInfo getSymkeyNiceCiInfo(final NiceCiRequest reqDTO) {
final NiceCiInfo niceDTO = getPublickeyNiceCiInfo(reqDTO);
if(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss").compareTo(niceDTO.getCurSymkeyValidDtim()) < 0) return niceDTO;
if(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss").compareTo(
Objects.requireNonNull(niceDTO.getCurSymkeyValidDtim(), () -> messageSource.getMessage("fail.api.nice.symkey.invalid.expired"))) < 0) return niceDTO;
// 대칭키 발행 등록
//TODO::에러 처리 - throw exception

@ -235,6 +235,7 @@ public class NiceCiService extends EgovAbstractServiceImpl implements INiceCiSer
final IpinCiReqEncData encDataDTO = IpinCiReqEncData.builder()
.siteCode(niceDTO.getSiteCode())
//.infoReqType() //default: 1-CI제공
.reqDtim(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss"))
.juminId(reqDTO.getJuminId())
.reqNo(CmmEnsUtils.generateLengthUuid(30))

@ -4,8 +4,8 @@
contract:
# milisecond
connection:
timeout: 30000
readTimeout: 30000
timeout: 20000
readTimeout: 20000
thread:
# 동시 실행 스레드 개수
corePoolSize: 5

@ -105,3 +105,9 @@ app:
rcv: /rcv
backup: /backup
err: /err
contract:
# milisecond
connection:
timeout: 60000
readTimeout: 60000

@ -5,9 +5,12 @@ fail.api.nice.info=NICE \uC778\uC99D \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5
fail.api.nice.token.info=NICE Access token \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.
fail.api.nice.revoke.token=\uD1A0\uD070(NICE) \uD3D0\uAE30\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4
fail.api.nice.invalid.tranId=NICE \uC778\uC99D \uC694\uCCAD\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4(TRAN_ID \uBD88\uC77C\uCE58)
fail.api.nice.token.invalid.expired=Nice token \uC720\uD6A8\uAE30\uAC04\uC774 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4[null].
fail.api.nice.symkey.invalid.expired=Nice \uB300\uCE6D\uD0A4 \uC720\uD6A8\uAE30\uAC04\uC774 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4[null].
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.
fail.api.kt.token.invalid.expired=kt access token \uC720\uD6A8\uAE30\uAC04\uC774 \uC798\uBABB\uB418\uC5C8\uC2B5\uB2C8\uB2E4[null].
err.api.nice.pubKey.0000=\uACF5\uAC1C\uD0A4\uBC1C\uAE09
err.api.nice.pubKey.0001=\uD544\uC218 \uC785\uB825\uAC12 \uC624\uB958

@ -40,13 +40,11 @@ public class ErrorParse {
if(e instanceof ClientError) {
ClientError ce = (ClientError)e;
return ApiResponseDTO.error(String.valueOf(ce.getStatus()), ce.getBody(), ce.getStatus());
//return ApiResponseDTO.error(String.valueOf(ce.getStatus().value()), ce.getBody(), ce.getStatus());
}
if(e instanceof ServerError) {
ServerError ce = (ServerError) e;
return ApiResponseDTO.error(String.valueOf(ce.getStatus()), ce.getBody(), ce.getStatus());
//return ApiResponseDTO.error(String.valueOf(ce.getStatus().value()), ce.getBody(), ce.getStatus());
}
// Async(React) Exception 처리
@ -67,6 +65,10 @@ public class ErrorParse {
}
}
if(e instanceof ReadTimeoutException){
return getTimeoutException();
}
// Async(React) Exception 처리
if(e.getCause() instanceof WebClientRequestException){
@ -84,6 +86,7 @@ public class ErrorParse {
return ApiResponseDTO.error(errCode, message, httpStatus);
}
@SuppressWarnings("rawtypes")
private static ApiResponseDTO getTimeoutException(){
return ApiResponseDTO.error(
String.valueOf(HttpStatus.REQUEST_TIMEOUT.value()),

Loading…
Cancel
Save