Skip to content

Commit

Permalink
Merge branch 'devel' into dbeaver/pro#1978-sso-sign-out
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-rider authored Oct 24, 2023
2 parents 4fa3394 + 9979363 commit 4a9579f
Show file tree
Hide file tree
Showing 63 changed files with 828 additions and 384 deletions.
8 changes: 7 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///*": "${workspaceFolder}/../*"
}
},
"skipFiles": [
"<node_internals>/**",
"**/node_modules/**",
"${workspaceFolder}/webapp/**/node_modules/**/*.js",
"${workspaceFolder}/webapp/**/dist/**/*.js"
]
},
{
"type": "java",
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ You can see live demo of CloudBeaver here: https://demo.cloudbeaver.io

## Changelog

### CloudBeaver 23.2.3 - 2023-10-23

- The SSL option is available for establishing a connection in SQL Server;
- Added the ability to edit binary values in a table;
- Different bug fixes and enhancements have been made.

### CloudBeaver 23.2.2 - 2023-10-09

- The 'Save credentials' checkbox has been removed from a template creating form as credentials are not stored in templates;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public RMController getResourceController() {
return resourceController;
}

@NotNull
@Override
public RMProject getRMProject() {
return project;
}

@Override
public boolean isVirtual() {
return true;
Expand Down
4 changes: 3 additions & 1 deletion server/bundles/io.cloudbeaver.server/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<extension point="org.jkiss.dbeaver.ws.event.handler">
<eventHandler class="io.cloudbeaver.server.events.WSDefaultEventHandler">
<topic id="cb_config"/>
<topic id="cb_workspace_configuration"/>
</eventHandler>
<eventHandler class="io.cloudbeaver.server.events.WSDataSourceUpdatedEventHandlerImpl">
<topic id="cb_datasource"/>
Expand All @@ -73,6 +72,9 @@
<eventHandler class="io.cloudbeaver.server.events.WSLogEventHandler">
<topic id="cb_session_log"/>
</eventHandler>
<eventHandler class="io.cloudbeaver.server.events.WSEventHandlerWorkspaceConfigUpdate">
<topic id="cb_workspace_configuration"/>
</eventHandler>
<eventHandler class="io.cloudbeaver.server.events.WSDeleteTempFileHandler">
<topic id="cb_delete_temp_folder"/>
</eventHandler>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,21 +325,21 @@ protected void startServer() {

}

{
try {
initializeSecurityController();
} catch (Exception e) {
log.error("Error initializing database", e);
return;
}
}
try {
initializeServer();
} catch (DBException e) {
log.error("Error initializing server", e);
return;
}

try {
initializeSecurityController();
} catch (Exception e) {
log.error("Error initializing database", e);
return;
}


if (configurationMode) {
// Try to configure automatically
performAutoConfiguration(configPath.toFile().getParentFile());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.jkiss.utils.IOUtils;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

public class WSDeleteTempFileHandler implements WSEventHandler<WSEventDeleteTempFile> {
Expand All @@ -36,10 +37,12 @@ public void resetTempFolder(String sessionId) {
Path path = CBPlatform.getInstance()
.getTempFolder(new VoidProgressMonitor(), TEMP_FILE_FOLDER)
.resolve(sessionId);
try {
IOUtils.deleteDirectory(path);
} catch (IOException e) {
log.error("Error deleting temp path", e);
if (Files.exists(path)) {
try {
IOUtils.deleteDirectory(path);
} catch (IOException e) {
log.error("Error deleting temp path", e);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2023 DBeaver Corp
*
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of DBeaver Corp and its suppliers, if any.
* The intellectual and technical concepts contained
* herein are proprietary to DBeaver Corp and its suppliers
* and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package io.cloudbeaver.server.events;

import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.WorkspaceConfigEventManager;
import org.jkiss.dbeaver.model.websocket.event.WSEventType;
import org.jkiss.dbeaver.model.websocket.event.WSWorkspaceConfigurationChangedEvent;

public class WSEventHandlerWorkspaceConfigUpdate extends WSDefaultEventHandler<WSWorkspaceConfigurationChangedEvent> {
private static final Log log = Log.getLog(WSEventHandlerWorkspaceConfigUpdate.class);

@Override
public void handleEvent(@NotNull WSWorkspaceConfigurationChangedEvent event) {
String configFileName = event.getConfigFilePath();
WorkspaceConfigEventManager.fireConfigChangedEvent(configFileName);
super.handleEvent(event);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class WebSQLFileLoaderServlet extends WebServiceServletBase {

private static final String FILE_ID = "fileId";

private static final String FORBIDDEN_CHARACTERS_FILE_REGEX = "(?U)[$()@ /]+";

private static final Gson gson = new GsonBuilder()
.serializeNulls()
.setPrettyPrinting()
Expand Down Expand Up @@ -88,14 +90,18 @@ protected void processServiceRequest(

String fileId = JSONUtils.getString(variables, FILE_ID);

if (fileId != null) {
if (fileId != null && !fileId.matches(FORBIDDEN_CHARACTERS_FILE_REGEX) && !fileId.startsWith(".")) {
Path file = tempFolder.resolve(fileId);
try {
Files.write(file, request.getPart("fileData").getInputStream().readAllBytes());
} catch (ServletException e) {
log.error(e.getMessage());
throw new DBWebException(e.getMessage());
}
} else {
String illegalCharacters = fileId != null ?
fileId.replaceAll(FORBIDDEN_CHARACTERS_FILE_REGEX, " ").strip() : null;
throw new DBException("Resource path '" + fileId + "' contains illegal characters: " + illegalCharacters);
}
}
}
4 changes: 3 additions & 1 deletion server/bundles/io.cloudbeaver.service.fs/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
class="io.cloudbeaver.service.fs.WebServiceBindingFS">
</service>
</extension>

<extension point="io.cloudbeaver.feature">
<feature id="fileSystems" label="File Systems" description="File Systems"/>
</extension>
</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
*/
package io.cloudbeaver.service.rm.fs;

import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.service.rm.nio.RMNIOFileSystemProvider;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPImage;
import org.jkiss.dbeaver.model.fs.DBFVirtualFileSystem;
import org.jkiss.dbeaver.model.fs.DBFVirtualFileSystemRoot;
import org.jkiss.dbeaver.model.rm.RMController;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;

Expand All @@ -35,8 +35,9 @@ public class RMVirtualFileSystem implements DBFVirtualFileSystem {

@NotNull
private final RMProject rmProject;
public RMVirtualFileSystem(@NotNull WebSession webSession, @NotNull RMProject rmProject) {
this.rmNioFileSystemProvider = new RMNIOFileSystemProvider(webSession.getRmController());

public RMVirtualFileSystem(@NotNull RMController rmController, @NotNull RMProject rmProject) {
this.rmNioFileSystemProvider = new RMNIOFileSystemProvider(rmController);
this.rmProject = rmProject;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
*/
package io.cloudbeaver.service.rm.fs;

import io.cloudbeaver.WebProjectImpl;
import io.cloudbeaver.model.session.WebSession;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.app.DBPProject;
import org.jkiss.dbeaver.model.fs.DBFFileSystemProvider;
import org.jkiss.dbeaver.model.fs.DBFVirtualFileSystem;
import org.jkiss.dbeaver.model.rm.RMControllerProvider;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;

public class RMVirtualFileSystemProvider implements DBFFileSystemProvider {
Expand All @@ -33,16 +32,11 @@ public DBFVirtualFileSystem[] getAvailableFileSystems(
@NotNull DBRProgressMonitor monitor,
@NotNull DBPProject project
) {
var session = project.getSessionContext().getPrimaryAuthSpace();
if (!(session instanceof WebSession)) {
if (!(project instanceof RMControllerProvider)) {
return new DBFVirtualFileSystem[0];
}
WebSession webSession = (WebSession) session;
WebProjectImpl webProject = webSession.getProjectById(project.getId());
if (webProject == null) {
log.warn(String.format("Project %s not found in session %s", project.getId(), webSession.getSessionId()));
return new DBFVirtualFileSystem[0];
}
return new DBFVirtualFileSystem[]{new RMVirtualFileSystem(webSession, webProject.getRmProject())};
RMControllerProvider rmControllerProvider = (RMControllerProvider) project;
return new DBFVirtualFileSystem[]{new RMVirtualFileSystem(rmControllerProvider.getResourceController(),
rmControllerProvider.getRMProject())};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileAttribute;
Expand Down Expand Up @@ -80,6 +82,7 @@ public Path getPath(URI uri) {
}
RMNIOFileSystem rmNioFileSystem = new RMNIOFileSystem(projectId, this);
String resourcePath = uri.getPath();
resourcePath = URLDecoder.decode(resourcePath, StandardCharsets.UTF_8);
if (CommonUtils.isNotEmpty(resourcePath) && projectId == null) {
throw new IllegalArgumentException("Project is not specified in URI");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@

import java.io.IOException;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;

public class RMPath extends NIOPath {
@NotNull
Expand Down Expand Up @@ -71,7 +76,7 @@ public Path getFileName() {
if (ArrayUtils.isEmpty(parts)) {
return this;
}
return new RMPath(rmNioFileSystem, parts[parts.length - 1]);
return new RMPath(new RMNIOFileSystem(null, getFileSystem().rmProvider()), parts[parts.length - 1]);
}

@Override
Expand Down Expand Up @@ -122,22 +127,31 @@ public Path resolve(String other) {
@Override
public URI toUri() {
var fileSystem = getFileSystem();
var uriBuilder = new StringBuilder(fileSystem.provider().getScheme())
.append("://");

if (rmProjectId != null) {
uriBuilder.append(rmProjectId);
var uriBuilder = new StringBuilder();
if (isAbsolute()) {
uriBuilder.append(fileSystem.provider().getScheme())
.append("://");
}

String rmResourcePath = getResourcePath();
if (rmResourcePath != null) {
uriBuilder.append(fileSystem.getSeparator())
.append(rmResourcePath);
}
var paths = new ArrayList<String>();
paths.add(rmProjectId);
paths.add(getResourcePath());

uriBuilder.append(
paths.stream()
.filter(Objects::nonNull)
.map(s -> URLEncoder.encode(s, StandardCharsets.UTF_8))
.collect(Collectors.joining(fileSystem.getSeparator()))
);

return URI.create(uriBuilder.toString());
}

@Override
public boolean isAbsolute() {
return rmNioFileSystem.getRmProjectId() != null;
}

@Override
public Path toAbsolutePath() {
if (isAbsolute()) {
Expand Down
Loading

0 comments on commit 4a9579f

Please sign in to comment.