Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
import org.springframework.format.annotation.DateTimeFormat;

Expand Down Expand Up @@ -45,7 +46,12 @@ public class Datasource {

private String username;

@JsonIgnore
/**
* Password field is only writable (input only).
* It will not be returned in API responses for security reasons,
* but can be received from API requests.
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String password;

@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ public String buildConnectionUrl(Datasource datasource) {
return datasource.getConnectionUrl();
}
// Oracle JDBC URL format: jdbc:oracle:thin:@host:port/serviceName
// databaseName may contain "serviceName|schemaName" format, extract serviceName part
String databaseName = datasource.getDatabaseName();
String serviceName = databaseName;
if (databaseName != null && databaseName.contains("|")) {
serviceName = databaseName.split("\\|")[0];
}
return String.format("jdbc:oracle:thin:@%s:%d/%s", datasource.getHost(), datasource.getPort(),
datasource.getDatabaseName());
serviceName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ public boolean testConnection(Integer id) {
* Actual connection test method
*/
private boolean realConnectionTest(Datasource datasource) {
// Validate password is not empty
if (datasource.getPassword() == null || datasource.getPassword().trim().isEmpty()) {
log.error("Password is empty for datasource: {}", datasource.getName());
return false;
}

// Convert Datasource to DbConfig
DbConfigBO config = new DbConfigBO();
DatasourceTypeHandler handler = datasourceTypeHandlerRegistry.getRequired(datasource.getType());
Expand Down
Loading