This commit is contained in:
@@ -73,7 +73,8 @@ public class MainController implements InterceptorSkipController {
|
||||
private final LoginService loginService;
|
||||
private final MonitoringPropertyService monitoringPropertyService;
|
||||
private final UserLoginHistoryService userLoginHistoryService;
|
||||
|
||||
private final SmsAuthService smsAuthService;
|
||||
|
||||
@Autowired
|
||||
public MainController(LocaleMessage localeMessage,
|
||||
MonitoringContext monitoringContext,
|
||||
@@ -82,7 +83,8 @@ public class MainController implements InterceptorSkipController {
|
||||
UserRoleService userRoleService,
|
||||
UserServiceTypeService userServiceTypeService,
|
||||
MonitoringPropertyService monitoringPropertyService,
|
||||
UserLoginHistoryService userLoginHistoryService) {
|
||||
UserLoginHistoryService userLoginHistoryService,
|
||||
SmsAuthService smsAuthService) {
|
||||
this.localeMessage = localeMessage;
|
||||
this.monitoringContext = monitoringContext;
|
||||
this.userInfoService = userInfoService;
|
||||
@@ -91,6 +93,7 @@ public class MainController implements InterceptorSkipController {
|
||||
this.userServiceTypeService = userServiceTypeService;
|
||||
this.monitoringPropertyService = monitoringPropertyService;
|
||||
this.userLoginHistoryService = userLoginHistoryService;
|
||||
this.smsAuthService = smsAuthService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/loginForm.do")
|
||||
@@ -264,16 +267,8 @@ public class MainController implements InterceptorSkipController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SmsAuthService 인스턴스 조회 (singleton)
|
||||
*/
|
||||
private SmsAuthService getSmsAuthService() {
|
||||
try {
|
||||
return SmsAuthService.getInstance();
|
||||
} catch (Exception e) {
|
||||
logger.warn("SmsAuthService 초기화 실패 - SMS 인증 비활성화 처리", e);
|
||||
return null;
|
||||
}
|
||||
return smsAuthService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.eactive.eai.rms.ext.djb.ums.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.eactive.apim.portal.template.entity.MessageCode;
|
||||
import com.eactive.apim.portal.template.service.MessageEventHandler;
|
||||
import com.eactive.apim.portal.template.service.MessageRecipient;
|
||||
import com.eactive.apim.portal.template.service.MessageSendEvent;
|
||||
|
||||
@Component
|
||||
public class AdminVerificationMobilePhoneEventHandler implements MessageEventHandler {
|
||||
|
||||
@Override
|
||||
public MessageCode getKey() {
|
||||
return MessageCode.ADMIN_VERIFICATION_MOBILEPHONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowAdditionalRecipients() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "관리자포탈 휴대폰 인증번호 발송";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "<div>사용 가능 변수: </div><br/>"
|
||||
+ "<div> - userName 수신자 이름 </div><br/>"
|
||||
+ "<div> - authNumber 인증번호 </div><br/>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageSendEvent createEvent(Object source, MessageRecipient recipient, Map<String, Object> params) {
|
||||
Map<String, String> eventParams = new HashMap<>();
|
||||
String authNumber = (String) params.get("authNumber");
|
||||
eventParams.put("authNumber", authNumber);
|
||||
eventParams.put("AUTH_CODE", authNumber);
|
||||
eventParams.put("userName", (String) params.get("userName"));
|
||||
return new MessageSendEvent(source, MessageCode.ADMIN_VERIFICATION_MOBILEPHONE, recipient, eventParams);
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,15 @@ import javax.servlet.http.HttpSession;
|
||||
public class SmsAuthController implements InterceptorSkipController {
|
||||
|
||||
private final MainController mainController;
|
||||
private final SmsAuthService smsAuthService;
|
||||
|
||||
public SmsAuthController(MainController mainController) {
|
||||
public SmsAuthController(MainController mainController, SmsAuthService smsAuthService) {
|
||||
this.mainController = mainController;
|
||||
this.smsAuthService = smsAuthService;
|
||||
}
|
||||
|
||||
private SmsAuthService getSmsAuthService() {
|
||||
return SmsAuthService.getInstance();
|
||||
return smsAuthService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.HashMap;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.eactive.apim.portal.template.entity.MessageCode;
|
||||
import com.eactive.apim.portal.user.entity.UserInfo;
|
||||
@@ -19,11 +19,13 @@ import com.eactive.ext.kjb.common.KjbPropertyHolder;
|
||||
import com.eactive.ext.kjb.common.KjbUmsException;
|
||||
import com.eactive.ext.kjb.ums.KjbUmsService;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SmsAuthService {
|
||||
private static volatile SmsAuthService instance;
|
||||
|
||||
// 세션 키
|
||||
public static final String SESSION_KEY_AUTH_CODE = "SMS_AUTH_CODE";
|
||||
@@ -41,24 +43,8 @@ public class SmsAuthService {
|
||||
public static final String MODE_FIXED = "fixed";
|
||||
|
||||
private final SecureRandom random = new SecureRandom();
|
||||
|
||||
@Autowired
|
||||
private UmsManager ums;
|
||||
|
||||
private SmsAuthService() {
|
||||
// 싱글톤
|
||||
}
|
||||
|
||||
public static SmsAuthService getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (SmsAuthService.class) {
|
||||
if (instance == null) {
|
||||
instance = new SmsAuthService();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
private final UmsManager ums;
|
||||
|
||||
private static KjbProperty getProperty() {
|
||||
return KjbPropertyHolder.get();
|
||||
@@ -124,22 +110,11 @@ public class SmsAuthService {
|
||||
*/
|
||||
public boolean sendAuthCode(UserInfo userInfo, String authCode) {
|
||||
try {
|
||||
// String cleanedPhone = phone.replaceAll("[^0-9]", "").trim();
|
||||
// String guid = String.format("EAPIM_EMS-%s",
|
||||
// DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now()));
|
||||
//
|
||||
// JsonObject content = GsonUtil.toJsonObject(VerifyPhoneUmsTemplate.builder().authNumber(authCode).build());
|
||||
//
|
||||
// getUmsService().sendKakaoAlimTalk(guid, UmsBizWorkCode.VERIFY_PHONE, cleanedPhone, content);
|
||||
// log.info("SMS 인증번호 발송 완료 - guid: {}, phone: {}****{}",
|
||||
// guid, cleanedPhone.substring(0, 3), cleanedPhone.substring(cleanedPhone.length() - 4));
|
||||
// log.debug("SMS 인증번호 발송 - authCode: {}", authCode);
|
||||
|
||||
HashMap<String,Object> params = new HashMap<String, Object>();
|
||||
params.put("authNumber", authCode);
|
||||
params.put("userName", userInfo.getUsername());
|
||||
|
||||
ums.send(userInfo, MessageCode.ADMIN_VERIFICATION_MOBILEPHONE, params);
|
||||
log.debug("\n\n\nDDDDDDDDD" + userInfo.toString());
|
||||
ums.send(userInfo, MessageCode.ADMIN_VERIFICATION_MOBILEPHONE, params);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("SMS 인증번호 발송 실패", e);
|
||||
@@ -295,11 +270,4 @@ public class SmsAuthService {
|
||||
public boolean isEnabled() {
|
||||
return getProperty().isSmsAuthEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* 테스트용 인스턴스 리셋
|
||||
*/
|
||||
public static void resetForTest() {
|
||||
instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user