feat: add dedicated DDS permission backoffice instance

This commit is contained in:
devmrko
2026-06-29 21:19:48 +09:00
parent 6cf75dc42b
commit c4968a0313
22 changed files with 1128 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
package com.cloudhandson.ddsbackoffice.config;
import java.time.Duration;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.regex.Pattern;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "dds")
public record DdsProperties(
String dbUrl,
Duration queryTimeout,
String pgObject,
String myObject,
Map<String, User> users
) {
private static final Pattern OBJECT_NAME = Pattern.compile(
"[A-Za-z][A-Za-z0-9_$#]*(\\.[A-Za-z][A-Za-z0-9_$#]*)*"
);
public DdsProperties {
dbUrl = dbUrl == null ? "" : dbUrl.trim();
queryTimeout = queryTimeout == null ? Duration.ofSeconds(10) : queryTimeout;
pgObject = normalizeObject(pgObject, "ADMIN.V_DDS_CUSTOMERS_PG");
myObject = normalizeObject(myObject, "ADMIN.V_DDS_CUSTOMERS_MY");
var normalizedUsers = new LinkedHashMap<String, User>();
if (users != null) {
users.forEach((key, value) -> {
if (key != null && value != null) {
normalizedUsers.put(key.trim().toLowerCase(), value);
}
});
}
users = Map.copyOf(normalizedUsers);
}
public String objectFor(String sourceKey) {
if ("PG".equalsIgnoreCase(sourceKey)) {
return pgObject;
}
if ("MY".equalsIgnoreCase(sourceKey)) {
return myObject;
}
throw new IllegalArgumentException("지원하지 않는 DDS 데이터 소스입니다.");
}
private static String normalizeObject(String value, String fallback) {
var candidate = value == null || value.isBlank() ? fallback : value.trim();
if (!OBJECT_NAME.matcher(candidate).matches()) {
throw new IllegalArgumentException("DDS 보호 객체 이름은 스키마.객체 형식이어야 합니다.");
}
return candidate.toUpperCase();
}
public record User(String label, String description, String username, String password) {
public boolean configured() {
return username != null && !username.isBlank()
&& password != null && !password.isBlank();
}
}
}