fix: preserve quoted DDS end user identity
This commit is contained in:
@@ -85,7 +85,7 @@ public class DdsQueryService {
|
|||||||
var search = searchText == null ? "" : searchText.trim();
|
var search = searchText == null ? "" : searchText.trim();
|
||||||
var timeoutSeconds = timeoutSeconds(properties.queryTimeout());
|
var timeoutSeconds = timeoutSeconds(properties.queryTimeout());
|
||||||
var connectionProperties = new Properties();
|
var connectionProperties = new Properties();
|
||||||
connectionProperties.setProperty("user", user.username());
|
connectionProperties.setProperty("user", jdbcUsername(user.username()));
|
||||||
connectionProperties.setProperty("password", user.password());
|
connectionProperties.setProperty("password", user.password());
|
||||||
connectionProperties.setProperty("oracle.net.CONNECT_TIMEOUT", String.valueOf(timeoutSeconds * 1000));
|
connectionProperties.setProperty("oracle.net.CONNECT_TIMEOUT", String.valueOf(timeoutSeconds * 1000));
|
||||||
connectionProperties.setProperty("oracle.jdbc.ReadTimeout", String.valueOf(timeoutSeconds * 1000));
|
connectionProperties.setProperty("oracle.jdbc.ReadTimeout", String.valueOf(timeoutSeconds * 1000));
|
||||||
@@ -168,6 +168,19 @@ public class DdsQueryService {
|
|||||||
return normalized;
|
return normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String jdbcUsername(String username) {
|
||||||
|
var normalized = username == null ? "" : username.trim();
|
||||||
|
if (normalized.length() >= 2 && normalized.startsWith("\"") && normalized.endsWith("\"")) {
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
// The standalone SQL creates quoted lower-case END USER names. Oracle's
|
||||||
|
// JDBC driver uppercases an unquoted username, so preserve that identity.
|
||||||
|
if (!normalized.isEmpty() && normalized.equals(normalized.toLowerCase(Locale.ROOT))) {
|
||||||
|
return "\"" + normalized.replace("\"", "\"\"") + "\"";
|
||||||
|
}
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
private static int timeoutSeconds(Duration duration) {
|
private static int timeoutSeconds(Duration duration) {
|
||||||
return Math.max(1, (int) Math.ceil(duration.toMillis() / 1000.0));
|
return Math.max(1, (int) Math.ceil(duration.toMillis() / 1000.0));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user