Compare commits
8 Commits
6b49e518e5
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 401fbbc41f | |||
| d60809ccff | |||
| ab42f2e429 | |||
| ca8c7d9d30 | |||
| d2fde8f99e | |||
| 4cb1df3a9f | |||
| 86737ee91b | |||
| ea68606fbc |
@@ -14,6 +14,6 @@ eapim-admin 에서 포함하여 테스트 이용시 느린 부팅 속도 떄문
|
||||
GIT_SSH_COMMAND='ssh -i ~/.ssh/id_rsa-jenkins' git pull origin jenkins_with_weblogic
|
||||
|
||||
# test run
|
||||
KJB_EAPIM_TEST_ENABLED=TRUE kjb-gradle.sh :eapim-admin-kjb:test --tests "com.eactive.ext.kjb.ums.test.UmsTest.testSms" -Psafedb
|
||||
KJB_EAPIM_TEST_ENABLED=TRUE kjb-gradle.sh :eapim-admin-kjb:test --tests "com.eactive.ext.kjb.ums.test.UmsTest.testEmail" -Psafedb
|
||||
KJB_EAPIM_TEST_ENABLED=TRUE ./gradlew :eapim-admin-kjb:test --tests "com.eactive.ext.kjb.ums.test.UmsTest.testSms" -Psafedb
|
||||
KJB_EAPIM_TEST_ENABLED=TRUE ./gradlew :eapim-admin-kjb:test --tests "com.eactive.ext.kjb.ums.test.UmsTest.testEmail" -Psafedb
|
||||
```
|
||||
@@ -1,3 +0,0 @@
|
||||
/main/
|
||||
/test/
|
||||
/default/
|
||||
+3
-1
@@ -26,7 +26,9 @@ dependencies {
|
||||
|
||||
api 'com.eactive.elink.common:elink-common-data:4.5.5'
|
||||
|
||||
implementation fileTree(dir: "ext-libs", include: ["*.jar"])
|
||||
// log4j-core / log4j-1.2-api 는 log4j-to-slf4j 로 대체 (Hibernate/iBATIS 로그를 logback 으로 라우팅)
|
||||
implementation fileTree(dir: "ext-libs", include: ["*.jar"], exclude: ["log4j-core-*.jar", "log4j-1.2-api-*.jar"])
|
||||
implementation 'org.apache.logging.log4j:log4j-to-slf4j:2.17.2'
|
||||
|
||||
// api "org.springframework:spring-context:${springVersion}"
|
||||
// api "org.springframework:spring-webmvc:${springVersion}"
|
||||
|
||||
@@ -1,332 +0,0 @@
|
||||
package com.eactive.ext.djb.ums;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.SecureRandom;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.hc.client5.http.config.RequestConfig;
|
||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
||||
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
||||
import org.apache.hc.core5.util.Timeout;
|
||||
|
||||
import com.eactive.apim.portal.template.entity.MessageCode;
|
||||
import com.eactive.apim.portal.template.entity.MessageRequest;
|
||||
import com.eactive.ext.kjb.common.KjbProperty;
|
||||
import com.eactive.ext.kjb.common.KjbPropertyHolder;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class DjbMessengerService {
|
||||
public final static int[] ALLOW_CHANNELS = { MessageCode.Channels.MESSENGER.getValue() };
|
||||
|
||||
private static final Gson gson = new Gson();
|
||||
|
||||
private static volatile DjbMessengerService instance;
|
||||
|
||||
|
||||
private DjbMessengerService() {
|
||||
// 싱글톤
|
||||
}
|
||||
|
||||
public static DjbMessengerService getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (DjbMessengerService.class) {
|
||||
if (instance == null) {
|
||||
instance = new DjbMessengerService();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private KjbProperty getProperty() {
|
||||
return KjbPropertyHolder.get();
|
||||
}
|
||||
|
||||
private boolean isRealMode() {
|
||||
String url = getProperty().getUmsHostUrl();
|
||||
return url != null && StringUtils.isNotEmpty(url.trim());
|
||||
}
|
||||
|
||||
private CloseableHttpClient createHttpClient() {
|
||||
return HttpClients.createDefault();
|
||||
}
|
||||
|
||||
private RequestConfig createRequestConfig() {
|
||||
KjbProperty prop = getProperty();
|
||||
return RequestConfig.custom()
|
||||
.setConnectTimeout(Timeout.ofSeconds(prop.getUmsConnectionTimeout()))
|
||||
.setResponseTimeout(Timeout.ofSeconds(prop.getUmsResponseTimeout()))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static boolean isAllowChannel(MessageRequest message) {
|
||||
for (int channel : ALLOW_CHANNELS) {
|
||||
if ((message.getMessageCode().getChannels() & channel) == channel) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean send(MessageRequest messageRequest) throws Exception {
|
||||
if (messageRequest == null) {
|
||||
throw new IllegalArgumentException("messageRequest is null");
|
||||
}
|
||||
|
||||
if (MessageCode.Channels.MESSENGER.getValue() != (messageRequest.getMessageCode().getChannels() & MessageCode.Channels.MESSENGER.getValue())) {
|
||||
log.error("지원하지 않는 발송 채널 - {}", messageRequest.getMessageCode().toString());
|
||||
throw new IllegalArgumentException("지원하지 않는 발송 채널 - " + messageRequest.getMessageCode().toString());
|
||||
}
|
||||
|
||||
this.httpConnection(messageRequest);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void httpConnection(MessageRequest messageRequest) throws Exception {
|
||||
|
||||
KjbProperty prop = getProperty();
|
||||
|
||||
URL url = new URL(prop.getSwingUrl());
|
||||
int timeoutValue = 5 * 1000; // 타임아웃 설정을 위한 값 (단위: ms)
|
||||
// Charset charset = Charset.forName("UTF-8");
|
||||
Charset charset = Charset.forName("MS949");
|
||||
HttpURLConnection conn = null;
|
||||
BufferedReader br = null;
|
||||
StringBuffer sb = null;
|
||||
String bodyData = this.makeBodyData(messageRequest);
|
||||
|
||||
String responseData = "";
|
||||
String method = bodyData != "" ? "POST" : "GET";
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod(method); // 전송방식
|
||||
// conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
|
||||
conn.setRequestProperty("Content-Type", "application/json; charset=MS949");
|
||||
conn.setConnectTimeout(timeoutValue); // 연결 타임아웃 설정(5초)
|
||||
conn.setReadTimeout(timeoutValue); // 읽기 타임아웃 설정(5초)
|
||||
conn.setDoOutput(true);
|
||||
|
||||
// POst 방식인 경우에만
|
||||
if (method.equals("POST")) {
|
||||
OutputStream os = conn.getOutputStream();
|
||||
byte requestData[] = bodyData.getBytes(charset);
|
||||
os.write(requestData);
|
||||
os.close();
|
||||
}
|
||||
// System.out.println("getContentType():"t conn.getContentType());
|
||||
// System,out.println("getResponseCode();" t conn.getResponseCode());
|
||||
// System.out.println("getResponseMessage();" + conn.getResponseMessage());
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("getContentType();" + conn.getContentType()); // 응답 콘텐츠 유형 구하기
|
||||
log.debug("getResponsecode();" + conn.getResponseCode()); // 응답 코드 구하기
|
||||
log.debug("getResponseMessage():" + conn.getResponseMessage()); // 응답 메세지 구하기
|
||||
}
|
||||
|
||||
|
||||
// http 요청 후 응답 받은 데이타를 버퍼에 쌓는다
|
||||
if (conn.getResponseCode() >= 200 && conn.getResponseCode() <= 300) {
|
||||
br = new BufferedReader(new InputStreamReader(conn.getInputStream(), charset));
|
||||
} else {
|
||||
br = new BufferedReader(new InputStreamReader(conn.getErrorStream(), charset));
|
||||
}
|
||||
|
||||
String inputLine;
|
||||
sb = new StringBuffer();
|
||||
while ((inputLine = br.readLine()) != null) {
|
||||
sb.append(inputLine);
|
||||
}
|
||||
|
||||
responseData = sb.toString();
|
||||
|
||||
// http 요청 및 응답 완료 후 BufferedReader를 닫는다
|
||||
if (br != null) {
|
||||
br.close();
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String makeBodyData(MessageRequest messageRequest) {
|
||||
|
||||
KjbProperty prop = getProperty();
|
||||
|
||||
// 리턴값
|
||||
String rtnVal = "";
|
||||
|
||||
// 스윙챗 알림 헤더
|
||||
SwingHeadVO swiHeadVO = new SwingHeadVO();
|
||||
|
||||
// 스윙챗 알림 공용
|
||||
SwingCommonVO swiComVO = new SwingCommonVO();
|
||||
|
||||
// 스윙챗 알림 데이터
|
||||
SwingDataVO swiDataVO = new SwingDataVO();
|
||||
|
||||
// 스윙챗 알림 데이터
|
||||
List<SwingReceiverDataVO> swiReDataVOList = new ArrayList<SwingReceiverDataVO>();
|
||||
|
||||
// guID 및 날짜 시간 정보
|
||||
String jsonData[] = this.makeJsonDataInfo();
|
||||
|
||||
// 스윙챗 알림 헤더 설정
|
||||
swiHeadVO.setNxgn_stnd_idfr("JERA");
|
||||
swiHeadVO.setGuid(jsonData[2]);
|
||||
swiHeadVO.setGuid_prgs_no("1");
|
||||
swiHeadVO.setStnd_mesg_ver("R10");
|
||||
swiHeadVO.setOrtr_guid(jsonData[2]);
|
||||
swiHeadVO.setSect_ecrpt_yn("N");
|
||||
swiHeadVO.setFrst_trnm_ipad(prop.getSwingWasIpAddress());
|
||||
swiHeadVO.setFrst_trnm_ipv4_addr(prop.getSwingWasIpAddress());
|
||||
swiHeadVO.setFrst_trnm_mac(prop.getSwingMacIpAddress());
|
||||
swiHeadVO.setFrst_mesg_dman_dt(jsonData[0]);
|
||||
swiHeadVO.setFrst_mesg_dman_time(jsonData[1]);
|
||||
swiHeadVO.setFrst_trnm_sys_dvcd("EBG");
|
||||
swiHeadVO.setTrnm_sys_dvcd("FEP");
|
||||
swiHeadVO.setDman_rspn_dvcd("S");
|
||||
swiHeadVO.setSys_env_dvcd("TODO: 설정값 확인 할것!!!"); //TODO: EgovPropertiesUtils.getOptionalProp("SYS_ENV_DVCD"));
|
||||
swiHeadVO.setTx_tycd("0");
|
||||
swiHeadVO.setSynz_dvcd("S");
|
||||
swiHeadVO.setTx_id("MSGSENDMSG1S");
|
||||
swiHeadVO.setXtis_cd(null);
|
||||
swiHeadVO.setOsdch_dvcd(null);
|
||||
swiHeadVO.setChnl_tycd("FEP");
|
||||
swiHeadVO.setIf_id("F2HMPSHGMSGSENDMSG1S");
|
||||
swiHeadVO.setHmab_dvcd("2");
|
||||
swiHeadVO.setTx_brcd("157");
|
||||
swiHeadVO.setTlrno("ET0001");
|
||||
swiHeadVO.setInsl_brcd("157");
|
||||
swiHeadVO.setBlng_brcd("157");
|
||||
swiHeadVO.setMgmt_brcd("157");
|
||||
swiComVO.setClientld(prop.getSwingClientId());
|
||||
swiComVO.setClientSecret(prop.getSwingClientSecret());
|
||||
swiComVO.setCompanyCode("CB");
|
||||
|
||||
// 랜던값(26)
|
||||
String random26 = this.genrateRandomStringNumber26();
|
||||
swiComVO.setRequestUniqueKey(random26);
|
||||
swiDataVO.setNotiCode("CNO_FEP_HMP_0002");
|
||||
swiDataVO.setNotiTitle("알림");
|
||||
swiDataVO.setNotiContent(messageRequest.getMessage());
|
||||
|
||||
SwingReceiverDataVO receiver = new SwingReceiverDataVO();
|
||||
receiver.setCode(messageRequest.getMessengerId());
|
||||
swiReDataVOList.add(receiver);
|
||||
|
||||
swiDataVO.setReceiverInfo(swiReDataVOList);
|
||||
|
||||
String header = gson.toJson(swiHeadVO);
|
||||
String common = gson.toJson(swiComVO);
|
||||
String data = gson.toJson(swiDataVO);
|
||||
|
||||
// 헤더 + 데이터
|
||||
rtnVal = "{\"HEAD\":" + header + " ,\r\n" + "\"DATA\":\r\n" + " [" + "{\r\n"
|
||||
+ " \"data_dvcd\":\"IO\", \r\n" + " \"BIZ_DATA\":\r\n" + " {\r\n"
|
||||
+ " \"common\":\r\n" + common + ",\r\n" + " \"data\":" + data
|
||||
+ " }\r\n" + " }\r\n" + " ]\r\n" + "}";
|
||||
|
||||
log.debug(rtnVal);
|
||||
|
||||
return rtnVal;
|
||||
}
|
||||
|
||||
private String[] makeJsonDataInfo() {
|
||||
// 리턴값
|
||||
String rtnVal[] = new String[3];
|
||||
|
||||
// 현재시간
|
||||
Date currentDate = new Date();
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
||||
String formattedDate = sdf.format(currentDate);
|
||||
|
||||
rtnVal[0] = formattedDate.substring(0,8);
|
||||
rtnVal[1] = formattedDate.substring(8);
|
||||
|
||||
// 랜던값
|
||||
String random20 = this.genrateRandomStringNumber20();
|
||||
|
||||
rtnVal[2] = formattedDate + "HMP" + random20;
|
||||
|
||||
return rtnVal;
|
||||
}
|
||||
|
||||
|
||||
private String genrateRandomStringNumber20() {
|
||||
String rtnVal= "";
|
||||
|
||||
StringBuilder buffer= new StringBuilder(10);
|
||||
|
||||
// 랜덤값
|
||||
String characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
// 랜덤객체 생성
|
||||
SecureRandom random = new SecureRandom();
|
||||
|
||||
// 반복문
|
||||
for (int i= 0;i< 10;i++) {
|
||||
// 랜덤수
|
||||
int randomIndex = random.nextInt(characters.length());
|
||||
|
||||
// 생성된 랜덤값
|
||||
char randomChar = characters.charAt(randomIndex);
|
||||
|
||||
// 랜덤값 저장
|
||||
buffer.append(randomChar);
|
||||
}
|
||||
|
||||
// 랜덤객체 재생성
|
||||
random = new SecureRandom();
|
||||
|
||||
// 난수 10개 생성
|
||||
int random10 = (int) (Math.pow(10, 9) + random.nextDouble() * Math.pow(10, 9));
|
||||
|
||||
// 문자 숫자 조합(10) + 숫자(10)
|
||||
rtnVal = buffer.toString() + Integer.toString(random10);
|
||||
|
||||
//리턴
|
||||
return rtnVal;
|
||||
}
|
||||
|
||||
private String genrateRandomStringNumber26() {
|
||||
String rtnVal = "";
|
||||
|
||||
// 리턴값
|
||||
StringBuilder buffer = new StringBuilder(26);
|
||||
|
||||
String characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
// 랜덤객체 생성
|
||||
Random random = new Random();
|
||||
|
||||
//반복문
|
||||
for (int i= 0; i < 26; i++) {
|
||||
// 랜덤수
|
||||
int randomIndex = random.nextInt(characters.length());
|
||||
// 생성된 랜덤값
|
||||
char randomChar = characters.charAt(randomIndex);
|
||||
// 랜덤값 저장
|
||||
buffer.append(randomChar);
|
||||
}
|
||||
|
||||
// 문자 숫자 조합(26)
|
||||
rtnVal= buffer.toString();
|
||||
|
||||
// 리턴
|
||||
return rtnVal;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.eactive.ext.djb.ums;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SwingCommonVO {
|
||||
|
||||
/** 클라이업트 D */
|
||||
private String clientld;
|
||||
|
||||
/** 클라이언트 시크릿 */
|
||||
private String clientSecret;
|
||||
|
||||
/** 회사코드 */
|
||||
private String companyCode;
|
||||
|
||||
/** 요청고유키 */
|
||||
private String requestUniqueKey;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.eactive.ext.djb.ums;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SwingDataVO {
|
||||
|
||||
/** 알림코드 */
|
||||
private String notiCode;
|
||||
|
||||
/** 알림제목 */
|
||||
private String notiTitle;
|
||||
|
||||
/** 알림내용 */
|
||||
private String notiContent;
|
||||
|
||||
/** 수신자정보 */
|
||||
private List<SwingReceiverDataVO> receiverInfo;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.eactive.ext.djb.ums;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SwingHeadVO {
|
||||
|
||||
private String nxgn_stnd_idfr;
|
||||
|
||||
private String guid;
|
||||
|
||||
private String guid_prgs_no;
|
||||
|
||||
private String stnd_mesg_ver;
|
||||
|
||||
private String ortr_guid;
|
||||
|
||||
private String sect_ecrpt_yn;
|
||||
|
||||
private String frst_trnm_ipad;
|
||||
|
||||
private String frst_trnm_ipv4_addr;
|
||||
|
||||
private String frst_trnm_mac;
|
||||
|
||||
private String frst_mesg_dman_dt;
|
||||
|
||||
private String frst_mesg_dman_time;
|
||||
|
||||
private String frst_trnm_sys_dvcd;
|
||||
|
||||
private String trnm_sys_dvcd;
|
||||
|
||||
private String dman_rspn_dvcd;
|
||||
|
||||
private String sys_env_dvcd;
|
||||
|
||||
private String tx_tycd;
|
||||
|
||||
private String synz_dvcd;
|
||||
|
||||
private String tx_id;
|
||||
|
||||
private String xtis_cd;
|
||||
|
||||
private String osdch_dvcd;
|
||||
|
||||
private String chnl_tycd;
|
||||
|
||||
private String if_id;
|
||||
|
||||
private String hmab_dvcd;
|
||||
|
||||
private String tx_brcd;
|
||||
|
||||
private String tlrno;
|
||||
|
||||
private String insl_brcd;
|
||||
|
||||
private String blng_brcd;
|
||||
|
||||
private String mgmt_brcd;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.eactive.ext.djb.ums;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SwingReceiverDataVO {
|
||||
|
||||
/** 알림코드 */
|
||||
private String name;
|
||||
|
||||
/** 알림제목 */
|
||||
private String type;
|
||||
|
||||
/** 알림내용 */
|
||||
private String companyCode;
|
||||
|
||||
/** 수신자정보 */
|
||||
private String code;
|
||||
|
||||
/** 상품명 */
|
||||
private String prdNm;
|
||||
}
|
||||
@@ -191,29 +191,6 @@ public class KjbProperty {
|
||||
private Integer apiGwMetricPageSize = 10000;
|
||||
|
||||
|
||||
|
||||
|
||||
// 제주은행 swing chat (messenger)
|
||||
|
||||
@KjbPropertyValue(key = "djb.swing.url", defaultValue = "http://127.0.0.1")
|
||||
private String swingUrl = "";
|
||||
|
||||
@KjbPropertyValue(key = "djb.swing.was_ip_address", defaultValue = "http://127.0.0.1")
|
||||
private String swingWasIpAddress = "";
|
||||
|
||||
@KjbPropertyValue(key = "djb.swing.was_mac_address", defaultValue = "http://127.0.0.1")
|
||||
private String swingMacIpAddress = "";
|
||||
|
||||
@KjbPropertyValue(key = "djb.swing.client_id", defaultValue = "12345")
|
||||
private String swingClientId = "";
|
||||
|
||||
@KjbPropertyValue(key = "djb.swing.client_secret", defaultValue = "12345")
|
||||
private String swingClientSecret = "";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String toJsonString(boolean isPretty) {
|
||||
return isPretty
|
||||
? new GsonBuilder().setPrettyPrinting().create().toJson(this)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.eactive.ext.kjb.ums;
|
||||
|
||||
import com.eactive.apim.portal.common.util.PhoneNumberUtil;
|
||||
import com.eactive.apim.portal.template.entity.MessageCode;
|
||||
import com.eactive.apim.portal.template.entity.MessageRequest;
|
||||
import com.eactive.ext.kjb.common.KjbProperty;
|
||||
@@ -128,7 +129,7 @@ public class KjbUmsService {
|
||||
.messageIdentityNo(guid)
|
||||
.msgBizWorkCode(bizWorkCode.getCode())
|
||||
.content(content)
|
||||
.cellphone(cpno)
|
||||
.cellphone(PhoneNumberUtil.digitsOnly(cpno))
|
||||
.msgSndChnlCd(UmsRequestPayload.ChannelCode.KM)
|
||||
.build();
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.eactive.ext.kjb.ums.test;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class KjbEmailSendModuleTests {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
// KjbProperty prop = new KjbProperty();
|
||||
// prop.setEaiBatchUrl(null);
|
||||
// prop.setEaiBatchSendDir("D:\\kjb-logs\\sendmail\\snd");
|
||||
// prop.setEaiBatchBackupDir("D:\\kjb-logs\\sendmail\\bak");
|
||||
// prop.setEaiBatchInterfaceId("UAGFF00001UIE");
|
||||
//
|
||||
// EmailSendModule service = EmailSendModule.getInstance(prop, null);
|
||||
// MessageRequest messageRequest = new MessageRequest();
|
||||
// messageRequest.setId(UUID.randomUUID().toString());
|
||||
// messageRequest.setEmail("dearmai@dearmai.net");
|
||||
// messageRequest.setUsername("김광은");
|
||||
// messageRequest.setSubject("제목 - test");
|
||||
//
|
||||
// messageRequest.setMessageCode(MessageCode.USER_ACCOUNT_LOCKED);
|
||||
//// messageRequest.setMessage("내용 - test");
|
||||
//
|
||||
//
|
||||
// CompletableFuture<Boolean> future = service.sendEmail(messageRequest, (result, ex) -> {
|
||||
// if (ex != null) {
|
||||
// log.error("failed", ex);
|
||||
// } else {
|
||||
// log.info("result: {}", result);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// future.join();
|
||||
|
||||
log.info("done");
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.eactive.ext.kjb.ums.test;
|
||||
|
||||
import com.eactive.ext.kjb.common.KjbProperty;
|
||||
import com.eactive.ext.kjb.utils.ValidationUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Slf4j
|
||||
public class KjbPropertyTest {
|
||||
|
||||
@Test
|
||||
void testKjbProperty() {
|
||||
Assumptions.assumeTrue(
|
||||
"true".equalsIgnoreCase(System.getenv("KJB_EAPIM_TEST_ENABLED")),
|
||||
"OS 환경변수 내 KJB_EAPIM_TEST_ENABLED=TRUE 설정되어 있어야 동작함");
|
||||
|
||||
|
||||
log.info("KjbProperty 테스트 시작");
|
||||
|
||||
|
||||
log.info("기본값 Validation 테스트");
|
||||
KjbProperty prop = new KjbProperty();
|
||||
ValidationUtil.validateOrThrow(prop);
|
||||
|
||||
log.info("KjbProperty 테스트 완료");
|
||||
}
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
package com.eactive.ext.kjb.ums.test;
|
||||
|
||||
import com.eactive.apim.portal.template.entity.MessageCode;
|
||||
import com.eactive.apim.portal.template.entity.MessageRequest;
|
||||
import com.eactive.ext.kjb.common.KjbEaiBatchException;
|
||||
import com.eactive.ext.kjb.common.KjbProperty;
|
||||
import com.eactive.ext.kjb.common.KjbPropertyHolder;
|
||||
import com.eactive.ext.kjb.common.KjbUmsException;
|
||||
import com.eactive.ext.kjb.ums.KjbEmailSendModule;
|
||||
import com.eactive.ext.kjb.ums.KjbUmsService;
|
||||
import com.eactive.ext.kjb.utils.OsUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class UmsTest {
|
||||
private static KjbProperty prop = null;
|
||||
|
||||
@BeforeAll
|
||||
public static void init() {
|
||||
prop = new KjbProperty();
|
||||
prop.setEaiBatchUrl("http://172.31.32.111:10230/BATAppWeb/EaiBatCall");
|
||||
prop.setUmsEaiBatchInterfaceId("UIEFF00001UAG");
|
||||
|
||||
prop.setUmsHostUrl("http://172.31.35.144:9021");
|
||||
prop.setUmsApiKey("7cca6d58-e4f7-474d-9edd-525806bc99ff");
|
||||
|
||||
if (OsUtil.isWindows()) {
|
||||
prop.setEaiBatchUrl("");
|
||||
prop.setUmsHostUrl("");
|
||||
prop.setUmsEaiBatchSendDir("c:\\kjb-logs\\sendmail\\snd");
|
||||
prop.setUmsEaiBatchBackupDir("c:\\kjb-logs\\sendmail\\bak");
|
||||
prop.setUmsEaiBatchErrorDir("c:\\kjb-logs\\sendmail\\error");
|
||||
}
|
||||
|
||||
if (OsUtil.isLinux()) {
|
||||
prop.setUmsEaiBatchSendDir("/Data/eapim/portal/sendmail/snd");
|
||||
prop.setUmsEaiBatchBackupDir("/Data/eapim/portal/sendmail/bak");
|
||||
prop.setUmsEaiBatchErrorDir("/Data/eapim/portal/sendmail/error");
|
||||
}
|
||||
|
||||
KjbPropertyHolder.setForTest(prop);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSms() {
|
||||
Assumptions.assumeTrue(
|
||||
"true".equalsIgnoreCase(System.getenv("KJB_EAPIM_TEST_ENABLED")),
|
||||
"OS 환경변수 내 KJB_EAPIM_TEST_ENABLED=TRUE 설정되어 있어야 동작함");
|
||||
|
||||
MessageRequest messageRequest = new MessageRequest();
|
||||
messageRequest.setId(UUID.randomUUID().toString());
|
||||
messageRequest.setMessageCode(MessageCode.USER_VERIFICATION_MOBILEPHONE);
|
||||
messageRequest.setPhone("01099750188");
|
||||
messageRequest.setEmail("dearmai@dearmai.net");
|
||||
messageRequest.setUsername("김광은");
|
||||
messageRequest.setSubject("제목 - test");
|
||||
messageRequest.setMessage("{\"ATHN_NO\"; \"369369\"}");
|
||||
|
||||
KjbUmsService umsService = KjbUmsService.getInstance();
|
||||
try {
|
||||
boolean result = umsService.send(messageRequest);
|
||||
|
||||
} catch (KjbUmsException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
Assertions.fail(e);
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("done");
|
||||
}
|
||||
|
||||
/**
|
||||
* :eapim-admin-kjb:test --tests "com.eactive.ext.kjb.ums.test.UmsTest.testEmail"
|
||||
*/
|
||||
@Test
|
||||
public void testEmail() {
|
||||
Assumptions.assumeTrue(
|
||||
"true".equalsIgnoreCase(System.getenv("KJB_EAPIM_TEST_ENABLED")),
|
||||
"OS 환경변수 내 KJB_EAPIM_TEST_ENABLED=TRUE 설정되어 있어야 동작함");
|
||||
|
||||
|
||||
System.getProperties().keySet().forEach(key -> {
|
||||
log.info("{}: {}", key, System.getProperty((String) key));
|
||||
});
|
||||
|
||||
KjbEmailSendModule service = KjbEmailSendModule.getInstance();
|
||||
|
||||
List<MessageRequest> requestList = new ArrayList<>();
|
||||
|
||||
|
||||
log.info("#1 요청 생성 - 이메일 인증");
|
||||
requestList.add(createMessageRequest(MessageCode.USER_VERIFICATION_EMAIL, "{\"ATHN_NO\": \"543216\"}"));
|
||||
|
||||
log.info("#2 요청 생성 - 비밀번호 초기화");
|
||||
requestList.add(createMessageRequest(MessageCode.USER_PASSWORD_RESET, "{\"ATHN_NO\": \"new-password\"}"));
|
||||
|
||||
log.info("#3 요청 생성 - 비밀번호 변경 완료");
|
||||
requestList.add(createMessageRequest(MessageCode.USER_PASSWORD_CHANGED, ""));
|
||||
|
||||
log.info("#4 요청 생성 - 로그인 제한");
|
||||
requestList.add(createMessageRequest(MessageCode.USER_ACCOUNT_LOCKED, "{\"RJCT_RSN\": \"reason\"}"));
|
||||
|
||||
log.info("#5 요청 생성 - 이메일 초대");
|
||||
requestList.add(createMessageRequest(MessageCode.USER_INVITATION,
|
||||
"{\"CRPT_NM\":\"corpName\",\"MNGR_NM\":\"managerName\",\"CUST_ID\":\"loginId\",\"RCMD_CD\":\"321654\",\"URL_ADDR\":\"https://www.naver.com/\"}"));
|
||||
|
||||
log.info("#6 요청 생성 - 이메일 초대 취소");
|
||||
requestList.add(createMessageRequest(MessageCode.USER_INVITATION_CANCELED,
|
||||
"{\"CRPT_NM\":\"corpName\",\"MNGR_NM\":\"managerName\"}"));
|
||||
|
||||
log.info("#7 요청 생성 - 법인관리자 및 법인 등록 승인");
|
||||
requestList.add(createMessageRequest(MessageCode.MANAGER_WITH_ORG_REGISTER_APPROVED, ""));
|
||||
|
||||
log.info("#8 요청 생성 - 법인관리자 및 법인 등록 거절");
|
||||
requestList.add(createMessageRequest(MessageCode.MANAGER_WITH_ORG_REGISTER_REJECTED, "{\"RJCT_RSN\": \"reason\"}"));
|
||||
|
||||
log.info("#9 요청 생성 - 앱 승인");
|
||||
requestList.add(createMessageRequest(MessageCode.APP_REGISTER_APPROVED, "{\"APP_IDNT_NM\": \"appName\"}"));
|
||||
|
||||
log.info("#10 요청 생성 - 앱 승인 거절");
|
||||
requestList.add(createMessageRequest(MessageCode.APP_REGISTER_REJECTED, "{\"RJCT_RSN\": \"reason\"}"));
|
||||
|
||||
|
||||
|
||||
try {
|
||||
for (int i = 0; i < requestList.size(); i++) {
|
||||
MessageRequest request = requestList.get(i);
|
||||
log.info("#{} - 메일 전송 시도 - {}", i + 1, request.getServiceId());
|
||||
service.sendEmail(request);
|
||||
}
|
||||
} catch (KjbEaiBatchException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
log.info("done");
|
||||
}
|
||||
|
||||
private MessageRequest createMessageRequest(MessageCode messageCode, String message) {
|
||||
MessageRequest messageRequest = new MessageRequest();
|
||||
messageRequest.setId(UUID.randomUUID().toString());
|
||||
messageRequest.setMessageCode(messageCode);
|
||||
messageRequest.setEmail(System.getenv().getOrDefault("KJB_TEST_EMAIL", "25W0064@kjbank.com"));
|
||||
messageRequest.setUmsUid(UUID.randomUUID().toString());
|
||||
messageRequest.setUsername("김광은");
|
||||
messageRequest.setSubject("제목 - test");
|
||||
messageRequest.setMessage(message);
|
||||
// messageRequest.setServiceId(serviceId);
|
||||
|
||||
log.info("MessageRequest - {}", messageRequest);
|
||||
|
||||
return messageRequest;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="5 seconds">
|
||||
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<!-- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>-->
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %magenta([%thread]) %highlight([%-3level]) %logger - %msg %n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="com.eactive.eai.custom.kjb" level="DEBUG" additivity="false">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</logger>
|
||||
<logger name="com.eactive.ext.kjb" level="DEBUG" additivity="false">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</logger>
|
||||
<logger name="org.apache.hc" level="DEBUG" additivity="false" />
|
||||
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user