ums 연동 대응

This commit is contained in:
Rinjae
2025-10-17 19:28:09 +09:00
parent 604d7975f6
commit 423af16926
7 changed files with 159 additions and 94 deletions
@@ -0,0 +1,19 @@
package com.eactive.eai.custom.kjb.spring;
import com.eactive.ext.kjb.safedb.KjbSafedbWrapper;
import org.springframework.security.crypto.password.PasswordEncoder;
public class KjbSafedbPasswordEncoder implements PasswordEncoder {
@Override
public String encode(CharSequence rawPassword) {
KjbSafedbWrapper safedb = KjbSafedbWrapper.getInstance();
return safedb.encryptPassword(rawPassword.toString());
}
@Override
public boolean matches(CharSequence rawPassword, String encodedPassword) {
KjbSafedbWrapper safedb = KjbSafedbWrapper.getInstance();
String encoded = safedb.encryptPassword(rawPassword.toString());
return encoded.equals(encodedPassword);
}
}
@@ -1,85 +0,0 @@
package com.eactive.eai.custom.kjb.ums;
import com.eactive.apim.portal.template.entity.MessageRequest;
import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.data.entity.man.monitoringProperty.service.MonitoringPropertyService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.json.simple.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.nio.file.Path;
import java.nio.file.Paths;
@Service
@Transactional(transactionManager = "transactionManagerForEMS")
@Slf4j
public class KjbUmsService extends BaseService {
public static final String PROP_GORUP_ID = "Monitoring";
public static final String PROP_EAI_BATCH_URL = "kjb.ums.eai_batch.url";
public static final String PROP_EAI_BATCH_SEND_DIR = "kjb.ums.eai_batch.send_dir";
private final MonitoringPropertyService monitoringPropertyService;
private final String EAI_BATCH_URL;
private final String EAI_BATCH_SEND_DIR;
private KjbUmsService(MonitoringPropertyService monitoringPropertyService) {
this.monitoringPropertyService = monitoringPropertyService;
// 파라미터 검사
this.EAI_BATCH_URL = monitoringPropertyService.getPropertyValue(PROP_GORUP_ID, PROP_EAI_BATCH_URL, "");
this.EAI_BATCH_SEND_DIR = monitoringPropertyService.getPropertyValue(PROP_GORUP_ID, PROP_EAI_BATCH_SEND_DIR, "/Data/eapim/portal/sendmail");
if (EAI_BATCH_URL.isEmpty()) {
log.warn("{} 가 설정되지 않음. 실제 EAI 배치 연동 없이 동작함", PROP_EAI_BATCH_URL);
}
log.info("EAI Batch URL: {}", EAI_BATCH_URL);
log.info("EAI Batch Send Dir: {}", EAI_BATCH_SEND_DIR);
// 디렉토리 검사(쓰기 권한 포함)
Path sendDirPath = Paths.get(EAI_BATCH_SEND_DIR);
if (!sendDirPath.toFile().exists()) {
// 생성 시도
boolean created = sendDirPath.toFile().mkdirs();
if (!created) {
log.error("EAI_BATCH_SEND_DIR 디렉토리를 생성할 수 없음: {}", EAI_BATCH_SEND_DIR);
throw new IllegalStateException("EAI_BATCH_SEND_DIR 디렉토리를 생성할 수 없음: " + EAI_BATCH_SEND_DIR);
}
}
if (!sendDirPath.toFile().isDirectory()) {
log.error("EAI_BATCH_SEND_DIR 가 디렉토리가 아님: {}", EAI_BATCH_SEND_DIR);
throw new IllegalStateException("EAI_BATCH_SEND_DIR 가 디렉토리가 아님: " + EAI_BATCH_SEND_DIR);
}
if (!sendDirPath.toFile().canWrite()) {
log.error("EAI_BATCH_SEND_DIR 에 쓰기 권한이 없음: {}", EAI_BATCH_SEND_DIR);
throw new IllegalStateException("EAI_BATCH_SEND_DIR 에 쓰기 권한이 없음: " + EAI_BATCH_SEND_DIR);
}
}
public void sendEmail(MessageRequest messageRequest) {
log.debug("sendEmail() called - EAI_BATCH_URL: {}, EAI_BATCH_SEND_DIR: {}", EAI_BATCH_URL, EAI_BATCH_SEND_DIR);
log.debug("MessageRequest ID: {}, Email: {}", messageRequest.getId(), messageRequest.getEmail());
if (StringUtils.isEmpty(messageRequest.getId())) {
log.warn("MessageRequest ID is empty");
throw new IllegalArgumentException("MessageRequest ID is required");
}
String filename = "EMAIL_" + messageRequest.getId() + ".json";
JSONObject jsonObject = new JSONObject();
jsonObject.put("to", messageRequest.getEmail());
}
}