Merge remote-tracking branch 'origin/jenkins_with_weblogic' of C:/eactive/workspaces/eapim-git/bundles/251002/elink-portal-common_incremental_2025-09-12.bundle into jenkins_with_weblogic
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.eactive.apim.portal.common.entity;
|
||||
|
||||
import com.eactive.eai.data.converter.LocalDateTimeToStringConverter14;
|
||||
import kjb.safedb.KjbNotRnnoJpaAttributeConverter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
@@ -33,6 +34,7 @@ public abstract class Auditable {
|
||||
* 최초등록자ID
|
||||
*/
|
||||
@Column(name = "created_by")
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@CreatedBy
|
||||
private String createdBy;
|
||||
|
||||
@@ -48,6 +50,7 @@ public abstract class Auditable {
|
||||
* 최종수정자ID
|
||||
*/
|
||||
@Column(name = "LAST_MODIFIED_BY")
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
@LastModifiedBy
|
||||
private String lastModifiedBy;
|
||||
|
||||
|
||||
@@ -1,35 +1,60 @@
|
||||
package com.eactive.apim.portal.portalorg.entity;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.tuple.ValueGenerator;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.tuple.ValueGenerator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class OrgCodeGenerator implements ValueGenerator<String> {
|
||||
private static final Logger log = LoggerFactory.getLogger(OrgCodeGenerator.class);
|
||||
private static final String TABLE_NAME = "PTL_ID";
|
||||
private static final String SELECT_SQL =
|
||||
"SELECT NEXT_ID FROM " + TABLE_NAME +
|
||||
" WHERE TABLE_NAME = 'PTL_ORG' FOR UPDATE";
|
||||
private static final String UPDATE_SQL =
|
||||
"UPDATE " + TABLE_NAME +
|
||||
" SET NEXT_ID = ? WHERE TABLE_NAME = 'PTL_ORG'";
|
||||
|
||||
private static final String CHECK_EXISTS_SQL =
|
||||
"SELECT COUNT(*) FROM " + TABLE_NAME +
|
||||
" WHERE TABLE_NAME = 'PTL_ORG'";
|
||||
|
||||
private static final String INSERT_SQL =
|
||||
"INSERT INTO " + TABLE_NAME +
|
||||
" (TABLE_NAME, NEXT_ID) VALUES ('PTL_ORG', ?)";
|
||||
private final String CHECK_EXISTS_SQL;
|
||||
private final String INSERT_SQL;
|
||||
private final String SELECT_SQL;
|
||||
private final String UPDATE_SQL;
|
||||
private static final long INITIAL_VALUE = 1000000000L;
|
||||
|
||||
|
||||
private OrgCodeGenerator() {
|
||||
// private static final String SELECT_SQL =
|
||||
// "SELECT NEXT_ID FROM " + TABLE_NAME +
|
||||
// " WHERE TABLE_NAME = 'PTL_ORG' FOR UPDATE";
|
||||
// private static final String UPDATE_SQL =
|
||||
// "UPDATE " + TABLE_NAME +
|
||||
// " SET NEXT_ID = ? WHERE TABLE_NAME = 'PTL_ORG'";
|
||||
//
|
||||
// private static final String CHECK_EXISTS_SQL =
|
||||
// "SELECT COUNT(*) FROM " + TABLE_NAME +
|
||||
// " WHERE TABLE_NAME = 'PTL_ORG'";
|
||||
//
|
||||
// private static final String INSERT_SQL =
|
||||
// "INSERT INTO " + TABLE_NAME +
|
||||
// " (TABLE_NAME, NEXT_ID) VALUES ('PTL_ORG', ?)";
|
||||
// private static final long INITIAL_VALUE = 1000000000L;
|
||||
|
||||
|
||||
String schema = System.getProperty("eai.tableowner", "");
|
||||
|
||||
if (schema.isEmpty()) {
|
||||
log.error("ems.schema is empty.");
|
||||
throw new IllegalStateException("System property 'eai.tableowner' is not set. Please configure 'eai.tableowner' or 'ems.datasource.schema'(developer portal).");
|
||||
}
|
||||
|
||||
String TABLE_NAME_WITH_SCHEMA = System.getProperty("ems.schema", "") + "." + TABLE_NAME;
|
||||
|
||||
this.CHECK_EXISTS_SQL = "SELECT COUNT(*) FROM " + TABLE_NAME_WITH_SCHEMA + " WHERE TABLE_NAME = 'PTL_ORG'";
|
||||
this.INSERT_SQL = "INSERT INTO " + TABLE_NAME_WITH_SCHEMA + " (TABLE_NAME, NEXT_ID) VALUES ('PTL_ORG', ?)";
|
||||
this.SELECT_SQL = "SELECT NEXT_ID FROM " + TABLE_NAME_WITH_SCHEMA + " WHERE TABLE_NAME = 'PTL_ORG' FOR UPDATE";
|
||||
this.UPDATE_SQL = "UPDATE " + TABLE_NAME_WITH_SCHEMA + " SET NEXT_ID = ? WHERE TABLE_NAME = 'PTL_ORG'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateValue(Session session, Object owner) {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.eactive.apim.portal.portaluser.entity;
|
||||
|
||||
import com.eactive.eai.data.converter.LocalDateTimeToStringConverter14;
|
||||
import kjb.safedb.KjbNotRnnoJpaAttributeConverter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -14,6 +15,7 @@ public class TwoFactorAuth {
|
||||
|
||||
@Id
|
||||
@Column(name = "recipient", length = 255)
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
private String recipient;
|
||||
|
||||
@Column(name = "auth_number", length = 255)
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package com.eactive.apim.portal.template.service;
|
||||
|
||||
import kjb.safedb.KjbNotRnnoJpaAttributeConverter;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.Convert;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MessageRecipient {
|
||||
|
||||
private String username;
|
||||
private String userId; //email
|
||||
private String phone;
|
||||
|
||||
@@ -10,6 +10,8 @@ import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.TableGenerator;
|
||||
|
||||
import kjb.safedb.KjbNotRnnoJpaAttributeConverter;
|
||||
import lombok.Data;
|
||||
|
||||
@TableGenerator(
|
||||
@@ -30,6 +32,7 @@ public class UserLog {
|
||||
private Long logId;
|
||||
|
||||
@Column(name = "login_id", nullable = false)
|
||||
@Convert(converter = KjbNotRnnoJpaAttributeConverter.class)
|
||||
private String loginId;
|
||||
|
||||
@Column(name = "login_time")
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
package kjb.safedb;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
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
|
||||
@@ -21,7 +23,7 @@ public class KjbNotRnnoJpaAttributeConverter implements AttributeConverter<Strin
|
||||
*/
|
||||
@Override
|
||||
public String convertToDatabaseColumn(String attribute) {
|
||||
log.debug("DB 암호화 #1 - {} / {}", attribute, SafeDBColumns.NOT_RNNO);
|
||||
// log.debug("DB 암호화 #1 - {} / {}", attribute, SafeDBColumns.NOT_RNNO);
|
||||
|
||||
String originalAttribute = attribute;
|
||||
if (StringUtils.isNotEmpty(attribute)) {
|
||||
@@ -29,7 +31,7 @@ public class KjbNotRnnoJpaAttributeConverter implements AttributeConverter<Strin
|
||||
attribute = wrapper.encryptNotRnnoString(attribute);
|
||||
}
|
||||
|
||||
log.debug("DB 암호화 #2 : {} -> {}", originalAttribute, attribute);
|
||||
// log.debug("DB 암호화 #2 : {} -> {}", originalAttribute, attribute);
|
||||
|
||||
return attribute;
|
||||
}
|
||||
@@ -42,19 +44,27 @@ public class KjbNotRnnoJpaAttributeConverter implements AttributeConverter<Strin
|
||||
*/
|
||||
@Override
|
||||
public String convertToEntityAttribute(String dbData) {
|
||||
log.debug("DB 복호화 #1 - {} / {}", dbData, SafeDBColumns.NOT_RNNO);
|
||||
// log.debug("DB 복호화 #1 - {} / {}", dbData, SafeDBColumns.NOT_RNNO);
|
||||
|
||||
String dbDataOriginal = dbData;
|
||||
if (StringUtils.isNotEmpty(dbData)) {
|
||||
if (this.isEncrypted(dbData)) {
|
||||
KjbSafedbWrapper safeDBWrapper = KjbSafedbWrapper.getInstance();
|
||||
dbData = safeDBWrapper.decryptNotRnno(dbData);
|
||||
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);
|
||||
// log.debug("DB 복호화 #2 : {} -> {}", dbDataOriginal, dbData);
|
||||
|
||||
return dbData;
|
||||
}
|
||||
@@ -77,10 +87,16 @@ public class KjbNotRnnoJpaAttributeConverter implements AttributeConverter<Strin
|
||||
data = data.trim();
|
||||
|
||||
// Base64 형식 체크
|
||||
if (Utils.isBase64(data)) {
|
||||
return true;
|
||||
if (!Utils.isBase64(data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
// Base64 길이 체크 (4의 배수)
|
||||
if (data.length() % 4 != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user