RED-5293: fixed jdbcUrl-check by adding more checks; removed URL-check because it does not work
This commit is contained in:
parent
27dcd61e3e
commit
6b63468148
@ -1,8 +1,6 @@
|
||||
package com.iqser.red.service.peristence.v1.server.service;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.util.List;
|
||||
@ -133,22 +131,14 @@ public class TenantManagementService {
|
||||
|
||||
@SneakyThrows
|
||||
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
|
||||
try {
|
||||
String startExpr = "jdbc:postgresql://";
|
||||
if (!jdbcUrl.startsWith(startExpr)) {
|
||||
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);
|
||||
String startExpr = "jdbc:postgresql://";
|
||||
if (!jdbcUrl.startsWith(startExpr)) {
|
||||
throw new IllegalArgumentException("Your jdbcUrl is not URL conform.");
|
||||
}
|
||||
|
||||
// just create a URI object to check if the string is a valid URI
|
||||
new URI(jdbcUrl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user