Compare commits

..
4 Commits
4266 changed files with 51192 additions and 195924 deletions
-35
View File
@@ -1,35 +0,0 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/java
{
"name": "Java",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/java:1-17-bookworm",
"features": {
"ghcr.io/devcontainers/features/java:1": {
"version": "none",
"installMaven": "true",
"installGradle": "false"
},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/node:1": {}
},
"hostRequirements": {
"cpus": 8,
"memory": "16gb",
"storage": "64gb"
}
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "java -version",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
-76
View File
@@ -1,76 +0,0 @@
name: frontend-cache
on:
push:
branches: ["devel"]
paths:
- "webapp/**"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build_and_test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./webapp
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: restore yarn cache
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: restore node_modules
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node_modules-
- name: restore typescript cache
uses: actions/cache@v3
with:
path: "**/packages/*/dist"
key: ${{ runner.os }}-dist-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-dist-
- name: yarn install
uses: borales/actions-yarn@v4
with:
dir: webapp
cmd: install
- name: yarn lerna bootstrap
uses: borales/actions-yarn@v4
with:
dir: webapp
cmd: lerna bootstrap
- name: build
uses: borales/actions-yarn@v4
with:
dir: webapp/packages/product-default
cmd: build # build tyescript source code
- name: test
uses: borales/actions-yarn@v4
with:
dir: webapp
cmd: lerna run test # build packages that have test script
-29
View File
@@ -1,29 +0,0 @@
name: cleanup caches by a branch
on:
pull_request:
types:
- closed
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
-80
View File
@@ -1,80 +0,0 @@
name: frontend
on:
# Triggers the workflow on push or pull request events but only for the "devel" branch
pull_request:
branches: ["devel"]
paths:
- "webapp/**" # monitor for the frontend changes
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allows you to reuse workflows by referencing their YAML files
workflow_call:
jobs:
build_and_test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./webapp
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "20"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: restore yarn cache
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: restore node_modules
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node_modules-
- name: restore typescript cache
uses: actions/cache@v3
with:
path: "**/packages/*/dist"
key: ${{ runner.os }}-dist-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-dist-
- name: yarn install
uses: borales/actions-yarn@v4
with:
dir: webapp
cmd: install
- name: yarn lerna bootstrap
uses: borales/actions-yarn@v4
with:
dir: webapp
cmd: lerna bootstrap
- name: build
uses: borales/actions-yarn@v4
with:
dir: webapp/packages/product-default
cmd: bundle
- name: test
uses: borales/actions-yarn@v4
with:
dir: webapp
cmd: lerna run test
-17
View File
@@ -1,17 +0,0 @@
name: validation
on:
pull_request:
branches:
- devel
types:
- opened
- synchronize
- reopened
- edited
- ready_for_review
- labeled
jobs:
commit-message:
uses: dbeaver/dbeaver/.github/workflows/reused-commit-msgs-validator.yml@devel
+4 -7
View File
@@ -16,10 +16,14 @@
*.ear
*.rar
# editor files
.vscode
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# web
/sources/web/node_modules/
dist/
## IDEA configs
@@ -28,12 +32,6 @@ dist/
/idea/
.idea/
## Mac OS
.DS_Store
## tests
server/test/io.cloudbeaver.test.platform/workspace/.data/
## Eclipse configs
.project
@@ -42,4 +40,3 @@ server/test/io.cloudbeaver.test.platform/workspace/.data/
deploy/cloudbeaver
server/**/target
apps/**/target
-25
View File
@@ -1,25 +0,0 @@
{
"recommendations": [
"shengchen.vscode-checkstyle",
"vscjava.vscode-java-pack",
"yaozheng.vscode-pde",
"arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint",
"ecmel.vscode-html-css",
"GraphQL.vscode-graphql",
"ms-vscode.js-debug",
"ms-vscode.vscode-js-profile-table",
"rangav.vscode-thunder-client",
"redhat.vscode-xml",
"redhat.vscode-yaml",
"streetsidesoftware.code-spell-checker",
"streetsidesoftware.code-spell-checker-russian",
"syler.sass-indented",
"VisualStudioExptTeam.intellicode-api-usage-examples",
"VisualStudioExptTeam.vscodeintellicode",
"yzhang.markdown-all-in-one",
"GraphQL.vscode-graphql-syntax",
"mrmlnc.vscode-json5",
"esbenp.prettier-vscode"
]
}
-92
View File
@@ -1,92 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Chrome",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/..",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///*": "${workspaceFolder}/../*"
},
"skipFiles": [
"<node_internals>/**",
"**/node_modules/**",
"${workspaceFolder}/webapp/**/node_modules/**/*.js",
"${workspaceFolder}/webapp/**/dist/**/*.js"
]
},
{
"type": "java",
"name": "CloudBeaver CE",
"cwd": "${workspaceFolder}/../opt/cbce",
"request": "launch",
"mainClass": "org.jkiss.dbeaver.launcher.DBeaverLauncher",
"windows": {
"type": "java",
"name": "CloudBeaver CE",
"request": "launch",
"mainClass": "org.jkiss.dbeaver.launcher.DBeaverLauncher",
"args": [
"-product",
"io.cloudbeaver.product.ce.product",
"-configuration",
"file:${workspaceFolder}/../eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/CloudbeaverServer.product/",
"-dev",
"file:${workspaceFolder}/../eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/CloudbeaverServer.product/dev.properties",
"-os",
"win32",
"-ws",
"win32",
"-arch",
"x86_64",
"-nl",
"en",
"-showsplash",
"-web-config",
"conf/cloudbeaver.conf"
],
"vmArgs": [
"-XX:+IgnoreUnrecognizedVMOptions",
"--add-modules=ALL-SYSTEM",
"-Xms64m",
"-Xmx1024m",
"-Declipse.pde.launch=true"
]
},
"osx": {
"type": "java",
"name": "CloudBeaver CE",
"request": "launch",
"mainClass": "org.jkiss.dbeaver.launcher.DBeaverLauncher",
"args": [
"-product",
"io.cloudbeaver.product.ce.product",
"-configuration",
"file:${workspaceFolder}/../eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/CloudbeaverServer.product/",
"-dev",
"file:${workspaceFolder}/../eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/CloudbeaverServer.product/dev.properties",
"-os",
"macosx",
"-ws",
"cocoa",
"-arch",
"aarch64",
"-nl",
"en_US",
"-showsplash"
],
"vmArgs": [
"-XX:+IgnoreUnrecognizedVMOptions",
"--add-modules=ALL-SYSTEM",
"-Xms64m",
"-Xmx1024m",
"-Declipse.pde.launch=true",
"-XstartOnFirstThread"
]
}
}
]
}
-17
View File
@@ -1,17 +0,0 @@
{
"license": {
"scope": "typescript,typescriptreact,javascript,javascriptreact,css,scss",
"prefix": "license",
"body": [
"/*",
" * CloudBeaver - Cloud Database Manager",
" * Copyright (C) 2020-2024 DBeaver Corp and others",
" *",
" * Licensed under the Apache License, Version 2.0.",
" * you may not use this file except in compliance with the License.",
" */",
"",
""
]
}
}
-51
View File
@@ -1,51 +0,0 @@
{
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.linkedEditing": true,
"task.autoDetect": "off",
"java.configuration.updateBuildConfiguration": "automatic",
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx16G -Xms100m -Xlog:disable",
"java.compile.nullAnalysis.mode": "automatic",
"typescript.preferences.useAliasesForRenames": false,
"typescript.preferences.importModuleSpecifier": "relative",
"typescript.preferences.includePackageJsonAutoImports": "on",
"typescript.preferences.quoteStyle": "single",
"typescript.tsdk": "webapp/node_modules/typescript/lib",
"eslint.enable": true,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"eslint.workingDirectories": ["webapp"],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[java]": {
"editor.defaultFormatter": "redhat.java"
},
"files.eol": "\n",
"files.associations": {
"*.css": "postcss"
},
"java.checkstyle.configuration": "${workspaceFolder}/../dbeaver/dbeaver-checkstyle-config.xml",
"java.checkstyle.version": "10.12.0"
}
-95
View File
@@ -1,95 +0,0 @@
{
"version": "2.0.0",
"problemMatcher": [],
"presentation": {
"clear": true
},
"options": {
"cwd": "${workspaceFolder}/webapp",
"env": {
"NODE_OPTIONS": "--max-old-space-size=8192",
"MAVEN_OPTS": "-Xmx8192m"
}
},
"tasks": [
{
"label": "Run Tests CE",
"type": "shell",
"command": "yarn",
"group": "test",
"args": ["lerna", "run", "test", "--no-bail", "--stream", "--"]
},
{
"label": "Run DevServer CE",
"group": "build",
"isBackground": true,
"type": "shell",
"command": "yarn",
"args": ["dev"],
"options": {
"env": {
"server": "${input:stage.ce}"
},
"cwd": "${workspaceFolder}/webapp/packages/product-default"
}
},
{
"label": "Build CE",
"type": "shell",
"windows": {
"command": "./build-sqlite.bat"
},
"osx": {
"command": "./build-sqlite.sh"
},
"options": {
"cwd": "${workspaceFolder}/deploy"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Run Backend CE",
"type": "shell",
"windows": {
"command": "./run-server.bat"
},
"osx": {
"command": "./run-server.sh"
},
"options": {
"cwd": "${workspaceFolder}/deploy/cloudbeaver"
}
},
{
"label": "Yarn Install",
"type": "shell",
"command": "yarn install; yarn lerna bootstrap",
"args": [],
"presentation": {
"reveal": "silent",
"close": true,
"clear": false
}
},
{
"label": "Update TS references CE",
"type": "shell",
"command": "yarn lerna run update-ts-references --stream",
"options": {
"cwd": "${workspaceFolder}/webapp"
}
}
],
"inputs": [
{
"type": "pickString",
"id": "stage.ce",
"description": "CE Stage servers",
"default": "http://localhost:8978/",
"options": ["http://localhost:8978/"]
}
]
}
+41 -34
View File
@@ -9,10 +9,12 @@ See out [WIKI](https://github.com/dbeaver/cloudbeaver/wiki) for more details.
![](https://github.com/dbeaver/cloudbeaver/wiki/images/demo_screenshot_1.png)
## Run in Docker
## Build CloudBeaver
- [Official Docker repository](https://hub.docker.com/r/dbeaver/cloudbeaver)
- [Running instructions](https://github.com/dbeaver/cloudbeaver/wiki/Run-Docker-Container)
CloudBeaver is the multi-platform server side application.
It can run on Linux, Windows and MacOS X.
[Detailed instructions](https://github.com/dbeaver/cloudbeaver/wiki/Build-and-deploy)
## Demo server
@@ -22,36 +24,41 @@ You can see live demo of CloudBeaver here: https://demo.cloudbeaver.io
## Changelog
### CloudBeaver 1.1.0 - 2020-07-14
### 24.0.0. 2024-03-04
- Changes since 23.3.0:
- Connection management and authentication redesign
- Webpack build minimization
- A lot of minor UI improvements
- Many minor UI improvements
- Main updates:
- Have enhanced security for unauthorised access;
- Have added a password policy for the local authorization. Password parameters can be set in the configuration file;
- Have added validation for mandatory fields in all forms to create and edit entities;
- Have added an ability to edit the default preferences of the following parts: interface, tools and data viewer in the settings panel in the administrative part;
- Performance:
- Have improved the performance of the server.
- Administration:
- Have added the ability to configure reverse proxy header name and redirect URL at logout. Now the administrator can configure all settings. The delimiter symbol for the reverse proxy team headers is configurable;
- Preferences:
- Have added the ability in the admin panel to customise copying in the Tables and Values panel for all users except the administrator;
- Have added the ability to disable alias autocomplete for all users.
- Access Management:
- A default user group was added to the product. This group includes all users which could not be deleted.
- Connections:
- The 'Keep alive' option has been added to the connection settings to keep the connection active even in case of inactivity.
- Data Editor:
- Have added the ability to view decoded binary-type data in the Value panel;
- Text wrap is activated by default for texts and BLOBs in the Values panel for better visibility. The user can switch to the one-line mode using a button on the toolbar;
- Have added the ability to display full text for a string data type in the Value panel;
- Have added the ability to display the OpenStreetMap layer with the coordinate system ESPG 4326.
- Resource management:
- Read-only scripts now have a padlock icon.
- Databases:
- The DuckDB driver has been added;
- Updated PostgreSQL driver to 42.5.2;
- ClickHouse Legacy driver has been removed to prevent potential vulnerability issues;
- Updated MariaDB driver to version 3.3.2.
- Different bug fixes and enhancements have been made.
### CloudBeaver 1.0.4 - 2020-06-16
- Database navigator refresh
- Data viewer: filters support
- Many minor UI improvements
### CloudBeaver 1.0.3 - 2020-06-02
- Administrative panel
- User management
- Authentication model redesign
- Build artifacts minimization
- Many minor UI improvements
### CloudBeaver 1.0.2 - 2020-05-19
- Data export feature UI was improved
- User authentication and permission management
- Driver management was redesigned
- Clickhouse driver was added
- Build procedure was redesigned
- Many minor bugfixes
### CloudBeaver 1.0.1 - 2020-05-05
- Data export feature added to the data viewer
- H2 embedded database driver was added
- User authentication API was added
- Product configuration framework and API was added
- Embedded database for user management was added
- Many minor bugfixes
-17
View File
@@ -1,17 +0,0 @@
# Security Policy
## Supported Versions
Use this section to tell people about which versions of your project are
currently being supported with security updates.
| Version | Supported |
| ------- | --------- |
| 22.x | yes |
| 23.x | yes |
## Reporting a Vulnerability
Please report (suspected) security vulnerabilities to devops@dbeaver.com.
You will receive a response from us within 48 hours.
If the issue is confirmed, we will release a patch as soon as possible depending on complexity but historically within a few days.
-27
View File
@@ -1,27 +0,0 @@
# H2 Query Executor
Applications for executing h2 database queries through the console and running queries to fix the CloudBeaver database
## How to build
Use mvn clean install to build executable jar.
## Arguments:
**--db-path** - path to cloudbeaver database
**--db-user** - cloudbeaver database username
**--db-password-path** - path to .database.credentials.dat
**--db-password** - database password(use only password or db-password-path, not both)
**--db-custom-query** - execute custom sql query
**--db-execute-11-migration-fix** - mark that scripts to fix broken migration must be executed
## Example:
java -jar h2-query-executor-1.0.0.jar --db-path=/var/cloudbeaver/workspace/.data/cb.h2.dat.mv.db --db-user=cb-data
--db-password-path=/var/cloudbeaver/workspace/.data/.database-credentials.dat --db-custom-query="show tables"
-56
View File
@@ -1,56 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>io.cloudbeaver</groupId>
<artifactId>h2-query-executor</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.220</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifest>
<mainClass>
io.cloudbeaver.H2ExecutorConsoleApplication
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -1,33 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver;
import java.util.HashMap;
import java.util.Map;
public class ArgsParser {
public static Map<String, String> parseArgs(String[] args) {
var result = new HashMap<String, String>();
for (String arg : args) {
var keyValue = arg.split("=");
var key = keyValue[0].replaceAll("--", "");
var value = keyValue.length > 1 ? keyValue[1] : null;
result.put(key, value);
}
return result;
}
}
@@ -1,76 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import java.util.Properties;
public class H2ExecutorConsoleApplication {
private static final String ARG_DB_PATH = "db-path";
private static final String ARG_DB_USER = "db-user";
private static final String ARG_DB_PASSWORD = "db-password";
private static final String ARG_DB_PASSWORD_PATH = "db-password-path";
private static final String ARG_DB_CUSTOM_QUERY = "db-custom-query";
private static final String ARG_EXECUTE_11_MIGRATION_FIX = "db-execute-11-migration-fix";
public static void main(String[] args) throws Exception {
var parsedArgs = ArgsParser.parseArgs(args);
var dbPath = validateAndGetValue(ARG_DB_PATH, parsedArgs);
var dbUser = validateAndGetValue(ARG_DB_USER, parsedArgs);
String dbPassword = null;
if (parsedArgs.containsKey(ARG_DB_PASSWORD)) {
dbPassword = validateAndGetValue(ARG_DB_PASSWORD, parsedArgs);
} else if (parsedArgs.containsKey(ARG_DB_PASSWORD_PATH)) {
var dbPasswordFilePath = validateAndGetValue(ARG_DB_PASSWORD_PATH, parsedArgs);
dbPassword = Files.readString(Path.of(dbPasswordFilePath));
}
if (dbPassword == null) {
throw new RuntimeException("Database password not specified");
}
var dbUrl = "jdbc:h2:file:" + dbPath.replaceAll(".mv.db", "");
var props = new Properties();
props.put("user", dbUser);
props.put("password", dbPassword);
var executor = new H2QueryExecutor(dbUrl, props);
process(executor, parsedArgs);
}
private static String validateAndGetValue(String argName, Map<String, String> ars) {
String argValue = ars.get(argName);
if (argValue == null) {
throw new RuntimeException(argName + " parameter not specified");
}
return argValue;
}
public static void process(H2QueryExecutor executor, Map<String, String> args) throws Exception {
if (args.containsKey(ARG_DB_CUSTOM_QUERY)) {
var customQuery = validateAndGetValue(ARG_DB_CUSTOM_QUERY, args);
executor.executeQuery(customQuery);
}
if (args.containsKey(ARG_EXECUTE_11_MIGRATION_FIX)) {
System.out.println("Start to execute migration fix");
executor.execute11MigrationFix();
}
}
}
@@ -1,63 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
public class H2QueryExecutor {
private final String dbUrl;
private final Properties dbProperties;
public H2QueryExecutor(String dbUrl, Properties dbProperties) {
this.dbUrl = dbUrl;
this.dbProperties = dbProperties;
}
public void executeQuery(String query) throws SQLException, ClassNotFoundException {
System.out.println("Execute query: " + query);
try (
var connection = DriverManager.getConnection(dbUrl, dbProperties);
var statement = connection.createStatement()
) {
statement.execute(query);
var result = statement.getResultSet();
if (result == null) {
return;
}
var meta = result.getMetaData();
while (result.next()) {
for (var i = 1; i <= meta.getColumnCount(); i++) {
var className = meta.getColumnClassName(i);
var clazz = Class.forName(className);
System.out.print(result.getObject(i, clazz) + " ");
}
System.out.println();
}
}
}
public void execute11MigrationFix() throws SQLException, ClassNotFoundException {
var queries = SqlConsts.fix11MigrationQueries.split(";");
for (String query : queries) {
executeQuery(query);
}
}
}
@@ -1,53 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver;
public class SqlConsts {
public static final String fix11MigrationQueries = "" +
"CREATE TABLE CB_USER_TEAM\n" +
"(\n" +
" USER_ID VARCHAR(128) NOT NULL,\n" +
" TEAM_ID VARCHAR(128) NOT NULL,\n" +
"\n" +
" GRANT_TIME TIMESTAMP NOT NULL,\n" +
" GRANTED_BY VARCHAR(128) NOT NULL,\n" +
"\n" +
" PRIMARY KEY (USER_ID, TEAM_ID),\n" +
" FOREIGN KEY (USER_ID) REFERENCES CB_USER (USER_ID) ON DELETE CASCADE,\n" +
" FOREIGN KEY (TEAM_ID) REFERENCES CB_TEAM (TEAM_ID) ON DELETE NO ACTION\n" +
");\n" +
"\n" +
"INSERT INTO CB_USER_TEAM (USER_ID, TEAM_ID, GRANT_TIME, GRANTED_BY)\n" +
"SELECT USER_ID, ROLE_ID, GRANT_TIME, GRANTED_BY FROM CB_USER_ROLE;\n" +
"\n" +
"CREATE TABLE CB_EXTERNAL_TEAM\n" +
"(\n" +
" TEAM_ID VARCHAR(128) NOT NULL,\n" +
" EXTERNAL_TEAM_ID VARCHAR(128) NOT NULL,\n" +
"\n" +
" PRIMARY KEY (TEAM_ID,EXTERNAL_TEAM_ID),\n" +
" FOREIGN KEY (TEAM_ID) REFERENCES CB_TEAM (TEAM_ID) ON DELETE CASCADE\n" +
");\n" +
"\n" +
"DROP TABLE CB_USER_ROLE;\n" +
"DROP TABLE CB_ROLE;\n" +
"\n" +
"\n" +
"DELETE FROM CB_SCHEMA_INFO where VERSION > 0;\n" +
"INSERT INTO CB_SCHEMA_INFO (VERSION,UPDATE_TIME) VALUES(11,CURRENT_TIMESTAMP)\n" +
"\n";
}
-16
View File
@@ -1,16 +0,0 @@
{
teams: [
{
subjectId: "admin",
teamName: "Admin",
description: "Administrative access. Has all permissions.",
permissions: [ "admin" ]
},
{
subjectId: "user",
teamName: "User",
description: "All users, including anonymous.",
permissions: [ ]
}
]
}
-21
View File
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{dd-MM-yyyy HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<!-- Disable logback status messages -->
<statusListener class="ch.qos.logback.core.status.NopStatusListener"/>
<logger name="org.jkiss" level="DEBUG"/>
<logger name="io.cloudbeaver" level="DEBUG"/>
<root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
-32
View File
@@ -1,32 +0,0 @@
// Product configuration. Customized web application behavior
// It is in JSONC format
{
// Global properties
core: {
// User defaults
user: {
defaultTheme: "light",
defaultLanguage: "en"
},
app: {
// Log viewer config
logViewer: {
refreshTimeout: 3000,
logBatchSize: 1000,
maxLogRecords: 2000,
maxFailedRequests: 3
}
}
},
// Notifications config
core_events: {
notificationsPool: 20
},
plugin_data_spreadsheet_new: {
hidden: false
},
plugin_data_export: {
disabled: false
},
sql.proposals.insert.table.alias: true
}
@@ -1,24 +0,0 @@
{
"folders": {},
"connections": {
"postgresql-template-1": {
"provider": "postgresql",
"driver": "postgres-jdbc",
"name": "PostgreSQL (Template)",
"save-password": false,
"show-system-objects": false,
"read-only": true,
"template": true,
"configuration": {
"host": "localhost",
"port": "5432",
"database": "postgres",
"url": "jdbc:postgresql://localhost:5432/postgres",
"type": "dev",
"provider-properties": {
"@dbeaver-show-non-default-db@": "false"
}
}
}
}
}
@@ -1,84 +0,0 @@
{
server: {
serverPort: 8978,
workspaceLocation: "workspace",
contentRoot: "web",
driversLocation: "drivers",
sslConfigurationPath:"${CLOUDBEAVER_SSL_CONF_PATH:workspace/.data/ssl-config.xml}",
rootURI: "/",
serviceURI: "/api/",
productConfiguration: "conf/product.conf",
expireSessionAfterPeriod: 1800000,
develMode: false,
enableSecurityManager: false,
sm: {
enableBruteForceProtection: "${CLOUDBEAVER_BRUTE_FORCE_PROTECTION_ENABLED:true}",
maxFailedLogin: "${CLOUDBEAVER_MAX_FAILED_LOGINS:10}",
minimumLoginTimeout: "${CLOUDBEAVER_MINIMUM_LOGIN_TIMEOUT:1}",
blockLoginPeriod: "${CLOUDBEAVER_BLOCK_PERIOD:300}",
passwordPolicy: {
minLength: "${CLOUDBEAVER_POLICY_MIN_LENGTH:8}",
requireMixedCase: "${CLOUDBEAVER_POLICY_REQUIRE_MIXED_CASE:true}",
minNumberCount: "${CLOUDBEAVER_POLICY_MIN_NUMBER_COUNT:1}",
minSymbolCount: "${CLOUDBEAVER_POLICY_MIN_SYMBOL_COUNT:0}"
}
},
database: {
driver="h2_embedded_v2",
url: "jdbc:h2:${workspace}/.data/cb.h2v2.dat",
initialDataConfiguration: "conf/initial-data.conf",
pool: {
minIdleConnections: 4,
maxIdleConnections: 10,
maxConnections: 100,
validationQuery: "SELECT 1"
}
}
},
app: {
anonymousAccessEnabled: true,
anonymousUserRole: "user",
grantConnectionsAccessToAnonymousTeam: false,
supportsCustomConnections: false,
showReadOnlyConnectionInfo: false,
forwardProxy: false,
publicCredentialsSaveEnabled: true,
adminCredentialsSaveEnabled: true,
resourceManagerEnabled: true,
resourceQuotas: {
dataExportFileSizeLimit: 10000000,
resourceManagerFileSizeLimit: 500000,
sqlMaxRunningQueries: 100,
sqlResultSetRowsLimit: 100000,
sqlResultSetMemoryLimit: 2000000,
sqlTextPreviewMaxLength: 4096,
sqlBinaryPreviewMaxLength: 261120
},
enabledAuthProviders: [
"local"
],
disabledDrivers: [
"sqlite:sqlite_jdbc",
"h2:h2_embedded",
"h2:h2_embedded_v2",
"clickhouse:yandex_clickhouse"
]
}
}
@@ -1,4 +0,0 @@
{
"folders": {},
"connections": {}
}
@@ -1,80 +0,0 @@
{
server: {
serverPort: 8978,
workspaceLocation: "workspace",
contentRoot: "web",
driversLocation: "drivers",
rootURI: "/",
serviceURI: "/api/",
productConfiguration: "conf/product.conf",
expireSessionAfterPeriod: 1800000,
develMode: false,
enableSecurityManager: false,
database: {
driver="h2_embedded_v2",
url: "jdbc:h2:${workspace}/.data/cb.h2v2.dat",
initialDataConfiguration: "conf/initial-data.conf",
pool: {
minIdleConnections: 4,
maxIdleConnections: 10,
maxConnections: 100,
validationQuery: "SELECT 1"
}
},
sm: {
enableBruteForceProtection: "${CLOUDBEAVER_BRUTE_FORCE_PROTECTION_ENABLED:true}",
maxFailedLogin: "${CLOUDBEAVER_MAX_FAILED_LOGINS:10}",
minimumLoginTimeout: "${CLOUDBEAVER_MINIMUM_LOGIN_TIMEOUT:1}",
blockLoginPeriod: "${CLOUDBEAVER_BLOCK_PERIOD:300}",
passwordPolicy: {
minLength: "${CLOUDBEAVER_POLICY_MIN_LENGTH:8}",
requireMixedCase: "${CLOUDBEAVER_POLICY_REQUIRE_MIXED_CASE:true}",
minNumberCount: "${CLOUDBEAVER_POLICY_MIN_NUMBER_COUNT:1}",
minSymbolCount: "${CLOUDBEAVER_POLICY_MIN_SYMBOL_COUNT:0}"
}
}
},
app: {
anonymousAccessEnabled: true,
anonymousUserRole: "user",
grantConnectionsAccessToAnonymousTeam: false,
supportsCustomConnections: false,
showReadOnlyConnectionInfo: false,
forwardProxy: false,
publicCredentialsSaveEnabled: true,
adminCredentialsSaveEnabled: true,
resourceManagerEnabled: true,
resourceQuotas: {
dataExportFileSizeLimit: 10000000,
resourceManagerFileSizeLimit: 500000,
sqlMaxRunningQueries: 100,
sqlResultSetRowsLimit: 100000,
sqlResultSetMemoryLimit: 2000000,
sqlTextPreviewMaxLength: 4096,
sqlBinaryPreviewMaxLength: 261120
},
enabledAuthProviders: [
"local"
],
disabledDrivers: [
"h2:h2_embedded",
"h2:h2_embedded_v2",
"clickhouse:yandex_clickhouse"
]
}
}
-63
View File
@@ -1,63 +0,0 @@
#!/bin/bash
set -Eeo pipefail
set +u
# #command line arguments
# CONFIGURATION_PATH=${1-"../config/sample-databases/DefaultConfiguration"}
# SAMPLE_DATABASE_PATH=${2-""}
# echo $CONFIGURATION_PATH
# echo $SAMPLE_DATABASE_PATH
echo "Clone and build Cloudbeaver"
rm -rf ./drivers
rm -rf ./cloudbeaver
mkdir ./cloudbeaver
mkdir ./cloudbeaver/server
mkdir ./cloudbeaver/conf
mkdir ./cloudbeaver/workspace
mkdir ./cloudbeaver/web
echo "Pull cloudbeaver platform"
cd ../..
echo "Pull dbeaver platform"
[ ! -d dbeaver ] && git clone --depth 1 https://github.com/dbeaver/dbeaver.git
[ ! -d dbeaver-common ] && git clone --depth 1 https://github.com/dbeaver/dbeaver-common.git
cd cloudbeaver/deploy
echo "Build CloudBeaver server"
cd ../server/product/aggregate
mvn clean verify $MAVEN_COMMON_OPTS -Dheadless-platform
if [[ "$?" -ne 0 ]] ; then
echo 'Could not perform package'; exit $rc
fi
cd ../../../deploy
echo "Copy server packages"
cp -rp ../server/product/web-server/target/products/io.cloudbeaver.product/all/all/all/* ./cloudbeaver/server
cp -p ./scripts/* ./cloudbeaver
mkdir cloudbeaver/samples
if [[ -z $SAMPLE_DATABASE_PATH ]]; then
SAMPLE_DATABASE_PATH=""
else
mkdir cloudbeaver/samples/db
cp -rp "${SAMPLE_DATABASE_PATH}" cloudbeaver/samples/
fi
if [[ -z "$CONFIGURATION_PATH" ]]; then
CONFIGURATION_PATH="../config/sample-databases/DefaultConfiguration"
fi
cp -rp ../config/core/* cloudbeaver/conf
cp -rp "${CONFIGURATION_PATH}"/GlobalConfiguration/.dbeaver/data-sources.json cloudbeaver/conf/initial-data-sources.conf
cp -p "${CONFIGURATION_PATH}"/*.conf cloudbeaver/conf/
mv drivers cloudbeaver
echo "End of backend build"
-21
View File
@@ -1,21 +0,0 @@
#!/bin/bash
set -Eeuo pipefail
echo "Build static content"
cd ../../cloudbeaver/webapp
yarn
yarn lerna run bootstrap
yarn lerna run bundle --no-bail --stream --scope=@cloudbeaver/product-default #-- -- --env source-map
if [[ "$?" -ne 0 ]] ; then
echo 'Application build failed'; exit $rc
fi
cd ../deploy
echo "Copy static content"
cp -rp ../webapp/packages/product-default/lib/* cloudbeaver/web
echo "Cloudbeaver is ready. Run run-server.sh in cloudbeaver folder to start the server."
-1
View File
@@ -1 +0,0 @@
@call build.bat ..\config\sample-databases\SQLiteConfiguration ..\config\sample-databases\db
-9
View File
@@ -1,9 +0,0 @@
#!/bin/bash
set -Eeuo pipefail
#command line arguments
CONFIGURATION_PATH='../config/sample-databases/SQLiteConfiguration'
SAMPLE_DATABASE_PATH='../config/sample-databases/db'
source build-backend.sh
source build-frontend.sh
+9 -28
View File
@@ -1,12 +1,4 @@
@echo off
rem command line arguments
SET CONFIGURATION_PATH=%1
SET SAMPLE_DATABASE_PATH=%2
IF "%CONFIGURATION_PATH%"=="" SET CONFIGURATION_PATH="..\config\sample-databases\DefaultConfiguration"
echo "Configuration path=%CONFIGURATION_PATH%"
echo Clone and build Cloudbeaver
IF EXIST drivers rmdir /S /Q drivers
@@ -17,20 +9,16 @@ mkdir cloudbeaver\conf
mkdir cloudbeaver\workspace
mkdir cloudbeaver\web
echo Pull cloudbeaver platform
cd ..\..
echo Pull dbeaver platform
cd ../..
IF NOT EXIST dbeaver git clone https://github.com/dbeaver/dbeaver.git
IF NOT EXIST dbeaver-common git clone https://github.com/dbeaver/dbeaver-common.git
cd cloudbeaver\deploy
echo Build cloudbeaver server
cd ..\server\product\aggregate
call mvn clean verify -Dheadless-platform
call mvn clean package -Dheadless-platform
cd ..\..\..\deploy
@@ -39,26 +27,19 @@ echo Copy server packages
xcopy /E /Q ..\server\product\web-server\target\products\io.cloudbeaver.product\all\all\all\* cloudbeaver\server >NUL
copy scripts\* cloudbeaver >NUL
mkdir cloudbeaver\samples
IF NOT "%SAMPLE_DATABASE_PATH%"=="" (
mkdir cloudbeaver\samples\db
xcopy /E /Q %SAMPLE_DATABASE_PATH% cloudbeaver\samples\db >NUL
)
copy ..\config\core\* cloudbeaver\conf >NUL
copy %CONFIGURATION_PATH%\GlobalConfiguration\.dbeaver\data-sources.json cloudbeaver\conf\initial-data-sources.conf >NUL
copy %CONFIGURATION_PATH%\*.conf cloudbeaver\conf >NUL
mkdir cloudbeaver\samples\db
xcopy /E /Q ..\samples\sample-databases\db cloudbeaver\samples\db >NUL
copy ..\samples\sample-databases\GlobalConfiguration\.dbeaver\data-sources.json cloudbeaver\conf\initial-data-sources.conf >NUL
copy ..\samples\sample-databases\*.conf cloudbeaver\conf >NUL
move drivers cloudbeaver >NUL
echo Build static content
cd ..\
cd ..\cloudbeaver\webapp
cd ..\webapp
call yarn
call yarn lerna bootstrap
call yarn lerna run bundle --no-bail --stream --scope=@cloudbeaver/product-default &::-- -- --env source-map
call lerna bootstrap
call lerna run build --stream --scope=@cloudbeaver/product-default -- -- --mode=production
cd ..\deploy
+51 -6
View File
@@ -1,9 +1,54 @@
#!/bin/bash
set -Eeuo pipefail
set -e
#command line arguments
CONFIGURATION_PATH="../config/sample-databases/DefaultConfiguration"
SAMPLE_DATABASE_PATH=""
echo "Clone and build Cloudbeaver"
source build-backend.sh
source build-frontend.sh
rm -rf ./drivers
rm -rf ./cloudbeaver
mkdir ./cloudbeaver
mkdir ./cloudbeaver/server
mkdir ./cloudbeaver/conf
mkdir ./cloudbeaver/workspace
mkdir ./cloudbeaver/web
echo "Clone dbeaver platform"
cd ../..
[ ! -d dbeaver ] && git clone https://github.com/dbeaver/dbeaver.git
cd cloudbeaver/deploy
echo "Build CloudBeaver server"
cd ../server/product/aggregate
mvn clean package -Dheadless-platform
if [[ "$?" -ne 0 ]] ; then
echo 'Could not perform package'; exit $rc
fi
cd ../../../deploy
echo "Copy server packages"
cp -rp ../server/product/web-server/target/products/io.cloudbeaver.product/all/all/all/* ./cloudbeaver/server
cp -p ./scripts/* ./cloudbeaver
mkdir cloudbeaver/samples
mkdir cloudbeaver/samples/db
cp -rp ../samples/sample-databases/db cloudbeaver/samples/
cp -rp ../samples/sample-databases/GlobalConfiguration/.dbeaver/data-sources.json cloudbeaver/conf/initial-data-sources.conf
cp -p ../samples/sample-databases/*.conf cloudbeaver/conf/
mv drivers cloudbeaver
echo "Build static content"
cd ../webapp
yarn
lerna run bootstrap
lerna run build --stream --scope=@cloudbeaver/product-default -- -- --mode=production
cd ../deploy
echo "Copy static content"
cp -rp ../webapp/packages/product-default/lib/* cloudbeaver/web
echo "Cloudbeaver is ready. Run run-server.bat in cloudbeaver folder to start the server."
+10 -44
View File
@@ -1,52 +1,18 @@
FROM ubuntu:23.10
FROM adoptopenjdk/openjdk11:x86_64-ubuntu-jdk-11.0.7_10
MAINTAINER DBeaver Corp, devops@dbeaver.com
RUN apt-get update
RUN apt-get install -y supervisor
RUN set -eux; \
apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
# curl required for historical reasons, see https://github.com/adoptium/containers/issues/255
curl \
wget \
# java.lang.UnsatisfiedLinkError: libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory
# java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager
# https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077
fontconfig \
# utilities for keeping Ubuntu and OpenJDK CA certificates in sync
# https://github.com/adoptium/containers/issues/293
ca-certificates p11-kit \
# jlink --strip-debug on 13+ needs objcopy: https://github.com/docker-library/openjdk/issues/351
# Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory
binutils \
tzdata \
# locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8
locales \
nano \
; \
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \
locale-gen en_US.UTF-8; \
rm -rf /var/lib/apt/lists/*
ENV LANG=en_US.UTF-8
ENV JAVA_HOME=/opt/java/openjdk
COPY --from=eclipse-temurin:17 $JAVA_HOME $JAVA_HOME
ENV PATH="${JAVA_HOME}/bin:${PATH}"
RUN set -eux; \
# https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472
find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \
ldconfig; \
# https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840
# https://openjdk.java.net/jeps/341
java -Xshare:dump;
### Patch java security
COPY java.security* ${JAVA_HOME}/conf/security/java.security
#RUN mkdir -p /opt/cloudbeaver
COPY cloudbeaver /opt/cloudbeaver
#RUN ["chmod", "+x", "/opt/cloudbeaver/run-server.sh"]
COPY supervisor/cloudbeaver.conf /etc/supervisor/conf.d/cloudbeaver.conf
EXPOSE 8978
RUN find /opt/cloudbeaver -type d -exec chmod 775 {} \;
#CMD ["/usr/bin/supervisord"]
WORKDIR /opt/cloudbeaver/
ENTRYPOINT ["./run-server.sh"]
+5 -41
View File
@@ -1,47 +1,11 @@
@echo off
for /f %%a in ('dir /B /S server\plugins\org.jkiss.dbeaver.launcher*.jar') do SET launcherJar="%%a"
@rem echo off
for /f %%a in ('dir /B /S server\plugins\org.eclipse.equinox.launcher*.jar') do SET launcherJar="%%a"
echo "Starting Cloudbeaver Server"
IF NOT EXIST workspace\.metadata (
IF NOT EXIST workspace\GlobalConfiguration\.dbeaver (
mkdir workspace\GlobalConfiguration\.dbeaver\
copy conf\initial-data-sources.conf workspace\GlobalConfiguration\.dbeaver\data-sources.json
)
mkdir workspace\GlobalConfiguration\.dbeaver\
copy conf\initial-data-sources.conf workspace\GlobalConfiguration\.dbeaver\data-sources.json
)
SET VMARGS_OPTS = ""
If Not Defined JAVA_OPTS (
SET VMARGS_OPTS = "-Xmx2048M"
)
java %JAVA_OPTS% ^
-Dfile.encoding=UTF-8 ^
--add-modules=ALL-SYSTEM ^
--add-opens=java.base/java.io=ALL-UNNAMED ^
--add-opens=java.base/java.lang=ALL-UNNAMED ^
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED ^
--add-opens=java.base/java.net=ALL-UNNAMED ^
--add-opens=java.base/java.nio=ALL-UNNAMED ^
--add-opens=java.base/java.nio.charset=ALL-UNNAMED ^
--add-opens=java.base/java.text=ALL-UNNAMED ^
--add-opens=java.base/java.time=ALL-UNNAMED ^
--add-opens=java.base/java.util=ALL-UNNAMED ^
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED ^
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED ^
--add-opens=java.base/jdk.internal.vm=ALL-UNNAMED ^
--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED ^
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED ^
--add-opens=java.base/sun.security.ssl=ALL-UNNAMED ^
--add-opens=java.base/sun.security.action=ALL-UNNAMED ^
--add-opens=java.base/sun.security.util=ALL-UNNAMED ^
--add-opens=java.security.jgss/sun.security.jgss=ALL-UNNAMED ^
--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED ^
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED ^
--add-opens=java.sql/java.sql=ALL-UNNAMED ^
-jar %launcherJar% ^
-product io.cloudbeaver.product.ce.product ^
-data %workspacePath% ^
-web-config conf/cloudbeaver.conf ^
-nl en ^
-registryMultiLanguage
java -jar %launcherJar% -product io.cloudbeaver.product.ce.product -web-config conf/cloudbeaver.conf -nl en -registryMultiLanguage -vmargs -Xmx2048M
+3 -34
View File
@@ -1,40 +1,9 @@
#!/bin/bash
launcherJar=( server/plugins/org.jkiss.dbeaver.launcher*.jar )
launcherJar=( server/plugins/org.eclipse.equinox.launcher*.jar )
echo "Starting Cloudbeaver Server"
[ ! -d "workspace/.metadata" ] && mkdir -p workspace/.metadata \
&& mkdir -p workspace/GlobalConfiguration/.dbeaver \
&& [ ! -f "workspace/GlobalConfiguration/.dbeaver/data-sources.json" ] \
&& cp conf/initial-data-sources.conf workspace/GlobalConfiguration/.dbeaver/data-sources.json
[ ! -d "workspace/.metadata" ] && mkdir -p workspace/GlobalConfiguration/.dbeaver && cp conf/initial-data-sources.conf workspace/GlobalConfiguration/.dbeaver/data-sources.json
java ${JAVA_OPTS} \
-Dfile.encoding=UTF-8 \
--add-modules=ALL-SYSTEM \
--add-opens=java.base/java.io=ALL-UNNAMED \
--add-opens=java.base/java.lang=ALL-UNNAMED \
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
--add-opens=java.base/java.net=ALL-UNNAMED \
--add-opens=java.base/java.nio=ALL-UNNAMED \
--add-opens=java.base/java.nio.charset=ALL-UNNAMED \
--add-opens=java.base/java.text=ALL-UNNAMED \
--add-opens=java.base/java.time=ALL-UNNAMED \
--add-opens=java.base/java.util=ALL-UNNAMED \
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED \
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.vm=ALL-UNNAMED \
--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED \
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED \
--add-opens=java.base/sun.security.ssl=ALL-UNNAMED \
--add-opens=java.base/sun.security.action=ALL-UNNAMED \
--add-opens=java.base/sun.security.util=ALL-UNNAMED \
--add-opens=java.security.jgss/sun.security.jgss=ALL-UNNAMED \
--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED \
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED \
--add-opens=java.sql/java.sql=ALL-UNNAMED \
-jar ${launcherJar} \
-product io.cloudbeaver.product.ce.product \
-web-config conf/cloudbeaver.conf \
-nl en \
-registryMultiLanguage
java -jar ${launcherJar} -product io.cloudbeaver.product.ce.product -web-config conf/cloudbeaver.conf -nl en -registryMultiLanguage -vmargs -Xmx2048M
-4
View File
@@ -1,4 +0,0 @@
{
"projects": ["../dbeaver-common", "../dbeaver", "../cloudbeaver/server"],
"targetPlatform": "./org.jkiss.cloudbeaver.tp.target"
}
-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="org.jkiss.tp.cloudbeaver">
<locations>
<location path="../eclipse/Eclipse.app/Contents/Eclipse/plugins" type="Directory"/>
<location path="../eclipse/eclipse/plugins" type="Directory"/>
</locations>
</target>
-2
View File
@@ -1,2 +0,0 @@
dbeaver-common
dbeaver
+55
View File
@@ -0,0 +1,55 @@
{
server: {
serverPort: 8978,
workspaceLocation: "workspace",
contentRoot: "web",
driversLocation: "drivers",
rootURI: "/",
serviceURI: "/dbeaver/",
productConfiguration: "conf/product.conf",
expireSessionAfterPeriod: 1800000,
develMode: false,
database: {
driver="h2_embedded",
url: "jdbc:h2:${workspace}/.data/cb.h2.dat",
createDatabase: true,
initialDataConfiguration: "conf/initial-data.conf",
pool: {
minIdleConnections: 4,
maxIdleConnections: 10,
maxConnections: 100,
validationQuery: "SELECT 1"
}
}
},
app: {
anonymousAccessEnabled: true,
authenticationEnabled: true,
anonymousUserRole: "user",
supportsCustomConnections: false
/*
enabledDrivers: [
"postgresql:postgres-jdbc",
"mysql:mysql8",
"mysql:mariaDB",
"generic:sqlite_jdbc",
"generic:derby_server",
"generic:h2_embedded",
"jaybird:jaybird",
]
*/
}
}
@@ -0,0 +1,16 @@
{
roles: [
{
roleId: "admin",
name: "Admin",
description: "Administrative access. Has all permissions.",
permissions: [ "public", "admin" ]
},
{
roleId: "user",
name: "User",
description: "Standard user.",
permissions: [ "public" ]
}
]
}
+25
View File
@@ -0,0 +1,25 @@
// Product configuration. Customized web application behavior
// It is in JSONC format
{
// Global properties
core: {
// User defaults
user: {
defaultTheme: "light",
defaultLanguage: "en"
},
app: {
// Log viewer config
logViewer: {
refreshTimeout: 3000,
logBatchSize: 1000,
maxLogRecords: 2000,
maxFailedRequests: 3
}
}
},
// Notifications config
core_events: {
notificationsPool: 5
}
}
-9
View File
@@ -1,9 +0,0 @@
projects:
schema:
include: ./**/*.graphqls
schema: "gql.ce"
extensions:
endpoints:
Default GraphQL Endpoint:
url: http://localhost:8080/api/gql
introspect: false
@@ -0,0 +1,22 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Vendor: %Bundle-Vendor
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: io.cloudbeaver.connect.provider.sample;singleton:=true
Bundle-Version: 1.0.15.qualifier
Bundle-Release-Date: 20201019
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.expressions,
org.apache.commons.logging,
org.eclipse.core.commands,
org.eclipse.core.resources,
io.cloudbeaver.server,
com.google.gson,
org.jkiss.bundle.graphql.java,
org.jkiss.dbeaver.model,
org.jkiss.dbeaver.model.sql
Bundle-Localization: OSGI-INF/l10n/bundle
Automatic-Module-Name: io.cloudbeaver.connect.provider.sample
@@ -0,0 +1,2 @@
Bundle-Vendor = DBeaver Corp
Bundle-Name = Cloudbeaver - Connections configuration - Sample
@@ -0,0 +1,6 @@
source.. = src/
output.. = target/classes/
bin.includes = .,\
META-INF/,\
OSGI-INF/,\
plugin.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension point="org.jkiss.dbeaver.dataSourceStorage">
<storage id="sample" name="Sample configuration storage" description="Preconfigured sample connection set" class="io.cloudbeaver.connect.provider.sample.SampleDataSourceConfigurationStorage">
</storage>
</extension>
</plugin>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.cloudbeaver</groupId>
<artifactId>bundles</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>io.cloudbeaver.connect.provider.sample</artifactId>
<version>1.0.15-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
@@ -0,0 +1,87 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2020 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.connect.provider.sample;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBPDataSourceConfigurationStorage;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.app.DBPDataSourceRegistry;
import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* Sample configuration storage.
* Is the main source of data in web application
*/
public class SampleDataSourceConfigurationStorage implements DBPDataSourceConfigurationStorage {
private static final Log log = Log.getLog(SampleDataSourceConfigurationStorage.class);
public static final String SAMPLE_CONFIG_NAME = "provided-connections.json";
@Override
public String getStorageId() {
return "Sample";
}
@Override
public boolean isValid() {
return false;
}
@Override
public boolean isDefault() {
return false;
}
@Override
public boolean isDynamic() {
return false;
}
@Override
public String getStatus() {
return "Valid";
}
@Override
public List<? extends DBPDataSourceContainer> loadDataSources(DBPDataSourceRegistry registry, Map<String, Object> options) throws DBException {
File metadataFolder = registry.getProject().getMetadataFolder(false);
if (metadataFolder.exists()) {
File sampleConfigFile = new File(metadataFolder, SAMPLE_CONFIG_NAME);
if (sampleConfigFile.exists()) {
log.debug("Loading provided connections from [" + sampleConfigFile.getAbsolutePath() + "]");
List<? extends DBPDataSourceContainer> dsList = registry.loadDataSourcesFromFile(this, sampleConfigFile);
// for (DBPDataSourceContainer ds : dsList) {
// log.debug("\tProvided connection: " + ds.getName());
// }
return dsList;
}
}
return Collections.emptyList();
}
@Override
public String getConfigurationFileSuffix() {
return "-sample";
}
}
@@ -1,46 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Vendor: DBeaver Corp
Bundle-Name: Cloudbeaver Web Model
Bundle-SymbolicName: io.cloudbeaver.model;singleton:=true
Bundle-Version: 1.0.49.qualifier
Bundle-Release-Date: 20240325
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Require-Bundle: org.jkiss.dbeaver.data.gis;visibility:=reexport,
org.jkiss.dbeaver.model;visibility:=reexport,
org.jkiss.dbeaver.model.sm;visibility:=reexport,
org.jkiss.dbeaver.model.event;visibility:=reexport,
org.jkiss.dbeaver.model.nio;visibility:=reexport,
org.jkiss.dbeaver.registry;visibility:=reexport,
org.jkiss.dbeaver.net.ssh,
org.jkiss.bundle.graphql.java;visibility:=reexport,
org.jkiss.bundle.apache.dbcp,
com.google.gson;visibility:=reexport,
jakarta.servlet;visibility:=reexport
Export-Package: io.cloudbeaver,
io.cloudbeaver.auth,
io.cloudbeaver.auth.provider,
io.cloudbeaver.auth.provider.local,
io.cloudbeaver.auth.provisioning,
io.cloudbeaver.websocket,
io.cloudbeaver.model,
io.cloudbeaver.model.app,
io.cloudbeaver.model.fs,
io.cloudbeaver.model.rm,
io.cloudbeaver.model.rm.local,
io.cloudbeaver.model.rm.lock,
io.cloudbeaver.model.session,
io.cloudbeaver.model.user,
io.cloudbeaver.model.utils,
io.cloudbeaver.registry,
io.cloudbeaver.server,
io.cloudbeaver.service,
io.cloudbeaver.service.admin,
io.cloudbeaver.service.security,
io.cloudbeaver.service.sql,
io.cloudbeaver.utils,
io.cloudbeaver.utils.file
Automatic-Module-Name: io.cloudbeaver.model
Import-Package: org.slf4j
@@ -1,6 +0,0 @@
source.. = src/
output.. = target/classes/
bin.includes = .,\
META-INF/,\
plugin.xml,\
schema/
@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension-point id="io.cloudbeaver.service" name="Web services" schema="schema/io.cloudbeaver.service.exsd"/>
<extension-point id="io.cloudbeaver.feature" name="Web features" schema="schema/io.cloudbeaver.feature.exsd"/>
<extension-point id="io.cloudbeaver.valueSerializer" name="Web value serializers" schema="schema/io.cloudbeaver.valueSerializer.exsd"/>
<extension-point id="org.jkiss.dbeaver.auth.provider" name="%extension-point.org.jkiss.dbeaver.authProvider.name" schema="schema/org.jkiss.dbeaver.authProvider.exsd"/>
<extension-point id="io.cloudbeaver.metaParameters" name="Meta parameters" schema="schema/io.cloudbeaver.metaParameters.exsd"/>
<extension-point id="io.cloudbeaver.rm.file.handler" name="RM file operations handler"
schema="schema/io.cloudbeaver.rmFileHandler.exsd"/>
<extension point="io.cloudbeaver.metaParameters">
<metaParameters type="user">
<propertyGroup label="Main">
<property id="firstName" label="First Name" type="string" description="User first name"/>
<property id="lastName" label="Last Name" type="string" description="User last name"/>
</propertyGroup>
</metaParameters>
</extension>
<extension point="com.dbeaver.secretController">
<controller id="void-secret" class="io.cloudbeaver.model.app.VoidSecretController"
label="Default secret controller" description="Default void secret controller"/>
</extension>
</plugin>
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.cloudbeaver</groupId>
<artifactId>bundles</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>io.cloudbeaver.model</artifactId>
<version>1.0.49-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
@@ -1,34 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<schema targetNamespace="org.jkiss.dbeaver.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="io.cloudbeaver.model" id="io.cloudbeaver.feature" name="Web features"/>
</appInfo>
<documentation>
Web feature
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence>
<element ref="feature"/>
</sequence>
</complexType>
</element>
<element name="feature">
<annotation>
<documentation>
Web service description
</documentation>
</annotation>
</element>
</schema>
@@ -1,28 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<schema targetNamespace="org.jkiss.dbeaver.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="io.cloudbeaver.model" id="io.cloudbeaver.metaParameters" name="Subject meta parameters"/>
</appInfo>
<documentation>
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
</element>
<element name="driver">
<annotation>
<documentation>
Web service description
</documentation>
</annotation>
</element>
</schema>
@@ -1,11 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<schema targetNamespace="org.jkiss.dbeaver.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="io.cloudbeaver.rm.file.handler" id="io.cloudbeaver.rm.file.handler" name="RM file operations handler"/>
</appInfo>
<documentation>
RM file operations handler
</documentation>
</annotation>
</schema>
@@ -1,34 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<schema targetNamespace="org.jkiss.dbeaver.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="io.cloudbeaver.server" id="io.cloudbeaver.valueSerializer" name="Web value serializers"/>
</appInfo>
<documentation>
DBeaver web value serializers
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence>
<element ref="serializer"/>
</sequence>
</complexType>
</element>
<element name="serializer">
<annotation>
<documentation>
DBeaver web value serializer
</documentation>
</annotation>
</element>
</schema>
@@ -1,47 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<schema targetNamespace="org.jkiss.dbeaver.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="io.cloudbeaver.model" id="org.jkiss.dbeaver.auth.provider" name="Authentication provider"/>
</appInfo>
<documentation>
DBeaver auth provider
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
</element>
<element name="model">
<annotation>
<documentation>
Data source auth model description
</documentation>
</annotation>
</element>
<annotation>
<appInfo>
<meta.section type="appInfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>
@@ -1,163 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver;
import org.eclipse.core.resources.IProject;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.app.DBPWorkspace;
import org.jkiss.dbeaver.model.auth.SMSessionContext;
import org.jkiss.dbeaver.model.rm.RMController;
import org.jkiss.dbeaver.model.rm.RMControllerProvider;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.model.rm.RMUtils;
import org.jkiss.dbeaver.registry.BaseProjectImpl;
import org.jkiss.utils.CommonUtils;
import org.jkiss.utils.Pair;
import java.nio.file.Path;
import java.util.Collection;
public class BaseWebProjectImpl extends BaseProjectImpl implements RMControllerProvider {
@NotNull
private final RMProject project;
@NotNull
private final Path path;
@NotNull
protected final DataSourceFilter dataSourceFilter;
private final RMController resourceController;
public BaseWebProjectImpl(
@NotNull DBPWorkspace workspace,
@NotNull RMController resourceController,
@NotNull SMSessionContext sessionContext,
@NotNull RMProject project,
@NotNull DataSourceFilter dataSourceFilter
) {
super(workspace, sessionContext);
this.resourceController = resourceController;
this.path = RMUtils.getProjectPath(project);
this.project = project;
this.dataSourceFilter = dataSourceFilter;
}
@NotNull
public RMController getResourceController() {
return resourceController;
}
@NotNull
@Override
public RMProject getRMProject() {
return project;
}
@Override
public boolean isVirtual() {
return true;
}
@NotNull
@Override
public String getName() {
return project.getDisplayName();
}
@NotNull
@Override
public String getId() {
return project.getId();
}
@NotNull
@Override
public Path getAbsolutePath() {
return path;
}
@Nullable
@Override
public IProject getEclipseProject() {
return null;
}
@Override
public boolean isOpen() {
return true;
}
@Override
public void ensureOpen() {
}
@Override
public boolean isUseSecretStorage() {
return false;
}
@NotNull
public RMProject getRmProject() {
return this.project;
}
/**
* Method for Bulk Update of resources properties paths
*
* @param oldToNewPaths collection of OldPath to NewPath pairs
*/
public void moveResourcePropertiesBatch(@NotNull Collection<Pair<String, String>> oldToNewPaths) {
loadMetadata();
synchronized (metadataSync) {
for (var pathsPair : oldToNewPaths) {
final var oldResourcePath = CommonUtils.normalizeResourcePath(pathsPair.getFirst());
final var newResourcePath = CommonUtils.normalizeResourcePath(pathsPair.getSecond());
final var resProps = resourceProperties.remove(oldResourcePath);
if (resProps != null) {
resourceProperties.put(newResourcePath, resProps);
}
}
}
flushMetadata();
}
/**
* Method for Bulk Remove of resources properties
*/
public boolean resetResourcesPropertiesBatch(@NotNull Collection<String> resourcesPaths) {
loadMetadata();
boolean propertiesChanged = false;
synchronized (metadataSync) {
for (var resourcePath : resourcesPaths) {
var removedProperties = resourceProperties.remove(CommonUtils.normalizeResourcePath(resourcePath));
if (removedProperties != null) {
propertiesChanged = true;
}
}
}
if (propertiesChanged) {
flushMetadata();
}
return propertiesChanged;
}
public Path getMetadataFilePath() {
return getMetadataPath().resolve(METADATA_STORAGE_FILE);
}
}
@@ -1,46 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver;
import org.jkiss.dbeaver.model.access.DBAPermissionRealm;
import org.jkiss.dbeaver.model.rm.RMConstants;
/**
* General constants
*/
public interface DBWConstants {
String PERMISSION_ADMIN = DBAPermissionRealm.PERMISSION_ADMIN;
String PERMISSION_CONFIGURATION_MANAGER = RMConstants.PERMISSION_CONFIGURATION_MANAGER;
String PERMISSION_PRIVATE_PROJECT_ACCESS = "private-project-access";
String PERMISSION_SECRET_MANAGER = "secret-manager";
String PERMISSION_EDIT_STRUCTURE = "edit-meta";
String PERMISSION_EDIT_DATA = "edit-data";
String STATE_ATTR_SIGN_IN_STATE = "state.signin";
enum SignInState {
GLOBAL,
EMBEDDED
}
//public static final String PERMISSION_USER = "user";
}
@@ -1,39 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.DBPImage;
/**
* Web feature
*/
public interface DBWFeatureSet {
@NotNull
String getId();
@NotNull
String getLabel();
String getDescription();
DBPImage getIcon();
boolean isEnabled();
}
@@ -1,94 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* User identity provided by auth provider.
*/
public class DBWUserIdentity {
@NotNull
private final String id;
@NotNull
private final String displayName;
private final Map<String, String> metaParameters = new LinkedHashMap<>();
@Nullable
private String providedUserRole;
@Nullable
private String[] providedTeamIds;
public DBWUserIdentity(@NotNull String id, @NotNull String displayName) {
this(id, displayName, Map.of());
}
public DBWUserIdentity(
@NotNull String id,
@NotNull String displayName,
@NotNull Map<String, String> metaParameters
) {
this.id = id;
this.displayName = displayName;
this.metaParameters.putAll(metaParameters);
}
@NotNull
public String getId() {
return id;
}
@NotNull
public String getDisplayName() {
return displayName;
}
@NotNull
public Map<String, String> getMetaParameters() {
return Map.copyOf(metaParameters);
}
public void setMetaParameter(@NotNull String name, @Nullable String value) {
if (value == null) {
metaParameters.remove(name);
} else {
metaParameters.put(name, value);
}
}
@Nullable
public String getProvidedUserRole() {
return providedUserRole;
}
public void setProvidedUserRole(@Nullable String providedUserRole) {
this.providedUserRole = providedUserRole;
}
@Nullable
public String[] getProvidedTeamIds() {
return providedTeamIds;
}
public void setProvidedTeamIds(@Nullable String[] providedTeamIds) {
this.providedTeamIds = providedTeamIds;
}
}
@@ -1,31 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
@FunctionalInterface
public interface DataSourceFilter {
/**
* Filter datasource from registry
*
* @param dataSourceContainer
* @return true if datasource accessible
*/
boolean filter(DBPDataSourceContainer dataSourceContainer);
}
@@ -1,363 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.*;
import org.jkiss.dbeaver.model.access.DBAAuthProfile;
import org.jkiss.dbeaver.model.access.DBACredentialsProvider;
import org.jkiss.dbeaver.model.app.DBPDataSourceRegistry;
import org.jkiss.dbeaver.model.app.DBPDataSourceRegistryCache;
import org.jkiss.dbeaver.model.app.DBPProject;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.connection.DBPDriver;
import org.jkiss.dbeaver.model.net.DBWNetworkProfile;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.secret.DBSSecretController;
import org.jkiss.dbeaver.model.struct.DBSObjectFilter;
import org.jkiss.dbeaver.registry.DataSourceConfigurationManager;
import org.jkiss.dbeaver.registry.DataSourcePersistentRegistry;
import org.jkiss.dbeaver.registry.DataSourceRegistry;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
public class WebDataSourceRegistryProxy implements DBPDataSourceRegistry, DataSourcePersistentRegistry, DBPDataSourceRegistryCache {
private final DataSourceFilter dataSourceFilter;
private final DataSourceRegistry dataSourceRegistry;
public WebDataSourceRegistryProxy(DataSourceRegistry dataSourceRegistry, DataSourceFilter filter) {
this.dataSourceRegistry = dataSourceRegistry;
this.dataSourceFilter = filter;
}
@NotNull
@Override
public DBPProject getProject() {
return dataSourceRegistry.getProject();
}
@Nullable
@Override
public DBPDataSourceContainer getDataSource(@NotNull String id) {
DBPDataSourceContainer dataSource = dataSourceRegistry.getDataSource(id);
if (dataSource == null || dataSourceFilter != null && !dataSourceFilter.filter(dataSource)) {
return null;
}
return dataSource;
}
@Nullable
@Override
public DBPDataSourceContainer getDataSource(@NotNull DBPDataSource dataSource) {
if (dataSourceFilter != null && !dataSourceFilter.filter(dataSource.getContainer())) {
return null;
}
return dataSourceRegistry.getDataSource(dataSource);
}
@Nullable
@Override
public DBPDataSourceContainer findDataSourceByName(String name) {
var dataSource = dataSourceRegistry.findDataSourceByName(name);
if (dataSource != null) {
if (dataSourceFilter == null || dataSourceFilter.filter(dataSource)) {
return dataSource;
}
}
return null;
}
@NotNull
@Override
public List<? extends DBPDataSourceContainer> getDataSourcesByProfile(@NotNull DBWNetworkProfile profile) {
return dataSourceRegistry.getDataSourcesByProfile(profile)
.stream()
.filter(dataSourceFilter::filter)
.collect(Collectors.toList());
}
@NotNull
@Override
public List<DBPDataSourceContainer> getDataSources() {
return dataSourceRegistry.getDataSources()
.stream()
.filter(dataSourceFilter::filter)
.collect(Collectors.toList());
}
@NotNull
@Override
public DBPDataSourceContainer createDataSource(@NotNull DBPDriver driver, @NotNull DBPConnectionConfiguration connConfig) {
return dataSourceRegistry.createDataSource(driver, connConfig);
}
@NotNull
@Override
public DBPDataSourceContainer createDataSource(@NotNull DBPDataSourceContainer source) {
return dataSourceRegistry.createDataSource(source);
}
@Override
public void addDataSourceListener(@NotNull DBPEventListener listener) {
dataSourceRegistry.addDataSourceListener(listener);
}
@Override
public boolean removeDataSourceListener(@NotNull DBPEventListener listener) {
return dataSourceRegistry.removeDataSourceListener(listener);
}
@Override
public void addDataSource(@NotNull DBPDataSourceContainer dataSource) throws DBException {
dataSourceRegistry.addDataSource(dataSource);
}
@Override
public void removeDataSource(@NotNull DBPDataSourceContainer dataSource) {
dataSourceRegistry.removeDataSource(dataSource);
}
@Override
public void addDataSourceToList(@NotNull DBPDataSourceContainer dataSource) {
dataSourceRegistry.addDataSourceToList(dataSource);
}
@Override
public void removeDataSourceFromList(@NotNull DBPDataSourceContainer dataSource) {
dataSourceRegistry.removeDataSourceFromList(dataSource);
}
@Override
public void updateDataSource(@NotNull DBPDataSourceContainer dataSource) throws DBException {
dataSourceRegistry.updateDataSource(dataSource);
}
@NotNull
@Override
public List<? extends DBPDataSourceFolder> getAllFolders() {
return dataSourceRegistry.getAllFolders();
}
@NotNull
@Override
public List<? extends DBPDataSourceFolder> getRootFolders() {
return dataSourceRegistry.getRootFolders();
}
@Nullable
@Override
public DBPDataSourceFolder getFolder(@NotNull String path) {
return dataSourceRegistry.getFolder(path);
}
@NotNull
@Override
public DBPDataSourceFolder addFolder(@Nullable DBPDataSourceFolder parent, @NotNull String name) {
return dataSourceRegistry.addFolder(parent, name);
}
@Override
public void removeFolder(@NotNull DBPDataSourceFolder folder, boolean dropContents) {
dataSourceRegistry.removeFolder(folder, dropContents);
}
@Override
public void moveFolder(@NotNull String oldPath, @NotNull String newPath) {
dataSourceRegistry.moveFolder(oldPath, newPath);
}
@Nullable
@Override
public DBSObjectFilter getSavedFilter(String name) {
return dataSourceRegistry.getSavedFilter(name);
}
@NotNull
@Override
public List<DBSObjectFilter> getSavedFilters() {
return dataSourceRegistry.getSavedFilters();
}
@Override
public void updateSavedFilter(@NotNull DBSObjectFilter filter) {
dataSourceRegistry.updateSavedFilter(filter);
}
@Override
public void removeSavedFilter(@NotNull String filterName) {
dataSourceRegistry.removeSavedFilter(filterName);
}
@Nullable
@Override
public DBWNetworkProfile getNetworkProfile(@Nullable String source, @NotNull String name) {
return dataSourceRegistry.getNetworkProfile(source, name);
}
@NotNull
@Override
public List<DBWNetworkProfile> getNetworkProfiles() {
return dataSourceRegistry.getNetworkProfiles();
}
@Override
public void updateNetworkProfile(@NotNull DBWNetworkProfile profile) {
dataSourceRegistry.updateNetworkProfile(profile);
}
@Override
public void removeNetworkProfile(@NotNull DBWNetworkProfile profile) {
dataSourceRegistry.removeNetworkProfile(profile);
}
@Nullable
@Override
public DBAAuthProfile getAuthProfile(@NotNull String id) {
return dataSourceRegistry.getAuthProfile(id);
}
@NotNull
@Override
public List<DBAAuthProfile> getAllAuthProfiles() {
return dataSourceRegistry.getAllAuthProfiles();
}
@NotNull
@Override
public List<DBAAuthProfile> getApplicableAuthProfiles(@Nullable DBPDriver driver) {
return dataSourceRegistry.getApplicableAuthProfiles(driver);
}
@Override
public void updateAuthProfile(@NotNull DBAAuthProfile profile) {
dataSourceRegistry.updateAuthProfile(profile);
}
@Override
public void setAuthProfiles(@NotNull Collection<DBAAuthProfile> profiles) {
dataSourceRegistry.setAuthProfiles(profiles);
}
@Override
public void removeAuthProfile(DBAAuthProfile profile) {
dataSourceRegistry.removeAuthProfile(profile);
}
@Override
public void flushConfig() {
dataSourceRegistry.flushConfig();
}
@Override
public void refreshConfig() {
dataSourceRegistry.refreshConfig();
}
@Override
public void refreshConfig(@Nullable Collection<String> dataSourceIds) {
dataSourceRegistry.refreshConfig(dataSourceIds);
}
@Nullable
@Override
public Throwable getLastError() {
return dataSourceRegistry.getLastError();
}
@Override
public boolean hasError() {
return dataSourceRegistry.hasError();
}
@Override
public void checkForErrors() throws DBException {
dataSourceRegistry.checkForErrors();
}
@Override
public void notifyDataSourceListeners(@NotNull DBPEvent event) {
dataSourceRegistry.notifyDataSourceListeners(event);
}
@Nullable
@Override
public DBACredentialsProvider getAuthCredentialsProvider() {
return dataSourceRegistry.getAuthCredentialsProvider();
}
@Override
public void dispose() {
dataSourceRegistry.dispose();
}
@Override
public void setAuthCredentialsProvider(DBACredentialsProvider authCredentialsProvider) {
dataSourceRegistry.setAuthCredentialsProvider(authCredentialsProvider);
}
@NotNull
@Override
public Set<DBPDataSourceFolder> getTemporaryFolders() {
return dataSourceRegistry.getTemporaryFolders();
}
@Override
public boolean loadDataSources(
@NotNull List<DBPDataSourceConfigurationStorage> storages,
@NotNull DataSourceConfigurationManager manager,
@Nullable Collection<String> dataSourceIds, boolean refresh,
boolean purgeUntouched
) {
return dataSourceRegistry.loadDataSources(storages, manager, dataSourceIds, refresh, purgeUntouched);
}
@Override
public void saveDataSources() {
dataSourceRegistry.saveDataSources();
}
@Override
public DataSourceConfigurationManager getConfigurationManager() {
return dataSourceRegistry.getConfigurationManager();
}
@Override
public void saveConfigurationToManager(
@NotNull DBRProgressMonitor monitor,
@NotNull DataSourceConfigurationManager configurationManager,
@Nullable Predicate<DBPDataSourceContainer> filter
) {
dataSourceRegistry.saveConfigurationToManager(monitor, configurationManager, filter);
}
@Override
public void persistSecrets(DBSSecretController secretController) throws DBException {
dataSourceRegistry.persistSecrets(secretController);
}
@Override
public void resolveSecrets(DBSSecretController secretController) throws DBException {
dataSourceRegistry.resolveSecrets(secretController);
}
}
@@ -1,28 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver;
import org.jkiss.dbeaver.model.DBPPage;
import org.jkiss.dbeaver.model.data.json.JSONUtils;
import java.util.Map;
public class WebPage extends DBPPage {
public WebPage(Map<String, Object> params) {
super(JSONUtils.getInteger(params, "offset"), JSONUtils.getInteger(params, "limit"));
}
}
@@ -1,78 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.app.DBPDataSourceRegistry;
import org.jkiss.dbeaver.model.app.DBPWorkspace;
import org.jkiss.dbeaver.model.auth.SMSessionContext;
import org.jkiss.dbeaver.model.rm.RMController;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.registry.rm.DataSourceRegistryRM;
import org.jkiss.dbeaver.runtime.DBWorkbench;
public abstract class WebProjectImpl extends BaseWebProjectImpl {
private static final Log log = Log.getLog(WebProjectImpl.class);
public WebProjectImpl(
@NotNull DBPWorkspace workspace,
@NotNull RMController resourceController,
@NotNull SMSessionContext sessionContext,
@NotNull RMProject project,
@NotNull DataSourceFilter dataSourceFilter
) {
super(workspace, resourceController, sessionContext, project, dataSourceFilter);
}
@Nullable
@Override
public Object getProjectProperty(String propName) {
try {
return getResourceController().getProjectProperty(getId(), propName);
} catch (DBException e) {
log.error("Cannot get project property", e);
return null;
}
}
@Override
public void setProjectProperty(@NotNull String propName, @Nullable Object propValue) {
try {
getResourceController().setProjectProperty(getId(), propName, propValue);
} catch (DBException e) {
log.error("Cannot set project property", e);
}
}
@Override
public boolean isUseSecretStorage() {
return DBWorkbench.isDistributed();
}
@NotNull
@Override
protected DBPDataSourceRegistry createDataSourceRegistry() {
return new WebDataSourceRegistryProxy(
new DataSourceRegistryRM(this, getResourceController()),
dataSourceFilter
);
}
}
@@ -1,39 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver;
import io.cloudbeaver.model.session.WebSession;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.navigator.DBNModel;
import org.jkiss.dbeaver.model.rm.RMProject;
public class WebSessionProjectImpl extends WebProjectImpl {
private final WebSession webSession;
public WebSessionProjectImpl(@NotNull WebSession webSession, @NotNull RMProject project, @NotNull DataSourceFilter dataSourceFilter) {
super(webSession.getWorkspace(), webSession.getRmController(), webSession.getSessionContext(), project, dataSourceFilter);
this.webSession = webSession;
}
@Nullable
@Override
public DBNModel getNavigatorModel() {
return webSession.getNavigatorModel();
}
}
@@ -1,31 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.auth;
public interface CBAuthConstants {
String CB_AUTH_ID_COOKIE_NAME = "cb-auth-id";
String CB_REDIRECT_URL_COOKIE_NAME = "cb-redirect-url";
String CB_AUTH_ID_REQUEST_PARAM = "authId";
String CB_AUTO_LOGIN_REQUEST_PARAM = "autoLogin";
String CB_REDIRECT_URL_REQUEST_PARAM = "redirectUrl";
// Default max idle time (10 minutes)
long MAX_SESSION_IDLE_TIME = 10 * 60 * 1000;
}
@@ -1,30 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.auth;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.auth.SMCredentials;
import org.jkiss.dbeaver.model.auth.SMCredentialsProvider;
public class NoAuthCredentialsProvider implements SMCredentialsProvider {
@Nullable
@Override
public SMCredentials getActiveUserCredentials() {
return null;
}
}
@@ -1,41 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.auth;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.security.SMAuthProviderCustomConfiguration;
import java.util.Map;
/**
* Auth
* Authenticates user using external user identity
*/
public interface SMAuthProviderAssigner {
@NotNull
SMAutoAssign detectAutoAssignments(
@NotNull DBRProgressMonitor monitor,
@NotNull SMAuthProviderCustomConfiguration providerConfig,
@NotNull Map<String, Object> authParameters
) throws DBException;
String getExternalTeamIdMetadataFieldName();
}
@@ -1,72 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.auth;
import io.cloudbeaver.DBWUserIdentity;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.model.user.WebUser;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPObject;
import org.jkiss.dbeaver.model.auth.SMAuthProvider;
import org.jkiss.dbeaver.model.auth.SMSession;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.security.SMAuthProviderCustomConfiguration;
import java.util.Map;
/**
* External auth provider.
* Authenticates user using external user identity
*/
public interface SMAuthProviderExternal<AUTH_SESSION extends SMSession> extends SMAuthProvider<AUTH_SESSION> {
/**
* Returns new identifying credentials which can be used to find/create user in database
*/
@NotNull
default Map<String, Object> authExternalUser(
@NotNull DBRProgressMonitor monitor,
@Nullable SMAuthProviderCustomConfiguration providerConfig, // Auth provider configuration (e.g. 3rd party auth server address)
@NotNull Map<String, Object> authParameters // Passed auth parameters (e.g. user name or password)
) throws DBException {
return authParameters;
}
@NotNull
DBWUserIdentity getUserIdentity(
@NotNull DBRProgressMonitor monitor,
@Nullable SMAuthProviderCustomConfiguration customConfiguration,
@NotNull Map<String, Object> authParameters) throws DBException;
/**
* Get specified user details.
* @param user user
* @param selfIdentity true if users tries to get information about itself.
* Otherwise it is information for supervisor.
*/
@Nullable
DBPObject getUserDetails(
@NotNull DBRProgressMonitor monitor,
@NotNull WebSession webSession,
@NotNull AUTH_SESSION session,
@NotNull WebUser user,
boolean selfIdentity) throws DBException;
}
@@ -1,54 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.auth;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.security.SMAuthProviderCustomConfiguration;
import java.util.Map;
/**
* Federated auth provider.
* Provides links to external auth resource
*/
public interface SMAuthProviderFederated extends SMSignOutLinkProvider {
@NotNull
String getSignInLink(String id, @NotNull Map<String, Object> providerConfig) throws DBException;
@Override
default String getUserSignOutLink(
@NotNull SMAuthProviderCustomConfiguration providerConfig,
@NotNull Map<String, Object> userCredentials
) throws DBException {
return getCommonSignOutLink(providerConfig.getId(), providerConfig.getParameters());
}
@Nullable
String getMetadataLink(String id, @NotNull Map<String, Object> providerConfig) throws DBException;
@Nullable
String getAcsLink(String id, @NotNull Map<String, Object> providerConfig) throws DBException;
@Nullable
default String getRedirectLink(String id, @NotNull Map<String, Object> providerConfig) throws DBException {
return null;
}
}
@@ -1,50 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.auth;
import java.util.ArrayList;
import java.util.List;
public class SMAutoAssign {
private String authRole;
private List<String> externalTeamIds = new ArrayList<>();
public SMAutoAssign() {
}
public SMAutoAssign(String authRole, List<String> externalRolesIds) {
this.authRole = authRole;
this.externalTeamIds = externalRolesIds;
}
public String getAuthRole() {
return authRole;
}
public void setAuthRole(String authRole) {
this.authRole = authRole;
}
public List<String> getExternalTeamIds() {
return externalTeamIds;
}
public void addExternalTeamId(String externalRoleId) {
this.externalTeamIds.add(externalRoleId);
}
}
@@ -1,25 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.auth;
import org.jkiss.code.NotNull;
import java.util.Map;
public interface SMBruteForceProtected {
Object getInputUsername(@NotNull Map<String, Object> cred);
}
@@ -1,37 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.auth;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.security.SMAuthProviderCustomConfiguration;
import java.util.Map;
public interface SMSignOutLinkProvider {
/**
* @return a common link for logout, not related with the user context
*/
@NotNull
String getCommonSignOutLink(String id, @NotNull Map<String, Object> providerConfig) throws DBException;
String getUserSignOutLink(
@NotNull SMAuthProviderCustomConfiguration providerConfig,
@NotNull Map<String, Object> userCredentials
) throws DBException;
}
@@ -1,37 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.auth;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.auth.SMCredentials;
import org.jkiss.dbeaver.model.auth.SMCredentialsProvider;
import java.util.Set;
public class SMTokenCredentialProvider implements SMCredentialsProvider {
private final String smAccessToken;
public SMTokenCredentialProvider(String smAccessToken) {
this.smAccessToken = smAccessToken;
}
@Nullable
@Override
public SMCredentials getActiveUserCredentials() {
return new SMCredentials(smAccessToken, null, null, Set.of());
}
}
@@ -1,40 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.auth.provider;
import io.cloudbeaver.auth.SMAuthProviderExternal;
import io.cloudbeaver.model.user.WebUser;
import org.jkiss.dbeaver.model.auth.SMSession;
import org.jkiss.utils.CommonUtils;
/**
* Abstract external auth provider
*/
public abstract class AbstractExternalAuthProvider<SESSION extends SMSession> implements SMAuthProviderExternal<SESSION> {
public static final String META_AUTH_PROVIDER = "$provider";
public static final String META_AUTH_SPACE_ID = "$space";
@Deprecated
protected void setUserOrigin(WebUser user, String type, String subType) {
user.setMetaParameter(META_AUTH_PROVIDER, type);
if (!CommonUtils.isEmpty(subType)) {
user.setMetaParameter(META_AUTH_SPACE_ID, subType);
}
}
}
@@ -1,25 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.auth.provider.local;
//TODO remove after CBDatabase refactoring
public class LocalAuthProviderConstants {
public static final String PROVIDER_ID = "local";
public static final String CRED_USER = "user";
public static final String CRED_PASSWORD = "password";
}
@@ -1,38 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.auth.provisioning;
import io.cloudbeaver.model.session.WebSession;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.security.SMAuthProviderCustomConfiguration;
import org.jkiss.dbeaver.model.security.user.SMUserProvisioning;
import java.util.List;
public interface SMProvisioner {
@NotNull
List<SMUserProvisioning> listExternalUsers(
@NotNull WebSession webSession,
@NotNull SMAuthProviderCustomConfiguration customConfiguration,
@NotNull SMProvisioningFilter filter
) throws DBException;
default boolean isAuthRoleProvided(SMAuthProviderCustomConfiguration configuration) {
return false;
}
}
@@ -1,28 +0,0 @@
package io.cloudbeaver.auth.provisioning;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.data.json.JSONUtils;
import java.util.Map;
public class SMProvisioningFilter {
@Nullable
private final Integer offset;
@Nullable
private final Integer limit;
public SMProvisioningFilter(Map<String, Object> params) {
this.offset = JSONUtils.getInteger(params, "offset");
this.limit = JSONUtils.getInteger(params, "limit");
}
@Nullable
public Integer getOffset() {
return offset;
}
@Nullable
public Integer getLimit() {
return limit;
}
}
@@ -1,30 +0,0 @@
package io.cloudbeaver.model;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.DBPDataSourceHandler;
import org.jkiss.dbeaver.model.connection.DBPDriver;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
public abstract class BaseDatasourceAccessCheckHandler implements DBPDataSourceHandler {
@Override
public void beforeConnect(
DBRProgressMonitor monitor,
@NotNull DBPDataSourceContainer dataSourceContainer
) throws DBException {
if (isDriverDisabled(dataSourceContainer.getDriver())) {
throw new DBException("Driver disabled");
}
}
@Override
public void beforeDisconnect(
DBRProgressMonitor monitor,
@NotNull DBPDataSourceContainer dataSourceContainer
) throws DBException {
}
protected abstract boolean isDriverDisabled(DBPDriver driver);
}
@@ -1,57 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model;
import io.cloudbeaver.model.session.WebSession;
import org.jkiss.dbeaver.model.DBPDataSourceFolder;
import org.jkiss.dbeaver.model.meta.Property;
public class WebConnectionFolderInfo {
private final String projectId;
private final WebSession session;
private final DBPDataSourceFolder dataSourceFolder;
public WebConnectionFolderInfo(WebSession session, DBPDataSourceFolder dataSourceFolder) {
this.session = session;
this.dataSourceFolder = dataSourceFolder;
this.projectId = dataSourceFolder.getDataSourceRegistry().getProject().getId();
}
public WebSession getSession() {
return session;
}
public DBPDataSourceFolder getDataSourceFolder() {
return dataSourceFolder;
}
@Property
public String getId() {
return dataSourceFolder.getFolderPath();
}
@Property
public String getProjectId() {
return projectId;
}
@Property
public String getDescription() {
return dataSourceFolder.getDescription();
}
}
@@ -1,459 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model;
import io.cloudbeaver.WebProjectImpl;
import io.cloudbeaver.model.app.BaseWebAppConfiguration;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.service.security.SMUtils;
import io.cloudbeaver.service.sql.WebDataFormat;
import io.cloudbeaver.utils.CBModelConstants;
import io.cloudbeaver.utils.WebAppUtils;
import io.cloudbeaver.utils.WebCommonUtils;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBConstants;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.DBPDataSourceFolder;
import org.jkiss.dbeaver.model.app.DBPProject;
import org.jkiss.dbeaver.model.connection.DBPAuthModelDescriptor;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.connection.DBPDriverConfigurationType;
import org.jkiss.dbeaver.model.impl.auth.AuthModelDatabaseNative;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.navigator.DBNBrowseSettings;
import org.jkiss.dbeaver.model.navigator.DBNDataSource;
import org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.preferences.DBPPropertySource;
import org.jkiss.dbeaver.model.rm.RMProjectPermission;
import org.jkiss.dbeaver.model.runtime.DBRRunnableParametrized;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.jkiss.utils.CommonUtils;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* Web connection info
*/
public class WebConnectionInfo {
private static final Log log = Log.getLog(WebConnectionInfo.class);
public static final String SECURED_VALUE = "********";
private final WebSession session;
private final DBPDataSourceContainer dataSourceContainer;
private WebServerError connectError;
private String connectTime;
private String serverVersion;
private String clientVersion;
private transient Map<String, Object> savedAuthProperties;
private transient List<WebNetworkHandlerConfigInput> savedNetworkCredentials;
private transient List<DBRRunnableParametrized<WebConnectionInfo>> closeListeners = null;
public WebConnectionInfo(WebSession session, DBPDataSourceContainer ds) {
this.session = session;
this.dataSourceContainer = ds;
}
public WebSession getSession() {
return session;
}
public DBPDataSourceContainer getDataSourceContainer() {
return dataSourceContainer;
}
public DBPDataSource getDataSource() {
return dataSourceContainer.getDataSource();
}
@Property
public String getId() {
return dataSourceContainer.getId();
}
@Property
public String getDriverId() {
return dataSourceContainer.getDriver().getFullId();
}
@Property
public String getName() {
return dataSourceContainer.getName();
}
@Property
public String getDescription() {
return dataSourceContainer.getDescription();
}
@Property
public String getHost() {
if (canViewReadOnlyConnections()) {
return dataSourceContainer.getConnectionConfiguration().getHostName();
}
return SECURED_VALUE;
}
@Property
public String getPort() {
if (canViewReadOnlyConnections()) {
return dataSourceContainer.getConnectionConfiguration().getHostPort();
}
return SECURED_VALUE;
}
@Property
public String getServerName() {
return dataSourceContainer.getConnectionConfiguration().getServerName();
}
@Property
public String getDatabaseName() {
if (canViewReadOnlyConnections()) {
return dataSourceContainer.getConnectionConfiguration().getDatabaseName();
}
return SECURED_VALUE;
}
@Property
public String getUrl() {
if (canViewReadOnlyConnections()) {
return dataSourceContainer.getConnectionConfiguration().getUrl();
}
return SECURED_VALUE;
}
@Property
public Map<String, String> getProperties() {
if (canViewReadOnlyConnections()) {
return dataSourceContainer.getConnectionConfiguration().getProperties();
}
return Collections.emptyMap();
}
@Property
public boolean isConnected() {
return dataSourceContainer.isConnected();
}
@Property
public boolean isTemplate() {
return dataSourceContainer.isTemplate();
}
@Property
public boolean isProvided() {
return dataSourceContainer.isProvided();
}
@Property
public boolean isReadOnly() {
return dataSourceContainer.isConnectionReadOnly();
}
@Property
public boolean isUseUrl() {
return CommonUtils.isEmpty(dataSourceContainer.getDriver().getSampleURL());
}
@Property
public boolean isSaveCredentials() {
return dataSourceContainer.isSavePassword();
}
@Property
public boolean isCredentialsSaved() throws DBException {
return dataSourceContainer.isCredentialsSaved();
}
@Property
public boolean isSharedCredentials() {
return dataSourceContainer.isSharedCredentials();
}
@Property
public String getFolder() {
DBPDataSourceFolder folder = dataSourceContainer.getFolder();
return folder == null ? null : folder.getFolderPath();
}
@Property
public String getNodePath() {
return DBNDataSource.makeDataSourceItemPath(dataSourceContainer);
}
@Property
public String getConnectTime() {
return dataSourceContainer.getConnectTime() == null ? null :
CBModelConstants.ISO_DATE_FORMAT.format(dataSourceContainer.getConnectTime().toInstant());
}
@Property
public WebServerError getConnectError() {
return connectError;
}
public void setConnectError(Throwable connectError) {
this.connectError = connectError == null ? null : new WebServerError(connectError);
}
public void setConnectTime(String connectTime) {
this.connectTime = connectTime;
}
@Property
public String getServerVersion() {
return serverVersion;
}
public void setServerVersion(String serverVersion) {
this.serverVersion = serverVersion;
}
@Property
public String getClientVersion() {
return clientVersion;
}
public void setClientVersion(String clientVersion) {
this.clientVersion = clientVersion;
}
@Property
public String[] getFeatures() {
List<String> features = new ArrayList<>();
if (dataSourceContainer.isConnected()) {
features.add("connected");
}
if (dataSourceContainer.isHidden()) {
features.add("virtual");
}
if (dataSourceContainer.isTemporary()) {
features.add("temporary");
}
if (dataSourceContainer.isConnectionReadOnly()) {
features.add("readOnly");
}
if (dataSourceContainer.isProvided()) {
features.add("provided");
}
if (dataSourceContainer.isManageable()) {
features.add("manageable");
}
return features.toArray(new String[0]);
}
@Property
public DBNBrowseSettings getNavigatorSettings() {
return dataSourceContainer.getNavigatorSettings();
}
@Property
public List<WebDataFormat> getSupportedDataFormats() {
List<WebDataFormat> formats = new ArrayList<>();
formats.add(WebDataFormat.resultset);
DBPDataSource dataSource = dataSourceContainer.getDataSource();
if (dataSource == null) {
return formats;
}
if (Boolean.TRUE.equals(dataSource.getDataSourceFeature(DBPDataSource.FEATURE_DOCUMENT_DATA_SOURCE))) {
formats.add(WebDataFormat.document);
}
return formats;
}
@Property
public WebConnectionOriginInfo getOrigin() {
return new WebConnectionOriginInfo(session, dataSourceContainer, dataSourceContainer.getOrigin());
}
@Property
public DBPDriverConfigurationType getConfigurationType() {
DBPDriverConfigurationType configurationType = dataSourceContainer.getConnectionConfiguration().getConfigurationType();
if (configurationType == null) {
configurationType = DBPDriverConfigurationType.MANUAL;
}
return configurationType;
}
@Property
public boolean isAuthNeeded() throws DBException {
return !dataSourceContainer.isConnected() &&
!(dataSourceContainer.isCredentialsSaved() || isAuthPropertiesEmpty()) &&
!dataSourceContainer.getDriver().isAnonymousAccess();
}
// we don't show non-secured properties in FE when connecting to DB without saved credentials
private boolean isAuthPropertiesEmpty() {
return Arrays.stream(getAuthProperties()).allMatch(f -> f.hasFeature(DBConstants.PROP_FEATURE_NON_SECURED));
}
@Property
public String getAuthModel() {
String authModelId = dataSourceContainer.getConnectionConfiguration().getAuthModelId();
if (CommonUtils.isEmpty(authModelId)) {
authModelId = AuthModelDatabaseNative.ID;
}
return authModelId;
}
@Property
public WebPropertyInfo[] getAuthProperties() {
String authModelId = getAuthModel();
DBPAuthModelDescriptor authModel = DBWorkbench.getPlatform().getDataSourceProviderRegistry().getAuthModel(authModelId);
if (authModel == null) {
return new WebPropertyInfo[0];
}
// Fill user provided credentials
DBPConnectionConfiguration configWithAuth = new DBPConnectionConfiguration(dataSourceContainer.getConnectionConfiguration());
// show all properties if it is a manual connection
Predicate<DBPPropertyDescriptor> predicate = CommonUtils.isEmpty(getRequiredAuth())
? p -> true
: p -> WebCommonUtils.isAuthPropertyApplicable(p, session.getContextCredentialsProviders());
DBPPropertySource credentialsSource = authModel.createCredentialsSource(dataSourceContainer, configWithAuth);
return Arrays.stream(credentialsSource.getProperties())
.filter(predicate)
.map(p -> new WebPropertyInfo(session, p, credentialsSource)).toArray(WebPropertyInfo[]::new);
}
@Property
public List<WebNetworkHandlerConfig> getNetworkHandlersConfig() {
return dataSourceContainer.getConnectionConfiguration().getHandlers().stream()
.map(WebNetworkHandlerConfig::new).collect(Collectors.toList());
}
@Property
public Map<String, Object> getCredentials() {
//dataSourceContainer.getConnectionConfiguration().getCredentialsProvider().getCredentials();
return null;
}
public Map<String, Object> getSavedAuthProperties() {
return savedAuthProperties;
}
public List<WebNetworkHandlerConfigInput> getSavedNetworkCredentials() {
return savedNetworkCredentials;
}
public void setSavedCredentials(Map<String, Object> authProperties, List<WebNetworkHandlerConfigInput> networkCredentials) {
this.savedAuthProperties = authProperties;
this.savedNetworkCredentials = networkCredentials;
}
public void clearCache() {
this.savedAuthProperties = null;
this.savedNetworkCredentials = null;
this.fireCloseListeners();
}
public void fireCloseListeners() {
if (closeListeners != null) {
for (DBRRunnableParametrized<WebConnectionInfo> listener : closeListeners) {
try {
listener.run(this);
} catch (Exception e) {
log.debug(e);
}
}
closeListeners = null;
}
}
@Property
public Map<String, String> getProviderProperties() {
return dataSourceContainer.getConnectionConfiguration().getProviderProperties();
}
@Override
public String toString() {
return "WebConnection:" + dataSourceContainer.toString();
}
@Property
public boolean isCanViewSettings() {
return canViewReadOnlyConnections();
}
@Property
public boolean isCanEdit() {
return hasProjectPermission(RMProjectPermission.DATA_SOURCES_EDIT);
}
@Property
public boolean isCanDelete() {
return isCanEdit();
}
@Property
public String getProjectId() {
return dataSourceContainer.getProject().getId();
}
@Property
public String getRequiredAuth() {
return dataSourceContainer.getRequiredExternalAuth();
}
private boolean hasProjectPermission(RMProjectPermission projectPermission) {
DBPProject project = dataSourceContainer.getProject();
if (!(project instanceof WebProjectImpl)) {
return false;
}
return SMUtils.hasProjectPermission(session, ((WebProjectImpl) project).getRmProject(), projectPermission);
}
private boolean canViewReadOnlyConnections() {
if (isCanEdit()) {
return true;
}
BaseWebAppConfiguration appConfig = (BaseWebAppConfiguration) WebAppUtils.getWebApplication().getAppConfiguration();
return appConfig.isShowReadOnlyConnectionInfo();
}
public void addCloseListener(DBRRunnableParametrized<WebConnectionInfo> listener) {
if (closeListeners == null) {
closeListeners = new ArrayList<>();
}
closeListeners.add(listener);
}
@Property
public int getKeepAliveInterval() {
return dataSourceContainer.getConnectionConfiguration().getKeepAliveInterval();
}
@Property
public List<WebSecretInfo> getSharedSecrets() throws DBException {
return dataSourceContainer.listSharedCredentials()
.stream()
.map(WebSecretInfo::new)
.collect(Collectors.toList());
}
}
@@ -1,91 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model;
import io.cloudbeaver.DBWebException;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.utils.WebCommonUtils;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.DBPDataSourceOrigin;
import org.jkiss.dbeaver.model.DBPObject;
import org.jkiss.dbeaver.model.meta.Property;
import java.util.Map;
/**
* Web connection origin info
*/
public class WebConnectionOriginInfo implements WebObjectOrigin {
private final WebSession session;
private final DBPDataSourceContainer dataSourceContainer;
private final DBPDataSourceOrigin origin;
public WebConnectionOriginInfo(WebSession session, DBPDataSourceContainer dataSourceContainer, DBPDataSourceOrigin origin) {
this.session = session;
this.dataSourceContainer = dataSourceContainer;
this.origin = origin;
}
@NotNull
@Override
public String getType() {
return origin.getType();
}
@Nullable
@Override
public String getSubType() {
return origin.getSubType();
}
@NotNull
@Override
public String getDisplayName() {
return origin.getDisplayName();
}
@Nullable
@Override
public String getIcon() {
return WebCommonUtils.makeIconId(origin.getIcon());
}
@NotNull
@Override
public Map<String, Object> getConfiguration() {
return origin.getDataSourceConfiguration();
}
@Property
@Override
public WebPropertyInfo[] getDetails() throws DBWebException {
try {
DBPObject details = origin.getObjectDetails(session.getProgressMonitor(), session.getSessionContext(), dataSourceContainer);
if (details == null) {
return new WebPropertyInfo[0];
}
return WebCommonUtils.getObjectProperties(session, details);
} catch (DBException e) {
throw new DBWebException("Error reading origin details", e);
}
}
}
@@ -1,97 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
import org.jkiss.dbeaver.model.net.DBWHandlerType;
import org.jkiss.dbeaver.model.net.ssh.SSHConstants;
import org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor;
import org.jkiss.dbeaver.registry.RegistryConstants;
import org.jkiss.utils.CommonUtils;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Web network handler info
*/
public class WebNetworkHandlerConfig {
private final DBWHandlerConfiguration configuration;
public WebNetworkHandlerConfig(DBWHandlerConfiguration configuration) {
this.configuration = configuration;
}
public DBWHandlerType getType() {
return configuration.getType();
}
public boolean isSecured() {
return configuration.isSecured();
}
@NotNull
public String getId() {
return configuration.getId();
}
public boolean isEnabled() {
return configuration.isEnabled();
}
@Deprecated
public SSHConstants.AuthType getAuthType() {
return CommonUtils.valueOf(SSHConstants.AuthType.class, configuration.getStringProperty(SSHConstants.PROP_AUTH_TYPE), SSHConstants.AuthType.PASSWORD);
}
public String getUserName() {
return configuration.getUserName();
}
public String getPassword() {
return CommonUtils.isEmpty(configuration.getPassword()) ? null : "";
}
@Deprecated // use secure properties
public String getKey() {
return CommonUtils.isEmpty(configuration.getSecureProperty(SSHConstants.PROP_KEY_VALUE)) ? null : "";
}
public boolean isSavePassword() {
return configuration.isSavePassword();
}
@NotNull
public Map<String, Object> getProperties() {
return configuration.getProperties();
}
@NotNull
public Map<String, String> getSecureProperties() {
Map<String, String> secureProperties = new LinkedHashMap<>(configuration.getSecureProperties());
DBPPropertyDescriptor[] descriptor = configuration.getHandlerDescriptor().getHandlerProperties();
for (DBPPropertyDescriptor p : descriptor) {
if (p.hasFeature(RegistryConstants.ATTR_PASSWORD)) {
secureProperties.computeIfPresent(p.getId(), (k, v) -> CommonUtils.isEmpty(v) ? null : WebConnectionInfo.SECURED_VALUE);
}
}
return secureProperties;
}
}
@@ -1,94 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model;
import org.jkiss.dbeaver.model.data.json.JSONUtils;
import org.jkiss.dbeaver.model.net.DBWHandlerType;
import org.jkiss.utils.CommonUtils;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Web network handler info
*/
public class WebNetworkHandlerConfigInput {
private final Map<String, Object> cfg;
public WebNetworkHandlerConfigInput(Map<String, Object> cfg) {
this.cfg = cfg;
}
public DBWHandlerType getType() {
return CommonUtils.valueOf(DBWHandlerType.class, JSONUtils.getString(cfg, "type"), null);
}
public String getId() {
return JSONUtils.getString(cfg, "id");
}
public Boolean isEnabled() {
if (cfg.containsKey("enabled")) {
return JSONUtils.getBoolean(cfg, "enabled");
} else {
return null;
}
}
public String getAuthType() {
return JSONUtils.getString(cfg, "authType");
}
public String getUserName() {
return JSONUtils.getString(cfg, "userName");
}
public String getPassword() {
return JSONUtils.getString(cfg, "password");
}
@Deprecated // use secured properties
public String getKey() {
return JSONUtils.getString(cfg, "key");
}
public Boolean isSavePassword() {
if (cfg.containsKey("savePassword")) {
return JSONUtils.getBoolean(cfg, "savePassword");
} else {
return null;
}
}
public Map<String, Object> getProperties() {
return JSONUtils.getObjectOrNull(cfg, "properties");
}
public Map<String, String> getSecureProperties() {
var secureProperties = JSONUtils.getObjectOrNull(cfg, "secureProperties");
if (secureProperties == null) {
return null;
}
var result = new LinkedHashMap<String, String>();
for (Map.Entry<String, Object> property : secureProperties.entrySet()) {
result.put(property.getKey(), CommonUtils.toString(property.getValue()));
}
return result;
}
}
@@ -1,49 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model;
import io.cloudbeaver.DBWebException;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.meta.Property;
import java.util.Map;
/**
* Object origin info
*/
public interface WebObjectOrigin {
@NotNull
public String getType();
@Nullable
public String getSubType();
@NotNull
public String getDisplayName();
@Nullable
public String getIcon();
@NotNull
public Map<String, Object> getConfiguration();
@Property
public WebPropertyInfo[] getDetails() throws DBWebException;
}
@@ -1,110 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model;
import io.cloudbeaver.WebProjectImpl;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.service.security.SMUtils;
import org.jkiss.dbeaver.model.app.DBPProject;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.rm.RMProjectPermission;
import org.jkiss.dbeaver.model.rm.RMProjectType;
import org.jkiss.dbeaver.model.rm.RMResourceType;
import org.jkiss.utils.ArrayUtils;
import java.util.ArrayList;
public class WebProjectInfo {
private final WebSession session;
private final WebProjectImpl project;
private final boolean customPrivateConnectionsEnabled;
public WebProjectInfo(WebSession session, WebProjectImpl project, boolean customPrivateConnectionsEnabled) {
this.session = session;
this.project = project;
this.customPrivateConnectionsEnabled = customPrivateConnectionsEnabled;
}
public WebSession getSession() {
return session;
}
public DBPProject getProject() {
return project;
}
@Property
public String getId() {
return project.getId();
}
@Property
public boolean isGlobal() { return project.getRmProject().isGlobal(); }
@Property
public boolean isShared() {
return project.getRmProject().isShared();
}
@Property
public String getName() {
return project.getName();
}
@Property
public String getDescription() {
return null;
}
@Property
public boolean isCanEditDataSources() {
if (project.getRmProject().getType() == RMProjectType.USER && !customPrivateConnectionsEnabled) {
return false;
}
return hasDataSourcePermission(RMProjectPermission.DATA_SOURCES_EDIT);
}
@Property
public boolean isCanViewDataSources() {
return hasDataSourcePermission(RMProjectPermission.DATA_SOURCES_VIEW);
}
@Property
public boolean isCanEditResources() {
return hasDataSourcePermission(RMProjectPermission.RESOURCE_EDIT);
}
@Property
public boolean isCanViewResources() {
return hasDataSourcePermission(RMProjectPermission.RESOURCE_VIEW);
}
private boolean hasDataSourcePermission(RMProjectPermission permission) {
return SMUtils.hasProjectPermission(session, project.getRmProject(), permission);
}
@Property
public RMResourceType[] getResourceTypes() {
RMResourceType[] resourceTypes = project.getRmProject().getResourceTypes();
if(resourceTypes == null) {
return ArrayUtils.toArray(RMResourceType.class, new ArrayList<>());
}
return resourceTypes;
}
}
@@ -1,38 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.secret.DBSSecretValue;
public class WebSecretInfo {
private final DBSSecretValue secretValue;
public WebSecretInfo(DBSSecretValue secretValue) {
this.secretValue = secretValue;
}
@Property
public String getDisplayName() {
return secretValue.getDisplayName();
}
@Property
public String getSecretId() {
return secretValue.getUniqueId();
}
}
@@ -1,73 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model;
import io.cloudbeaver.utils.CBModelConstants;
import org.jkiss.dbeaver.model.websocket.event.MessageType;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.time.Instant;
/**
* Web server message
*/
public class WebServerMessage {
private final MessageType type;
private final Instant time;
private final String message;
private final Throwable error;
public WebServerMessage(MessageType type, String message) {
this(type, message, null);
}
public WebServerMessage(Throwable error) {
this(MessageType.ERROR, error.getMessage(), error);
}
public WebServerMessage(MessageType type, String message, Throwable error) {
this.type = type;
this.time = Instant.now();
this.message = message;
this.error = error;
}
public MessageType getType() {
return type;
}
public String getTime() {
return CBModelConstants.ISO_DATE_FORMAT.format(time);
}
public String getMessage() {
return message;
}
public String getStackTrace() {
if (error != null) {
StringWriter buf = new StringWriter();
error.printStackTrace(new PrintWriter(buf, true));
return buf.toString();
}
return null;
}
}
@@ -1,144 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model.app;
import com.google.gson.annotations.Expose;
import io.cloudbeaver.auth.provider.local.LocalAuthProviderConstants;
import io.cloudbeaver.registry.WebAuthProviderDescriptor;
import io.cloudbeaver.registry.WebAuthProviderRegistry;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.security.SMAuthProviderCustomConfiguration;
import org.jkiss.utils.ArrayUtils;
import java.util.*;
public abstract class BaseAuthWebAppConfiguration extends BaseWebAppConfiguration implements WebAuthConfiguration {
private String defaultAuthProvider;
private String[] enabledAuthProviders;
private final Set<SMAuthProviderCustomConfiguration> authConfigurations;
// Legacy auth configs, left for backward compatibility
@Expose(serialize = false)
private final Map<String, SMAuthProviderCustomConfiguration> authConfiguration;
public BaseAuthWebAppConfiguration() {
super();
this.defaultAuthProvider = LocalAuthProviderConstants.PROVIDER_ID;
this.enabledAuthProviders = null;
this.authConfigurations = new LinkedHashSet<>();
this.authConfiguration = new LinkedHashMap<>();
}
public BaseAuthWebAppConfiguration(BaseAuthWebAppConfiguration src) {
super(src);
this.defaultAuthProvider = src.defaultAuthProvider;
this.enabledAuthProviders = src.enabledAuthProviders;
this.authConfigurations = new LinkedHashSet<>(src.authConfigurations);
this.authConfiguration = new LinkedHashMap<>(src.authConfiguration);
}
@Override
public String getDefaultAuthProvider() {
return defaultAuthProvider;
}
public void setDefaultAuthProvider(String defaultAuthProvider) {
this.defaultAuthProvider = defaultAuthProvider;
}
@Override
public String[] getEnabledAuthProviders() {
if (enabledAuthProviders == null) {
// No config - enable all providers (+backward compatibility)
return WebAuthProviderRegistry.getInstance().getAuthProviders()
.stream().map(WebAuthProviderDescriptor::getId).toArray(String[]::new);
}
return enabledAuthProviders;
}
public void setEnabledAuthProviders(String[] enabledAuthProviders) {
this.enabledAuthProviders = enabledAuthProviders;
}
@Override
public boolean isAuthProviderEnabled(String id) {
var authProviderDescriptor = WebAuthProviderRegistry.getInstance().getAuthProvider(id);
if (authProviderDescriptor == null) {
return false;
}
if (!ArrayUtils.contains(getEnabledAuthProviders(), id)) {
return false;
}
if (!ArrayUtils.isEmpty(authProviderDescriptor.getRequiredFeatures())) {
for (String rf : authProviderDescriptor.getRequiredFeatures()) {
if (!isFeatureEnabled(rf)) {
return false;
}
}
}
return true;
}
////////////////////////////////////////////
// Auth provider configs
@Override
public Set<SMAuthProviderCustomConfiguration> getAuthCustomConfigurations() {
return authConfigurations;
}
@Override
@Nullable
public SMAuthProviderCustomConfiguration getAuthProviderConfiguration(@NotNull String id) {
synchronized (authConfigurations) {
return authConfigurations.stream().filter(c -> c.getId().equals(id)).findAny().orElse(null);
}
}
public void addAuthProviderConfiguration(@NotNull SMAuthProviderCustomConfiguration config) {
synchronized (authConfigurations) {
authConfigurations.removeIf(c -> c.getId().equals(config.getId()));
authConfigurations.add(config);
}
}
public void setAuthProvidersConfigurations(Collection<SMAuthProviderCustomConfiguration> authProviders) {
synchronized (authConfigurations) {
authConfigurations.clear();
authConfigurations.addAll(authProviders);
}
}
public boolean deleteAuthProviderConfiguration(@NotNull String id) {
synchronized (authConfigurations) {
return authConfigurations.removeIf(c -> c.getId().equals(id));
}
}
public void loadLegacyCustomConfigs() {
// Convert legacy map of configs into list
if (!authConfiguration.isEmpty()) {
for (Map.Entry<String, SMAuthProviderCustomConfiguration> entry : authConfiguration.entrySet()) {
entry.getValue().setId(entry.getKey());
authConfigurations.add(entry.getValue());
}
authConfiguration.clear();
}
}
}
@@ -1,108 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model.app;
import io.cloudbeaver.DBWFeatureSet;
import io.cloudbeaver.registry.WebFeatureRegistry;
import org.jkiss.code.NotNull;
import org.jkiss.utils.ArrayUtils;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
public abstract class BaseWebAppConfiguration implements WebAppConfiguration {
public static final String DEFAULT_APP_ANONYMOUS_TEAM_NAME = "user";
protected final Map<String, Object> plugins;
protected String defaultUserTeam;
protected boolean resourceManagerEnabled;
protected boolean showReadOnlyConnectionInfo;
protected String[] enabledFeatures;
public BaseWebAppConfiguration() {
this.plugins = new LinkedHashMap<>();
this.defaultUserTeam = DEFAULT_APP_ANONYMOUS_TEAM_NAME;
this.resourceManagerEnabled = true;
this.enabledFeatures = null;
this.showReadOnlyConnectionInfo = false;
}
public BaseWebAppConfiguration(BaseWebAppConfiguration src) {
this.plugins = new LinkedHashMap<>(src.plugins);
this.defaultUserTeam = src.defaultUserTeam;
this.resourceManagerEnabled = src.resourceManagerEnabled;
this.enabledFeatures = src.enabledFeatures;
this.showReadOnlyConnectionInfo = src.showReadOnlyConnectionInfo;
}
@Override
public String getDefaultUserTeam() {
return defaultUserTeam;
}
@Override
public <T> T getPluginOption(@NotNull String pluginId, @NotNull String option) {
return (T) getPluginConfig(pluginId, false).get(option);
}
@Override
public Map<String, Object> getPluginConfig(@NotNull String pluginId, boolean create) {
Object config = plugins.get(pluginId);
if (config instanceof Map) {
return (Map<String, Object>) config;
} else {
if (create) {
Map<String, Object> newConfig = new LinkedHashMap<>();
plugins.put(pluginId, newConfig);
return newConfig;
} else {
return Collections.emptyMap();
}
}
}
@Override
public boolean isResourceManagerEnabled() {
return resourceManagerEnabled;
}
public boolean isFeatureEnabled(String id) {
return ArrayUtils.contains(getEnabledFeatures(), id);
}
public boolean isFeaturesEnabled(String[] features) {
return ArrayUtils.containsAll(getEnabledFeatures(), features);
}
public String[] getEnabledFeatures() {
if (enabledFeatures == null) {
// No config - enable all features (+backward compatibility)
return WebFeatureRegistry.getInstance().getWebFeatures()
.stream().map(DBWFeatureSet::getId).toArray(String[]::new);
}
return enabledFeatures;
}
public void setEnabledFeatures(String[] enabledFeatures) {
this.enabledFeatures = enabledFeatures;
}
public boolean isShowReadOnlyConnectionInfo() {
return showReadOnlyConnectionInfo;
}
}
@@ -1,283 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model.app;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.cloudbeaver.DataSourceFilter;
import io.cloudbeaver.WebProjectImpl;
import io.cloudbeaver.WebSessionProjectImpl;
import io.cloudbeaver.model.log.SLF4JLogHandler;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.server.WebGlobalWorkspace;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.app.IApplicationContext;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBFileController;
import org.jkiss.dbeaver.model.app.DBPPlatform;
import org.jkiss.dbeaver.model.app.DBPWorkspace;
import org.jkiss.dbeaver.model.auth.SMCredentialsProvider;
import org.jkiss.dbeaver.model.auth.SMSessionContext;
import org.jkiss.dbeaver.model.data.json.JSONUtils;
import org.jkiss.dbeaver.model.impl.app.ApplicationRegistry;
import org.jkiss.dbeaver.model.rm.RMController;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.model.secret.DBSSecretController;
import org.jkiss.dbeaver.model.websocket.event.WSEventController;
import org.jkiss.dbeaver.registry.BaseApplicationImpl;
import org.jkiss.dbeaver.runtime.IVariableResolver;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.dbeaver.utils.RuntimeUtils;
import org.jkiss.utils.CommonUtils;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
/**
* Web application
*/
public abstract class BaseWebApplication extends BaseApplicationImpl implements WebApplication {
public static final String DEFAULT_CONFIG_FILE_PATH = "/etc/cloudbeaver.conf";
public static final String CUSTOM_CONFIG_FOLDER = "custom";
public static final String CLI_PARAM_WEB_CONFIG = "-web-config";
public static final String LOGBACK_FILE_NAME = "logback.xml";
private static final Log log = Log.getLog(BaseWebApplication.class);
@NotNull
@Override
public DBPWorkspace createWorkspace(@NotNull DBPPlatform platform, @NotNull IWorkspace eclipseWorkspace) {
return new WebGlobalWorkspace(platform, eclipseWorkspace);
}
@Override
public RMController createResourceController(
@NotNull SMCredentialsProvider credentialsProvider,
@NotNull DBPWorkspace workspace
) throws DBException {
throw new IllegalStateException("Resource controller is not supported by " + getClass().getSimpleName());
}
@NotNull
@Override
public DBFileController createFileController(@NotNull SMCredentialsProvider credentialsProvider) {
throw new IllegalStateException("File controller is not supported by " + getClass().getSimpleName());
}
@Nullable
@Override
public Path getDefaultWorkingFolder() {
return null;
}
@Override
public boolean isHeadlessMode() {
return true;
}
@Override
public boolean isMultiuser() {
return true;
}
@Nullable
protected Path loadServerConfiguration() throws DBException {
Path configFilePath = getMainConfigurationFilePath().toAbsolutePath();
Path configFolder = configFilePath.getParent();
// Configure logging
Path logbackConfigPath = getLogbackConfigPath(configFolder);
if (logbackConfigPath == null) {
System.err.println("Can't find slf4j configuration file in " + configFilePath.getParent());
} else {
System.setProperty("logback.configurationFile", logbackConfigPath.toString());
}
Log.setLogHandler(new SLF4JLogHandler());
// Load config file
log.debug("Loading configuration from " + configFilePath);
try {
loadConfiguration(configFilePath);
} catch (Exception e) {
log.error("Error parsing configuration", e);
return null;
}
return configFilePath;
}
@Nullable
private Path getLogbackConfigPath(Path path) {
// try to find custom logback.xml file
Path logbackConfigPath = getCustomConfigPath(path, LOGBACK_FILE_NAME);
if (Files.exists(logbackConfigPath)) {
return logbackConfigPath;
}
for (Path confFolder = path; confFolder != null; confFolder = confFolder.getParent()) {
Path lbFile = confFolder.resolve(LOGBACK_FILE_NAME);
if (Files.exists(lbFile)) {
return lbFile;
}
}
return null;
}
public Path getLogbackConfigPath() {
Path configFilePath = getMainConfigurationFilePath().toAbsolutePath();
Path configFolder = configFilePath.getParent();
// Configure logging
return getLogbackConfigPath(configFolder);
}
private Path getMainConfigurationFilePath() {
String configPath = DEFAULT_CONFIG_FILE_PATH;
String[] args = Platform.getCommandLineArgs();
for (int i = 0; i < args.length; i++) {
if (args[i].equals(CLI_PARAM_WEB_CONFIG) && args.length > i + 1) {
configPath = args[i + 1];
break;
}
}
// try fo find custom config path (it is used mostly for docker volumes)
Path configFilePath = Path.of(configPath);
Path customConfigPath = getCustomConfigPath(configFilePath.getParent(), configFilePath.getFileName().toString());
if (Files.exists(customConfigPath)) {
return customConfigPath;
}
return configFilePath;
}
@NotNull
private Path getCustomConfigPath(Path configPath, String fileName) {
var customConfigPath = configPath.resolve(CUSTOM_CONFIG_FOLDER).resolve(fileName);
return Files.exists(customConfigPath) ? customConfigPath : configPath.resolve(fileName);
}
protected abstract void loadConfiguration(Path configPath) throws DBException;
@Override
public WebProjectImpl createProjectImpl(
@NotNull WebSession webSession,
@NotNull RMProject project,
@NotNull DataSourceFilter dataSourceFilter
) {
return new WebSessionProjectImpl(
webSession,
project,
dataSourceFilter
);
}
/**
* There is no secret controller in base web app.
* Method returns VoidSecretController instance.
* Advanced apps may implement it differently.
*/
@Override
public DBSSecretController getSecretController(
@NotNull SMCredentialsProvider credentialsProvider,
SMSessionContext smSessionContext
) throws DBException {
return VoidSecretController.INSTANCE;
}
protected static Map<String, Object> getServerConfigProps(Map<String, Object> configProps) {
return JSONUtils.getObject(configProps, "server");
}
@SuppressWarnings("unchecked")
public static void patchConfigurationWithProperties(Map<String, Object> configProps, IVariableResolver varResolver) {
for (Map.Entry<String, Object> entry : configProps.entrySet()) {
Object propValue = entry.getValue();
if (propValue instanceof String) {
entry.setValue(GeneralUtils.replaceVariables((String) propValue, varResolver));
} else if (propValue instanceof Map) {
patchConfigurationWithProperties((Map<String, Object>) propValue, varResolver);
} else if (propValue instanceof List) {
List value = (List) propValue;
for (int i = 0; i < value.size(); i++) {
Object colItem = value.get(i);
if (colItem instanceof String) {
value.set(i, GeneralUtils.replaceVariables((String) colItem, varResolver));
} else if (colItem instanceof Map) {
patchConfigurationWithProperties((Map<String, Object>) colItem, varResolver);
}
}
}
}
}
@Override
public Object start(IApplicationContext context) {
initializeApplicationServices();
try {
startServer();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return null;
}
protected abstract void startServer() throws DBException;
@Override
public String getApplicationInstanceId() throws DBException {
try {
byte[] macAddress = RuntimeUtils.getLocalMacAddress();
String appId = ApplicationRegistry.getInstance().getApplication().getId();
return appId + "_" + CommonUtils.toHexString(macAddress) + getServerPort();
} catch (Exception e) {
throw new DBException("Error during generation instance id generation", e);
}
}
public String getApplicationId() {
try {
return getApplicationInstanceId();
} catch (DBException e) {
return null;
}
}
@Override
public WSEventController getEventController() {
return null;
}
protected Gson getGson() {
return getGsonBuilder().create();
}
protected abstract GsonBuilder getGsonBuilder();
@Override
public boolean isEnvironmentVariablesAccessible() {
return false;
}
}
@@ -1,71 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model.app;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.auth.SMCredentialsProvider;
import org.jkiss.dbeaver.model.auth.SMSessionContext;
import org.jkiss.dbeaver.model.exec.DBCFeatureNotSupportedException;
import org.jkiss.dbeaver.model.secret.DBSSecretController;
import org.jkiss.dbeaver.model.secret.DBSSecretControllerAuthorized;
import org.jkiss.dbeaver.model.secret.DBSSecretObject;
import org.jkiss.dbeaver.model.secret.DBSSecretValue;
import java.util.List;
/**
* Void secret controller.
*/
public class VoidSecretController implements DBSSecretController, DBSSecretControllerAuthorized {
public static final VoidSecretController INSTANCE = new VoidSecretController();
public VoidSecretController() {
}
@Nullable
@Override
public String getPrivateSecretValue(@NotNull String secretId) {
return null;
}
@Override
public void setPrivateSecretValue(@NotNull String secretId, @Nullable String secretValue) throws DBException {
throw new DBException("Secret controller is read-only");
}
@NotNull
@Override
public List<DBSSecretValue> discoverCurrentUserSecrets(@NotNull DBSSecretObject secretObject) throws DBException {
throw new DBCFeatureNotSupportedException("Secrets discovery not supported");
}
@Override
public void flushChanges() {
}
@Override
public void authorize(
@Nullable SMCredentialsProvider credentialsProvider,
@Nullable SMSessionContext smSessionContext
) throws DBException {
}
}
@@ -1,48 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model.app;
import org.jkiss.code.NotNull;
import java.util.Map;
/**
* Application configuration
*/
public interface WebAppConfiguration {
String getAnonymousUserTeam();
boolean isAnonymousAccessEnabled();
<T> T getResourceQuota(String quotaId);
String getDefaultUserTeam();
<T> T getPluginOption(@NotNull String pluginId, @NotNull String option);
Map<String, Object> getPluginConfig(@NotNull String pluginId, boolean create);
boolean isResourceManagerEnabled();
boolean isFeaturesEnabled(String[] requiredFeatures);
boolean isFeatureEnabled(String id);
default boolean isSupportsCustomConnections() {
return true;
}
}
@@ -1,96 +0,0 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model.app;
import io.cloudbeaver.DataSourceFilter;
import io.cloudbeaver.WebProjectImpl;
import io.cloudbeaver.model.session.WebSession;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBFileController;
import org.jkiss.dbeaver.model.app.DBPApplication;
import org.jkiss.dbeaver.model.app.DBPWorkspace;
import org.jkiss.dbeaver.model.auth.SMCredentialsProvider;
import org.jkiss.dbeaver.model.auth.SMSessionContext;
import org.jkiss.dbeaver.model.rm.RMController;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.model.secret.DBSSecretController;
import org.jkiss.dbeaver.model.security.SMAdminController;
import org.jkiss.dbeaver.model.security.SMController;
import org.jkiss.dbeaver.model.websocket.event.WSEventController;
import java.nio.file.Path;
/**
* Base interface for web application
*/
public interface WebApplication extends DBPApplication {
boolean isConfigurationMode();
WebAppConfiguration getAppConfiguration();
Path getDataDirectory(boolean create);
Path getWorkspaceDirectory();
Path getHomeDirectory();
boolean isMultiNode();
WebProjectImpl createProjectImpl(
@NotNull WebSession webSession,
@NotNull RMProject project,
@NotNull DataSourceFilter dataSourceFilter
);
SMController createSecurityController(@NotNull SMCredentialsProvider credentialsProvider) throws DBException;
SMAdminController getAdminSecurityController(@NotNull SMCredentialsProvider credentialsProvider) throws DBException;
DBSSecretController getSecretController(
@NotNull SMCredentialsProvider credentialsProvider,
SMSessionContext smSessionContext
) throws DBException;
RMController createResourceController(
@NotNull SMCredentialsProvider credentialsProvider,
@NotNull DBPWorkspace workspace
) throws DBException;
DBFileController createFileController(@NotNull SMCredentialsProvider credentialsProvider);
String getServerURL();
default String getServicesURI() {
return "/";
}
default String getRootURI() {
return "";
}
String getApplicationInstanceId() throws DBException;
WSEventController getEventController();
/**
* Port this server listens on
*/
int getServerPort();
boolean isLicenseRequired();
}

Some files were not shown because too many files have changed in this diff Show More