RED-5293: fixed jdbcUrl-check by adding more checks

This commit is contained in:
Ali Oezyetimoglu 2022-11-10 14:23:31 +01:00
parent 39a0eb4f8d
commit 197162b61b

View File

@ -135,9 +135,16 @@ public class TenantManagementService {
private void validateJdbcUrl(String jdbcUrl) {
// just create a URI object to check if the string is a valid URI
new URI(jdbcUrl);
// same as above but with a URL object
// // same as above but with a URL object
try {
new URL(jdbcUrl);
String startExpr = "jdbc:postgresql://";
if (!jdbcUrl.startsWith("")) {
throw new IllegalArgumentException("Your jdbcUrl is not URL conform.");
}
String afterStartExpr = jdbcUrl.substring(jdbcUrl.indexOf("//")).substring(2);
new URL(jdbcUrl.substring(jdbcUrl.indexOf(afterStartExpr)));
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Your jdbcUrl is not URL conform.", e);
}