From 46e6cfa0453b11d8c2c4b225f931fcbe90a9a286 Mon Sep 17 00:00:00 2001 From: arlen02-01 Date: Mon, 26 Jan 2026 22:57:59 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[UPLUS-125]=20feat=20:=20=EB=A9=94=EC=84=B8?= =?UTF-8?q?=EC=A7=80=20=EB=A1=9C=EA=B7=B8=20=EC=95=94=ED=98=B8=ED=99=94?= =?UTF-8?q?=EB=90=9C=20=EB=B2=88=ED=98=B8/=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EB=B3=B5=ED=98=B8=ED=99=94=20=EB=B0=8F=20=EB=A7=88=EC=8A=A4?= =?UTF-8?q?=ED=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/MessageLogDetailResponse.java | 6 +++- .../service/MessageLogService.java | 29 ++++++++++++++++++- src/main/resources/application.yml | 6 +++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/project/notification/controller/dto/response/MessageLogDetailResponse.java b/src/main/java/com/project/notification/controller/dto/response/MessageLogDetailResponse.java index 619a0ee..0bd5b51 100644 --- a/src/main/java/com/project/notification/controller/dto/response/MessageLogDetailResponse.java +++ b/src/main/java/com/project/notification/controller/dto/response/MessageLogDetailResponse.java @@ -25,6 +25,10 @@ public record TemplateSnapshot( String groupId, String groupName, Channel channel, int version) {} public static MessageLogDetailResponse from(MessageLog log) { + return from(log, log.getRecipientEnc()); + } + + public static MessageLogDetailResponse from(MessageLog log, String recipientMasked) { // 템플릿 정보가 있을 경우에만 Snapshot 생성 TemplateSnapshot snapshot = null; TemplateVersion templateVersion = log.getTemplateVersion(); @@ -42,7 +46,7 @@ public static MessageLogDetailResponse from(MessageLog log) { log.getId(), log.getTraceId(), log.getSubscription().getSubId(), - log.getRecipientEnc(), + recipientMasked, (templateVersion != null) ? templateVersion.getId() : null, log.getChannel(), log.getStatus(), diff --git a/src/main/java/com/project/notification/service/MessageLogService.java b/src/main/java/com/project/notification/service/MessageLogService.java index 578e7ed..35f3eb6 100644 --- a/src/main/java/com/project/notification/service/MessageLogService.java +++ b/src/main/java/com/project/notification/service/MessageLogService.java @@ -7,6 +7,8 @@ import com.project.global.exception.ApplicationException; import com.project.global.exception.code.domain.core.CoreErrorCode; +import com.project.global.util.AesUtil; +import com.project.core.controller.dto.response.MaskingUtil; import com.project.notification.controller.dto.request.MessageLogSearchRequest; import com.project.notification.controller.dto.response.MessageLogDetailResponse; import com.project.notification.controller.dto.response.MessageLogResponse; @@ -21,6 +23,7 @@ public class MessageLogService { private final MessageLogRepository messageLogRepository; + private final AesUtil aesUtil; /** 로그 목록 검색 */ public Slice searchLogs( @@ -35,6 +38,30 @@ public MessageLogDetailResponse getLogDetail(Long logId) { .findDetailById(logId) .orElseThrow(() -> new ApplicationException(CoreErrorCode.LOG_NOT_FOUND)); - return MessageLogDetailResponse.from(log); + String decryptedRecipient = safeDecrypt(log.getRecipientEnc()); + String maskedRecipient = maskRecipient(decryptedRecipient); + + return MessageLogDetailResponse.from(log, maskedRecipient); + } + + private String safeDecrypt(String encrypted) { + if (encrypted == null) { + return null; + } + try { + return aesUtil.decrypt(encrypted); + } catch (Exception e) { + return encrypted; + } + } + + private String maskRecipient(String recipient) { + if (recipient == null || recipient.isBlank()) { + return recipient; + } + if (recipient.contains("@")) { + return MaskingUtil.maskEmail(recipient); + } + return MaskingUtil.maskPhone(recipient); } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 7be2722..29bdc1a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -85,4 +85,8 @@ logging: org.springframework.web: INFO org.hibernate.SQL: WARN pattern: - level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]" \ No newline at end of file + level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]" + +debug: + crypto: + enabled: true From 322345b1829be847d025ba9db78449f8799944ae Mon Sep 17 00:00:00 2001 From: arlen02-01 Date: Mon, 26 Jan 2026 23:04:52 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[UPLUS-125]=20fix:ai=EB=A6=AC=EB=B7=B0=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/project/notification/service/MessageLogService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/project/notification/service/MessageLogService.java b/src/main/java/com/project/notification/service/MessageLogService.java index 35f3eb6..f338874 100644 --- a/src/main/java/com/project/notification/service/MessageLogService.java +++ b/src/main/java/com/project/notification/service/MessageLogService.java @@ -7,6 +7,7 @@ import com.project.global.exception.ApplicationException; import com.project.global.exception.code.domain.core.CoreErrorCode; +import com.project.global.exception.core.OperationFailedException; import com.project.global.util.AesUtil; import com.project.core.controller.dto.response.MaskingUtil; import com.project.notification.controller.dto.request.MessageLogSearchRequest; @@ -16,10 +17,12 @@ import com.project.notification.infra.repository.MessageLogRepository; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; @Service @RequiredArgsConstructor @Transactional(readOnly = true) +@Slf4j public class MessageLogService { private final MessageLogRepository messageLogRepository; @@ -50,7 +53,8 @@ private String safeDecrypt(String encrypted) { } try { return aesUtil.decrypt(encrypted); - } catch (Exception e) { + } catch (OperationFailedException e) { + log.warn("Failed to decrypt recipient. value: {}", encrypted, e); return encrypted; } } From b6e5ac0550800219a093e1b5a5fd969b4fda2f78 Mon Sep 17 00:00:00 2001 From: arlen02-01 Date: Mon, 26 Jan 2026 23:06:52 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[UPLUS-125]=20fix:ai=EB=A6=AC=EB=B7=B0=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/project/notification/service/MessageLogService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/project/notification/service/MessageLogService.java b/src/main/java/com/project/notification/service/MessageLogService.java index f338874..81ebb24 100644 --- a/src/main/java/com/project/notification/service/MessageLogService.java +++ b/src/main/java/com/project/notification/service/MessageLogService.java @@ -5,11 +5,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.project.core.controller.dto.response.MaskingUtil; import com.project.global.exception.ApplicationException; import com.project.global.exception.code.domain.core.CoreErrorCode; import com.project.global.exception.core.OperationFailedException; import com.project.global.util.AesUtil; -import com.project.core.controller.dto.response.MaskingUtil; import com.project.notification.controller.dto.request.MessageLogSearchRequest; import com.project.notification.controller.dto.response.MessageLogDetailResponse; import com.project.notification.controller.dto.response.MessageLogResponse;