Skip to content

Commit

Permalink
Merge pull request kruize#1479 from khansaad/no-auth-fix
Browse files Browse the repository at this point in the history
Fix issue with Datasource in case of No-Auth config
  • Loading branch information
dinogun authored Jan 31, 2025
2 parents c1d7be3 + 4d53a4a commit 1118621
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/com/autotune/database/helper/DBHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -1124,18 +1124,22 @@ public static List<DataSourceInfo> convertKruizeDataSourceToDataSourceObject(Lis
try {
DataSourceInfo dataSourceInfo;
AuthenticationConfig authConfig = null;
JSONObject authJson = null;
if (kruizeDataSource.getKruizeAuthenticationEntry() != null) {
try {
JsonNode credentialsNode = kruizeDataSource.getKruizeAuthenticationEntry().getCredentials();
String authType = kruizeDataSource.getKruizeAuthenticationEntry().getAuthenticationType();
// Parse the JsonNode credentials into a JSONObject
JSONObject credentialsJson = new JSONObject(credentialsNode.toString());
JSONObject authJson = new JSONObject()
.put(KruizeConstants.AuthenticationConstants.AUTHENTICATION_TYPE, authType)
.put(KruizeConstants.AuthenticationConstants.AUTHENTICATION_CREDENTIALS, credentialsJson);
if (!credentialsNode.toString().equalsIgnoreCase(AnalyzerConstants.NULL)) {
JSONObject credentialsJson = new JSONObject(credentialsNode.toString());
authJson = new JSONObject()
.put(KruizeConstants.AuthenticationConstants.AUTHENTICATION_TYPE, authType)
.put(KruizeConstants.AuthenticationConstants.AUTHENTICATION_CREDENTIALS, credentialsJson);
}
authConfig = AuthenticationConfig.createAuthenticationConfigObject(authJson);
} catch (Exception e) {
LOGGER.debug("GSON failed to convert the DB Json object in convertKruizeDataSourceToDataSourceObject");
e.printStackTrace();
LOGGER.error("GSON failed to convert the DB Json object in convertKruizeDataSourceToDataSourceObject");
}
}
if (kruizeDataSource.getServiceName().isEmpty() && null != kruizeDataSource.getUrl()) {
Expand Down

0 comments on commit 1118621

Please sign in to comment.