fix: 문서중개자 정보 조회 fix

KT 발송 결과 fix
dev
gitea-관리자 1 year ago
parent 66a70ca5aa
commit 483faf9e31

@ -15,6 +15,7 @@ import kr.xit.biz.ens.model.kt.KtTokenDTO.KtTokenResponse;
import kr.xit.biz.kt.mapper.IBizKtMmsMapper;
import kr.xit.core.exception.BizRuntimeException;
import kr.xit.core.spring.annotation.TraceLogging;
import kr.xit.core.support.utils.Checks;
import kr.xit.core.support.utils.DateUtils;
import kr.xit.ens.cmm.CmmEnsUtils;
import kr.xit.ens.kt.service.IKtMmsService;
@ -118,6 +119,11 @@ public class BizKtMmsService extends EgovAbstractServiceImpl implements IBizKtMm
if(!errors.isEmpty()) return throwError(errors);
for(KtMsgRsltReqData dto : reqDTO.getReqs()){
// 결과코드가 '40' 이고 열람타임스탬프가 있는 경우 -> 결과코드 '열람확인:60'으로 reset
if("40".equals(dto.getMmsSndgRsltDvcd()) && Checks.isNotEmpty(dto.getMmsRdgTmst())){
dto.setMmsSndgRsltDvcd("60");
}
dto.setMmsSndgRsltDvcdMsg(messageSource.getMessage("info.api.kt.msg.rslt."+dto.getMmsSndgRsltDvcd()));
if(mapper.updateKtBcDtl(dto) != 1) {
errors.add(new ErrorMsg(

@ -1,6 +1,6 @@
package kr.xit.ens.cmm;
import java.io.IOException;
import egovframework.com.cmm.EgovMessageSource;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
@ -27,10 +27,21 @@ import javax.crypto.spec.SecretKeySpec;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import kr.xit.biz.cmm.service.ICmmEnsCacheService;
import kr.xit.biz.common.ApiConstants;
import kr.xit.biz.common.ApiConstants.SndngSeCode;
import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO;
import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO;
import kr.xit.biz.ens.model.kt.KtCommonDTO.ErrorMsg;
import kr.xit.biz.ens.model.kt.KtCommonDTO.KtMnsRequest;
import kr.xit.core.exception.BizRuntimeException;
import kr.xit.core.spring.util.ApiSpringUtils;
import kr.xit.core.spring.util.CoreSpringUtils;
import kr.xit.core.support.utils.DateUtils;
import kr.xit.ens.kt.service.IKtMmsService;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.util.Base64Utils;
/**
@ -51,6 +62,54 @@ import org.springframework.util.Base64Utils;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CmmEnsUtils {
private static final EgovMessageSource messageSource = CoreSpringUtils.getMessageSource();
private static final ICmmEnsCacheService cacheService = ApiSpringUtils.getCmmEnsCacheService();
private static final IKtMmsService ktMmsService = ApiSpringUtils.getKtMmsService();
/**
*
* @param signguCode string
* @param ffnlgCode String
* @param seCode SndngSeCode
* @return CmmEnsRlaybsnmDTO
*/
public static CmmEnsRlaybsnmDTO getRlaybsnmInfo(final String signguCode, final String ffnlgCode, final
SndngSeCode seCode) {
CmmEnsRequestDTO ensDTO = CmmEnsRequestDTO.builder()
.signguCode(signguCode)
.ffnlgCode(ffnlgCode)
.profile(ApiConstants.PROFILE)
.build();
final CmmEnsRlaybsnmDTO dto = cacheService.getRlaybsnmInfoCache(ensDTO);
cacheService.logCache();
if(ObjectUtils.isEmpty(dto)) throw BizRuntimeException.create(messageSource.getMessage("fail.api.rlaybsnm.info"));
// KT인 경우 토큰유효기간 check
if(SndngSeCode.KT_BC.equals(seCode)){
if(DateUtils.getTodayAndNowTime(ApiConstants.FMT_DT_STD).compareTo(dto.getKtTokenExpiresIn()) < 0) return dto;
// 유효기간이 경과된 경우 재발급
ktMmsService.requestToken(
KtMnsRequest.builder()
.signguCode(signguCode)
.ffnlgCode(ffnlgCode)
.profile(ApiConstants.PROFILE)
.build()
);
return cacheService.getRlaybsnmInfoCache(ensDTO);
}
return dto;
}
/**
* <pre>
* parameter validation check
* invalid parameter message -> String BizRuntimeException throw
* @param t T
* </pre>
*/
public static <T> void validate(T t) {
Locale.setDefault(Locale.KOREA);
final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
@ -65,6 +124,11 @@ public class CmmEnsUtils {
}
}
/**
* parameter validation check
* @param t T
* @return List<ErrorMsg>
*/
public static <T> List<ErrorMsg> getValidateErrors(T t) {
Locale.setDefault(Locale.KOREA);
final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
@ -78,6 +142,11 @@ public class CmmEnsUtils {
return new ArrayList<>();
}
/**
* length UUID String return -> '-' remove
* @param length
* @return
*/
public static String generateLengthUuid(int length) {
final String allChars = UUID.randomUUID().toString().replace("-", "");
final Random random = new Random();
@ -91,15 +160,9 @@ public class CmmEnsUtils {
/**
*
*
* @param publicKeyString
* @param symkeyRegInfo
* @param publicKeyString String
* @param symkeyRegInfo String
* @return String
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
* @throws NoSuchPaddingException
* @throws InvalidKeyException
* @throws IllegalBlockSizeException
* @throws BadPaddingException
*/
public static String encSymkeyRegInfo(String publicKeyString, String symkeyRegInfo) {
try {
@ -122,10 +185,8 @@ public class CmmEnsUtils {
/**
* sha256
*
* @param text
* @return
* @throws IOException
* @throws NoSuchAlgorithmException
* @param text String
* @return String
*/
public static String hexSha256(final String text) {
final StringBuilder sbuf = new StringBuilder();
@ -151,11 +212,12 @@ public class CmmEnsUtils {
/**
* <pre>
* Nice ci
* Base64 encoding return
* @param key
* @param iv
* @param planText
* AES -> Base64 encoding return
* -> Nice ci
*
* @param key String
* @param iv String
* @param planText String
* @return String Base64 encoding data
* </pre>
*/
@ -178,9 +240,8 @@ public class CmmEnsUtils {
/**
* <pre>
* Hmac (integrity_value)
* @param hmacKey
* @param message
*
* @param hmacKey String
* @param message String
* @return String
* </pre>
*/
@ -197,6 +258,13 @@ public class CmmEnsUtils {
}
}
/**
* AES
* @param encData String
* @param key String
* @param iv String
* @return String
*/
public static String decodeAesData(String encData, String key, String iv) {
final byte[] respDataEnc = Base64.getDecoder().decode(encData.getBytes());

@ -0,0 +1,35 @@
package kr.xit.ens.cmm;
import egovframework.com.cmm.EgovMessageSource;
import kr.xit.biz.cmm.service.ICmmEnsCacheService;
import kr.xit.core.spring.util.ApiSpringUtils;
import kr.xit.core.spring.util.CoreSpringUtils;
import kr.xit.ens.kt.service.IKtMmsService;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/**
* <pre>
* description :
*
* packageName : kr.xit.ens.kt.cmm
* fileName : CmmKtMmsUtils
* author : limju
* date : 2023-09-19
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-09-19 limju
*
* </pre>
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CmmKtMmsUtils {
private static final EgovMessageSource messageSource = CoreSpringUtils.getMessageSource();
private static final ICmmEnsCacheService cacheService = ApiSpringUtils.getCmmEnsCacheService();
private static final IKtMmsService ktMmsService = ApiSpringUtils.getKtMmsService();
}

@ -9,7 +9,6 @@ import kr.xit.biz.ens.model.epost.EPostDTO.EpostTraceResponse;
import kr.xit.core.spring.annotation.TraceLogging;
import kr.xit.core.spring.util.ApiWebClientUtil;
import kr.xit.ens.cmm.CmmEnsUtils;
import kr.xit.ens.kt.cmm.CmmKtMmsUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
@ -49,7 +48,7 @@ public class EpostService extends EgovAbstractServiceImpl implements IEpostServi
@Override
@TraceLogging
public EpostTraceResponse postTrackInfo(final EpostTraceRequest reqDTO) {
final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode(),
final CmmEnsRlaybsnmDTO ktMnsInfo = CmmEnsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode(),
SndngSeCode.PPLUS);reqDTO.setServiceKey(ktMnsInfo.getEpostServiceKey());
final Map<String,String> headerMap = new HashMap<>();

@ -31,7 +31,7 @@ import kr.xit.core.spring.annotation.TraceLogging;
import kr.xit.core.spring.util.ApiWebClientUtil;
import kr.xit.core.support.utils.Checks;
import kr.xit.core.support.utils.JsonUtils;
import kr.xit.ens.kt.cmm.CmmKtMmsUtils;
import kr.xit.ens.cmm.CmmEnsUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@ -307,6 +307,6 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements
}
private CmmEnsRlaybsnmDTO getRlaybsnmInfo(final CmmEnsRequestDTO request){
return CmmKtMmsUtils.getRlaybsnmInfo(request.getSignguCode(), request.getFfnlgCode(), SndngSeCode.KAKAO);
return CmmEnsUtils.getRlaybsnmInfo(request.getSignguCode(), request.getFfnlgCode(), SndngSeCode.KAKAO);
}
}

@ -1,79 +0,0 @@
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.common.ApiConstants;
import kr.xit.biz.common.ApiConstants.SndngSeCode;
import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO;
import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO;
import kr.xit.core.exception.BizRuntimeException;
import kr.xit.core.spring.util.ApiSpringUtils;
import kr.xit.core.spring.util.CoreSpringUtils;
import kr.xit.core.support.utils.DateUtils;
import kr.xit.ens.kt.service.IKtMmsService;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
/**
* <pre>
* description :
*
* packageName : kr.xit.ens.kt.cmm
* fileName : CmmKtMmsUtils
* author : limju
* date : 2023-09-19
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-09-19 limju
*
* </pre>
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CmmKtMmsUtils {
private static final EgovMessageSource messageSource = CoreSpringUtils.getMessageSource();
private static final ICmmEnsCacheService cacheService = ApiSpringUtils.getCmmEnsCacheService();
private static final IKtMmsService ktMmsService = ApiSpringUtils.getKtMmsService();
/**
* KT MMS
* @return
*/
public static CmmEnsRlaybsnmDTO getRlaybsnmInfo(final String signguCode, final String ffnlgCode, final
SndngSeCode seCode) {
CmmEnsRequestDTO ensDTO = CmmEnsRequestDTO.builder()
.signguCode(signguCode)
.ffnlgCode(ffnlgCode)
.profile(ApiConstants.PROFILE)
.build();
final CmmEnsRlaybsnmDTO dto = cacheService.getRlaybsnmInfoCache(ensDTO);
cacheService.logCache();
if(ObjectUtils.isEmpty(dto)) throw BizRuntimeException.create(messageSource.getMessage("fail.api.rlaybsnm.info"));
//TODO :: null인 경우, pplus, kakao인 경우
// 토큰 유효기간 체크
if(DateUtils.getTodayAndNowTime(ApiConstants.FMT_DT_STD).compareTo(
Objects.requireNonNull(dto.getKtTokenExpiresIn(), () -> messageSource.getMessage("fail.api.token.invalid.expired", new String[]{seCode.getDesc()}))) < 0) return dto;
return dto;
/*
//TODO :: comment remove after test
ktMmsService.requestToken(
KtMnsRequest.builder()
.signguCode(signguCode)
.ffnlgCode(ffnlgCode)
.profile(ApiConstants.PROFILE)
.build()
);
return cacheService.getRlaybsnmInfoCache(ensDTO);
*/
}
}

@ -36,7 +36,6 @@ import kr.xit.core.spring.util.ApiWebClientUtil;
import kr.xit.core.support.utils.DateUtils;
import kr.xit.core.support.utils.JsonUtils;
import kr.xit.ens.cmm.CmmEnsUtils;
import kr.xit.ens.kt.cmm.CmmKtMmsUtils;
import lombok.RequiredArgsConstructor;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
import org.springframework.beans.factory.annotation.Value;
@ -461,6 +460,6 @@ public class KtMmsService extends EgovAbstractServiceImpl implements IKtMmsServi
//------------------------------------------------------------------------------
private CmmEnsRlaybsnmDTO getRlaybsnmInfo(final KtCommonDTO.KtMnsRequest request){
return CmmKtMmsUtils.getRlaybsnmInfo(request.getSignguCode(), request.getFfnlgCode(), SndngSeCode.KT_BC);
return CmmEnsUtils.getRlaybsnmInfo(request.getSignguCode(), request.getFfnlgCode(), SndngSeCode.KT_BC);
}
}

@ -18,7 +18,6 @@ import kr.xit.core.spring.util.ApiWebClientUtil;
import kr.xit.core.support.utils.FileUtil;
import kr.xit.core.support.utils.JsonUtils;
import kr.xit.ens.cmm.CmmEnsUtils;
import kr.xit.ens.kt.cmm.CmmKtMmsUtils;
import kr.xit.ens.pplus.mapper.IPplusMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -96,7 +95,7 @@ public class PplusService extends EgovAbstractServiceImpl implements IPplusServi
}
public PpCommonResponse accept(final SndngMssageParam paramDTO, final String unitySndngMstId) {
final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(paramDTO.getSignguCode(), paramDTO.getFfnlgCode(), SndngSeCode.PPLUS);
final CmmEnsRlaybsnmDTO ktMnsInfo = CmmEnsUtils.getRlaybsnmInfo(paramDTO.getSignguCode(), paramDTO.getFfnlgCode(), SndngSeCode.PPLUS);
MultipartFile pstFile = FileUtil.createMutipartFile(unitySndngMstId + ".json", FILE_TEMP_PATH);
@ -122,7 +121,7 @@ public class PplusService extends EgovAbstractServiceImpl implements IPplusServi
@Override
public PpStatusResponse statusBulks(PpStatusRequest reqDTO) {
final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode(), SndngSeCode.PPLUS);
final CmmEnsRlaybsnmDTO ktMnsInfo = CmmEnsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode(), SndngSeCode.PPLUS);
reqDTO.setApiKey(ktMnsInfo.getPplusApiKey());
reqDTO.setSignguCode(null);
reqDTO.setFfnlgCode(null);

@ -62,5 +62,5 @@ info.api.kt.msg.rslt.4V=MMS\uBC1C\uC1A1 \uC218\uC2E0\uB4F1\uB85D \uD734\uB300\uD
info.api.kt.msg.rslt.4W=MMS\uBC1C\uC1A1 \uAE30\uB3D9\uC758 \uC0AC\uC804\uBB38\uC790 \uC81C\uC678
info.api.kt.msg.rslt.50=\uC218\uC2E0\uD655\uC778 \uC218\uC2E0\uC131\uACF5
#(MMS\uBC1C\uC1A1\uACB0\uACFC\uC21C\uBC88=2, \uC5F4\uB78C\uD0C0\uC784\uC2A4\uD0EC\uD504\uAC00 \uC788\uB294 \uACBD\uC6B0)
info.api.kt.msg.rslt.60=\uC5F4\uB78C\uD655\uC778 \uC5F4\uB78C\uD655\uC778(MMS\uBC1C\uC1A1\uACB0\uACFC\uC21C\uBC88=2, \uC5F4\uB78C\uD0C0\uC784\uC2A4\uD0EC\uD504\uAC00 \uC788\uB294 \uACBD\uC6B0)
info.api.kt.msg.rslt.60=\uC5F4\uB78C\uD655\uC778 \uC5F4\uB78C\uD655\uC778(MMS\uBC1C\uC1A1\uACB0\uACFC\uCF54\uB4DC=40, \uC5F4\uB78C\uD0C0\uC784\uC2A4\uD0EC\uD504\uAC00 \uC788\uB294 \uACBD\uC6B0)

Loading…
Cancel
Save