Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| de262cec7b | |||
| 09013156dc | |||
| 2e77ce373e | |||
| c959549b99 | |||
| a974065fef | |||
| a23f0f73f3 | |||
| f26210b71a | |||
| 284b843e30 |
@@ -114,6 +114,8 @@ dependencies {
|
||||
api group: 'commons-io', name: 'commons-io', version: '2.11.0'
|
||||
|
||||
|
||||
compileOnly files('libs/damo-manager.jar')
|
||||
|
||||
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
|
||||
testImplementation 'ch.qos.logback:logback-classic:1.2.10'
|
||||
|
||||
Binary file not shown.
@@ -16,6 +16,7 @@ import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
@@ -23,6 +24,7 @@ import org.hibernate.annotations.LazyCollectionOption;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "ptl_credential")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.eactive.apim.portal.common.entity;
|
||||
|
||||
import com.eactive.apim.portal.jpa.PersonalDataEncryptConverter;
|
||||
import com.eactive.eai.data.converter.LocalDateTimeToStringConverter14;
|
||||
import kjb.safedb.KjbNotRnnoJpaAttributeConverter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
@@ -34,7 +34,7 @@ public abstract class Auditable {
|
||||
* 최초등록자ID
|
||||
*/
|
||||
@Column(name = "created_by")
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@Convert(converter = PersonalDataEncryptConverter.class)
|
||||
@CreatedBy
|
||||
private String createdBy;
|
||||
|
||||
@@ -50,7 +50,7 @@ public abstract class Auditable {
|
||||
* 최종수정자ID
|
||||
*/
|
||||
@Column(name = "LAST_MODIFIED_BY")
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@Convert(converter = PersonalDataEncryptConverter.class)
|
||||
@LastModifiedBy
|
||||
private String lastModifiedBy;
|
||||
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.eactive.apim.portal.jpa;
|
||||
|
||||
import com.eactive.ext.djb.DamoManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
@Slf4j
|
||||
@Converter
|
||||
public class PersonalDataEncryptConverter implements AttributeConverter<String, String> {
|
||||
|
||||
|
||||
/**
|
||||
* 암호화
|
||||
* @param attribute the entity attribute value to be converted
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String convertToDatabaseColumn(String attribute) {
|
||||
String originalAttribute = attribute;
|
||||
if (StringUtils.isNotEmpty(attribute)) {
|
||||
attribute = DamoManager.getInstance().encrypt(attribute);
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
// originalAttribute 홀수 글자 마스킹
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < originalAttribute.length(); i++) {
|
||||
if (i % 2 == 0) {
|
||||
sb.append(originalAttribute.charAt(i));
|
||||
} else {
|
||||
sb.append("*");
|
||||
}
|
||||
}
|
||||
|
||||
originalAttribute = sb.toString();
|
||||
log.debug("DB 암호화 : {} -> {}", originalAttribute, attribute);
|
||||
}
|
||||
}
|
||||
|
||||
return attribute;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 복호화
|
||||
* @param dbData the data from the database column to be
|
||||
* converted
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String convertToEntityAttribute(String dbData) {
|
||||
|
||||
String dbDataOriginal = dbData;
|
||||
if (StringUtils.isNotEmpty(dbData)) {
|
||||
if (this.isEncrypted(dbData)) {
|
||||
try {
|
||||
dbData = DamoManager.getInstance().decrypt(dbData);
|
||||
} catch (Exception e) {
|
||||
// 복호화 실패시 원본 반환
|
||||
String logData = dbData.length() <= 3 ? dbData : dbData.substring(0, 3) + "...";
|
||||
log.warn("DB 복호화 실패: 복호화하지 않고 원본 반환. dbData={} (Length : {})", logData, dbData.length());
|
||||
return dbData;
|
||||
}
|
||||
} else {
|
||||
log.debug("DB 복호화 경고: Base64 형식이 아님. 복호화하지 않고 원본 반환. dbData={}", dbData);
|
||||
}
|
||||
}
|
||||
|
||||
log.debug("DB 복호화 : {} -> {}", dbDataOriginal, dbData);
|
||||
|
||||
return dbData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 현재 damo-manager 가 bypass 모드(무변환)인지 여부.
|
||||
* bypass 면 {@code encrypt}/{@code decrypt} 가 원문을 그대로 반환하므로 암호화/정규화가 no-op 이 된다.
|
||||
* 레거시 평문 일괄 암호화 같은 마이그레이션 작업은 이 경우 의미가 없으므로 호출 측에서 차단해야 한다.
|
||||
*/
|
||||
public boolean isBypassMode() {
|
||||
return DamoManager.getInstance().isBypassMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* 암호화 여부 확인(base64 인코딩 여부로 판단, 또는 0-9, - 로 구성된 경우 암호화 되지 않은 걸로 판단(연락처))
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
private boolean isEncrypted(String data) {
|
||||
if (StringUtils.isEmpty(data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 숫자, - 로만 구성된 경우 암호화 되지 않은 걸로 판단 (ex: 연락처)
|
||||
if (data.matches("^[0-9-]+$")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data = data.trim();
|
||||
|
||||
// Base64 형식 체크
|
||||
if (!data.matches("^[A-Za-z0-9+/]+={0,2}$")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Base64 길이 체크 (4의 배수)
|
||||
if (data.length() % 4 != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.eactive.apim.portal.portaluser.entity;
|
||||
|
||||
import com.eactive.apim.portal.common.entity.Auditable;
|
||||
import com.eactive.apim.portal.portalorg.entity.PortalOrg;
|
||||
import com.eactive.apim.portal.jpa.PersonalDataEncryptConverter;import com.eactive.apim.portal.portalorg.entity.PortalOrg;
|
||||
import com.eactive.apim.portal.portaluser.entity.PortalUserEnums.ApprovalStatus;
|
||||
import com.eactive.apim.portal.portaluser.entity.PortalUserEnums.RoleCode;
|
||||
import com.eactive.apim.portal.portaluser.entity.PortalUserEnums.UserStatus;
|
||||
import java.io.Serializable;
|
||||
|
||||
import kjb.safedb.KjbNotRnnoJpaAttributeConverter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.annotations.Comment;
|
||||
@@ -22,7 +21,7 @@ import java.time.LocalDateTime;
|
||||
@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true)
|
||||
|
||||
@Entity
|
||||
@Table(name = "ptl_user")
|
||||
@Table(name = "PTL_USER")
|
||||
public class PortalUser extends Auditable implements Serializable, com.eactive.eai.data.Data {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -34,7 +33,7 @@ public class PortalUser extends Auditable implements Serializable, com.eactive.e
|
||||
|
||||
@Column(name = "login_id", length = 200, nullable = false)
|
||||
@Comment("로그인ID")
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@Convert(converter = PersonalDataEncryptConverter.class)
|
||||
private String loginId;
|
||||
|
||||
@Column(name = "password_hash", length = 60)
|
||||
@@ -47,17 +46,17 @@ public class PortalUser extends Auditable implements Serializable, com.eactive.e
|
||||
|
||||
@Column(name = "phone_number", length = 50)
|
||||
@Comment("전화번호")
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@Convert(converter = PersonalDataEncryptConverter.class)
|
||||
private String phoneNumber;
|
||||
|
||||
@Column(name = "mobile_number", length = 50)
|
||||
@Comment("휴대폰 번호")
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@Convert(converter = PersonalDataEncryptConverter.class)
|
||||
private String mobileNumber;
|
||||
|
||||
@Column(name = "email_addr", length = 200)
|
||||
@Comment("이메일주소")
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@Convert(converter = PersonalDataEncryptConverter.class)
|
||||
private String emailAddr;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.eactive.apim.portal.portaluser.entity;
|
||||
|
||||
import com.eactive.apim.portal.jpa.PersonalDataEncryptConverter;
|
||||
import com.eactive.eai.data.converter.LocalDateTimeToStringConverter14;
|
||||
import kjb.safedb.KjbNotRnnoJpaAttributeConverter;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.*;
|
||||
@@ -25,7 +25,7 @@ public class TwoFactorAuth {
|
||||
private String id;
|
||||
|
||||
@Column(name = "recipient", length = 255)
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@Convert(converter = PersonalDataEncryptConverter.class)
|
||||
private String recipient;
|
||||
|
||||
@Column(name = "auth_number", length = 255)
|
||||
|
||||
@@ -36,5 +36,12 @@ public interface PortalUserRepository extends BaseRepository<PortalUser, String>
|
||||
long countByPortalOrg(PortalOrg portalOrg);
|
||||
|
||||
Optional<PortalUser> findByUserName(String userName);
|
||||
|
||||
// 암복
|
||||
@Query(
|
||||
value = "select * from ${ems.datasource.schema}.ptl_user where email_addr = :emailAddr",
|
||||
nativeQuery = true
|
||||
)
|
||||
Optional<PortalUser> findByEmailAddrRaw(@Param("emailAddr") String emailAddr);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ public class Inquiry extends Auditable {
|
||||
|
||||
/**
|
||||
* 문의 상태 (예: 대기중, 답변 완료 등)
|
||||
* @DjbInquiryStatus 참조
|
||||
*/
|
||||
@Column(name = "INQUIRY_STATUS", length = 32)
|
||||
private String inquiryStatus;
|
||||
|
||||
@@ -25,7 +25,6 @@ public enum MessageCode {
|
||||
MANAGER_WITH_ORG_REGISTER_APPROVED("법인관리자 및 법인 등록 승인", "FM_APIM007", Channels.EMAIL),
|
||||
MANAGER_WITH_ORG_REGISTER_REJECTED("법인관리자 및 법인 등록 거절", "FM_APIM008", Channels.EMAIL),
|
||||
|
||||
|
||||
// 관리자 영역
|
||||
APP_REGISTER_APPROVED("앱 등록 승인", "FM_APIM009", Channels.EMAIL),
|
||||
APP_REGISTER_REJECTED("앱 등록 거절", "FM_APIM010", Channels.EMAIL),
|
||||
@@ -34,11 +33,9 @@ public enum MessageCode {
|
||||
INQUIRY_CREATED("Q&A 등록 알림", null, Channels.NONE),
|
||||
INQUIRY_COMMENT_CREATED("Q&A 댓글 등록 알림", null, Channels.NONE),
|
||||
|
||||
|
||||
// API상태 모니터링
|
||||
API_STATUS_CHANGED("API 상태 변화", "FM_APIM011", Channels.MESSENGER),
|
||||
// 유량제어 토큰 획득 실패
|
||||
INFLOW_TOKEN_FAILED("유량제어 토큰 획득 실패", "FM_APIM012", Channels.MESSENGER),
|
||||
// 제주은행
|
||||
API_STATUS_CHANGED("API 상태 변화", "FM_APIM011", Channels.SWING),
|
||||
INFLOW_TOKEN_FAILED("유량제어 토큰 획득 실패", "FM_APIM012", Channels.SWING),
|
||||
|
||||
|
||||
// 미 사용, 미 분류
|
||||
@@ -122,7 +119,7 @@ public enum MessageCode {
|
||||
NONE (0b0000),
|
||||
EMAIL (0b0001),
|
||||
KAKAO_ALIMTALK (0b0010),
|
||||
MESSENGER (0b0100),
|
||||
SWING (0b0100),
|
||||
;
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.eactive.apim.portal.template.entity;
|
||||
|
||||
|
||||
import com.eactive.apim.portal.jpa.PersonalDataEncryptConverter;
|
||||
import com.eactive.apim.portal.portaluser.entity.PortalUser;
|
||||
import com.eactive.eai.data.converter.LocalDateTimeToStringConverter14;
|
||||
import kjb.safedb.KjbNotRnnoJpaAttributeConverter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
@@ -53,10 +53,10 @@ public class MessageRequest implements Serializable {
|
||||
|
||||
private String username;
|
||||
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@Convert(converter = PersonalDataEncryptConverter.class)
|
||||
private String email;
|
||||
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@Convert(converter = PersonalDataEncryptConverter.class)
|
||||
private String phone;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@@ -66,7 +66,7 @@ public class MessageRequest implements Serializable {
|
||||
private PortalUser user;
|
||||
|
||||
@Comment("UMS 연계용 UID")
|
||||
@Column(name="ums_uid", length = 16)
|
||||
@Column(name="ums_uid", length = 36)
|
||||
private String umsUid;
|
||||
|
||||
@Column(name = "messenger_id")
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MessageSendService {
|
||||
processSingleRecipient(user, template.get(), messageParams);
|
||||
}
|
||||
} else {
|
||||
log.warn("메세지 템플릿이 존재 하지 않음 - {}", messageCode);
|
||||
log.error("메세지 템플릿이 존재 하지 않음 - {}", messageCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class MessageSendService {
|
||||
String subject = buildMessage(template.getSubjectTemplate(), messageParams);
|
||||
|
||||
if (template.getEnableSms().equalsIgnoreCase("Y")) {
|
||||
String smsEaiInterfaceId = portalProperties.get("message.integration.eaiId.sms");
|
||||
String smsEaiInterfaceId = portalProperties.get("ums.sms.if_id");
|
||||
MessageRequest smsRequest = new MessageRequest();
|
||||
smsRequest.setMessageCode(MessageCode.valueOf(template.getMessageCode().toUpperCase()));
|
||||
smsRequest.setSubject(subject);
|
||||
@@ -88,14 +88,14 @@ public class MessageSendService {
|
||||
smsRequest.setUsername(user.getUsername());
|
||||
smsRequest.setPhone(user.getPhone());
|
||||
smsRequest.setEaiInterfaceId(smsEaiInterfaceId);
|
||||
smsRequest.setServiceId(portalProperties.get("message.integration.template.sms." + template.getMessageCode()));
|
||||
smsRequest.setMessageType("KAKAO");
|
||||
smsRequest.setServiceId(portalProperties.get("ums.sms.tx_id"));
|
||||
smsRequest.setMessageType("SMS");
|
||||
messageRequestRepository.save(smsRequest);
|
||||
logger.debug(smsRequest.toString());
|
||||
}
|
||||
|
||||
if (template.getEnableEmail().equalsIgnoreCase("Y")) {
|
||||
String mailEaiInterfaceId = portalProperties.get("message.integration.eaiId.email");
|
||||
String mailEaiInterfaceId = portalProperties.get("ums.email.if_id");
|
||||
MessageRequest emailRequest = new MessageRequest();
|
||||
emailRequest.setMessageCode(MessageCode.valueOf(template.getMessageCode().toUpperCase()));
|
||||
emailRequest.setSubject(subject);
|
||||
@@ -105,13 +105,14 @@ public class MessageSendService {
|
||||
emailRequest.setUsername(user.getUsername());
|
||||
emailRequest.setEmail(user.getUserId());
|
||||
emailRequest.setEaiInterfaceId(mailEaiInterfaceId);
|
||||
emailRequest.setServiceId(portalProperties.get("message.integration.template.email." + template.getMessageCode()));
|
||||
emailRequest.setServiceId(portalProperties.get("ums.email.tx_id"));
|
||||
emailRequest.setMessageType("EMAIL");
|
||||
messageRequestRepository.save(emailRequest);
|
||||
logger.debug(emailRequest.toString());
|
||||
}
|
||||
|
||||
if (template.getEnableMessenger().equalsIgnoreCase("Y")) {
|
||||
String swingEaiInterfaceId = portalProperties.get("ums.messenger.if_id");
|
||||
MessageRequest messengerRequest = new MessageRequest();
|
||||
messengerRequest.setMessageCode(MessageCode.valueOf(template.getMessageCode()));
|
||||
messengerRequest.setSubject(subject);
|
||||
@@ -120,7 +121,11 @@ public class MessageSendService {
|
||||
messengerRequest.setRequestDate(LocalDateTime.now());
|
||||
messengerRequest.setUsername(user.getUsername());
|
||||
messengerRequest.setMessengerId(user.getUserId());
|
||||
messengerRequest.setEaiInterfaceId(swingEaiInterfaceId);
|
||||
messengerRequest.setServiceId(portalProperties.get("ums.messenger.tx_id"));
|
||||
messengerRequest.setMessageType("MESSENGER");
|
||||
messageRequestRepository.save(messengerRequest);
|
||||
logger.debug(messengerRequest.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
package com.eactive.apim.portal.user.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.eactive.apim.portal.jpa.PersonalDataEncryptConverter;
|
||||
import com.eactive.eai.data.converter.LocalDateTimeToStringConverter14;
|
||||
import com.eactive.eai.data.converter.StringTrimConverter;
|
||||
import com.eactive.eai.data.entity.AbstractEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
|
||||
import com.eactive.eai.data.converter.LocalDateTimeToStringConverter14;
|
||||
import com.eactive.eai.data.converter.StringTrimConverter;
|
||||
import com.eactive.eai.data.entity.AbstractEntity;
|
||||
import kjb.safedb.KjbNotRnnoJpaAttributeConverter;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true)
|
||||
@@ -54,7 +46,7 @@ public class UserInfo extends AbstractEntity<String> implements Serializable {
|
||||
|
||||
@Column(length = 40)
|
||||
@Comment("휴대폰 번호")
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@Convert(converter = PersonalDataEncryptConverter.class)
|
||||
private String cphnno;
|
||||
|
||||
@Column(length = 40)
|
||||
@@ -63,7 +55,7 @@ public class UserInfo extends AbstractEntity<String> implements Serializable {
|
||||
|
||||
@Column(length = 100)
|
||||
@Comment("이메일 주소")
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@Convert(converter = PersonalDataEncryptConverter.class)
|
||||
private String emad;
|
||||
|
||||
@Column(length = 3)
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
package com.eactive.apim.portal.user.entity;
|
||||
|
||||
import com.eactive.apim.portal.jpa.PersonalDataEncryptConverter;
|
||||
import com.eactive.eai.data.converter.LocalDateTimeToStringConverter14;
|
||||
import java.time.LocalDateTime;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.TableGenerator;
|
||||
|
||||
import kjb.safedb.KjbNotRnnoJpaAttributeConverter;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableGenerator(
|
||||
name = "USER_LOGIN_LOG_GEN",
|
||||
table = "PTL_ID",
|
||||
@@ -32,7 +25,7 @@ public class UserLog {
|
||||
private Long logId;
|
||||
|
||||
@Column(name = "login_id", nullable = false)
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@Convert(converter = PersonalDataEncryptConverter.class)
|
||||
private String loginId;
|
||||
|
||||
@Column(name = "login_time")
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
package kjb.safedb;
|
||||
|
||||
//import com.eactive.ext.kjb.safedb.KjbSafedbWrapper;
|
||||
//import com.eactive.ext.kjb.safedb.SafeDBColumns;
|
||||
//import com.eactive.ext.kjb.safedb.Utils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
@Converter
|
||||
@Slf4j
|
||||
public class KjbNotRnnoJpaAttributeConverter implements AttributeConverter<String, String> {
|
||||
private static final Logger needFixLogger = LoggerFactory.getLogger("eapim.portal.needfix");
|
||||
|
||||
/**
|
||||
* 암호화
|
||||
* @param attribute the entity attribute value to be converted
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String convertToDatabaseColumn(String attribute) {
|
||||
// log.debug("DB 암호화 #1 - {} / {}", attribute, SafeDBColumns.NOT_RNNO);
|
||||
|
||||
// String originalAttribute = attribute;
|
||||
// if (StringUtils.isNotEmpty(attribute)) {
|
||||
// KjbSafedbWrapper wrapper = KjbSafedbWrapper.getInstance();
|
||||
// attribute = wrapper.encryptNotRnnoString(attribute);
|
||||
//
|
||||
// if (log.isDebugEnabled()) {
|
||||
// // originalAttribute 홀수 글자 마스킹
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// for (int i = 0; i < originalAttribute.length(); i++) {
|
||||
// if (i % 2 == 0) {
|
||||
// sb.append(originalAttribute.charAt(i));
|
||||
// } else {
|
||||
// sb.append("*");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// originalAttribute = sb.toString();
|
||||
// log.debug("DB 암호화 #2 : {} -> {}", originalAttribute, attribute);
|
||||
// }
|
||||
// }
|
||||
|
||||
return attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* 복호화
|
||||
* @param dbData the data from the database column to be
|
||||
* converted
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String convertToEntityAttribute(String dbData) {
|
||||
// log.debug("DB 복호화 #1 - {} / {}", dbData, SafeDBColumns.NOT_RNNO);
|
||||
|
||||
// String dbDataOriginal = dbData;
|
||||
// if (StringUtils.isNotEmpty(dbData)) {
|
||||
// if (this.isEncrypted(dbData)) {
|
||||
// KjbSafedbWrapper safeDBWrapper = KjbSafedbWrapper.getInstance();
|
||||
// try {
|
||||
// dbData = safeDBWrapper.decryptNotRnno(dbData);
|
||||
// } catch (Exception e) {
|
||||
// // 복호화 실패시 원본 반환
|
||||
// String logData = dbData.length() <= 3 ? dbData : dbData.substring(0, 3) + "...";
|
||||
// log.warn("DB 복호화 실패: 복호화하지 않고 원본 반환. dbData={} (Length : {})", logData, dbData.length());
|
||||
// needFixLogger.warn("DB 복호화 실패: 복호화하지 않고 원본 반환. dbData={} (Length : {})", logData, dbData.length(), e);
|
||||
// return dbData;
|
||||
// }
|
||||
// } else {
|
||||
// log.debug("DB 복호화 경고: Base64 형식이 아님. 복호화하지 않고 원본 반환. dbData={}", dbData);
|
||||
// }
|
||||
// }
|
||||
|
||||
// log.debug("DB 복호화 #2 : {} -> {}", dbDataOriginal, dbData);
|
||||
|
||||
return dbData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 암호화 여부 확인(base64 인코딩 여부로 판단, 또는 0-9, - 로 구성된 경우 암호화 되지 않은 걸로 판단(연락처))
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
private boolean isEncrypted(String data) {
|
||||
// if (StringUtils.isEmpty(data)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // 숫자, - 로만 구성된 경우 암호화 되지 않은 걸로 판단 (ex: 연락처)
|
||||
// if (data.matches("^[0-9-]+$")) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// data = data.trim();
|
||||
//
|
||||
// // Base64 형식 체크
|
||||
// if (!Utils.isBase64(data)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // Base64 길이 체크 (4의 배수)
|
||||
// if (data.length() % 4 != 0) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user