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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions apis/com.dbeaver.datadam.dam.remote.api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ requests without this field remain supported; null means no suggestion and is om
When supplied, the name uses the same normalization and 256-Unicode-code-point limit as Account renames;
blank, non-string, and oversized values are rejected.
`DDRemoteDamHandshakeResponse` returns the assigned `damSessionId` and `DDRemoteDamSettings`, containing immutable
`account` and `dam` string maps. The desktop applies this snapshot before registering settings-dependent services
and registers `service.desktop.DDRemoteDamSettingsService` (`dbeaver.dam.settings`) for subsequent complete snapshots. A missing
`account` and `dam` string maps. Its required `accountId` is verified by the server.
The desktop applies the settings snapshot before registering settings-dependent services and registers
`service.desktop.DDRemoteDamSettingsService` (`dbeaver.dam.settings`) for subsequent complete snapshots. A missing
settings field from an older broker produces empty maps; MCP remains disabled until explicitly enabled for the DAM.
Setting keys are declared in `DDRemoteDamSettingKeys`. Settings reads and writes use Account GraphQL.
Wire control types remain
Expand Down Expand Up @@ -47,8 +48,9 @@ and changes when Desktop restarts. `damSessionId` identifies one WebSocket trans
Reconnects supersede the previous connection for the same account, client DAM identity and application instance.
Different application instances can have independent connections to the same DAM.

`DDRemoteDamSessionInfo` contains `appDeploymentId`, `appInstanceId`, `damSessionId`, and the handshake settings snapshot.
Transport identity uses only the three session identifiers; updated settings do not replace a physical session.
`DDRemoteDamSessionInfo` contains the verified `accountId`, `appDeploymentId`, `appInstanceId`, `damSessionId`,
and the handshake settings snapshot. Transport identity includes the account and the three session identifiers;
updated settings do not replace a physical session.
`DDRemoteDamSession` adds `product` and `version` for registry presentation. All fields are nonblank strings.
Concurrent sessions may share deployment and instance IDs when their account or client DAM identity differs; consumers
must use `damSessionId` to distinguish transport sessions. Deployment ID, product, and version are peer-supplied metadata, not
Expand Down Expand Up @@ -158,8 +160,9 @@ communication failures still throw, since some leave it unknown whether the key
`com.dbeaver.messaging.rpc` supplies typed proxies and implementation registration independently of DataDam and WebSocket.
`DDRemoteDamRpcTransport` adapts request/reply to `MessagingRpcMessage<JsonElement>`. Application serialization is selected
through a codec, for example `new DDRemoteDamGsonRpcCodec(new Gson())`. The codec retains the application's Gson adapters
and naming policies, preserves declared generic types, and handles each argument independently. A varargs array is one
argument; JSON null is a nullable payload. Each proxy and registration can use a different compatible codec.
and naming policies except for `LocalDateTime` and `OffsetDateTime`: these types always use ISO-8601 on the RPC wire so
peers agree on their representation. It preserves declared generic types and handles each argument independently.
A varargs array is one argument; JSON null is a nullable payload. Each proxy and registration can use a different compatible codec.
Proxy timeout overloads accept `Duration`, without changing other proxies or the shared endpoint; the default is
30 seconds unless endpoint options specify otherwise.

Expand Down Expand Up @@ -193,6 +196,10 @@ Causes and suppressed exceptions are formatted remotely; no `Throwable` is seria
Each argument and response can be any JSON value, while the outer topic message remains an object. Existing correlation,
source validation, and authentication still apply. Malformed envelopes are ignored without exposing raw contents.

Desktop and Remote DAM currently limit each complete UTF-8 WebSocket message to 4 MiB, including the RPC envelope,
JSON, and Base64-encoded project ciphertext. This is not a 4 MiB raw-file limit: Base64 and framing reduce the
available space for file contents. Larger transfers need transparent transport chunking, which is not yet implemented.

Framing, snapshot copying, and outstanding sends are bounded to 128 operations without a waiting queue. Cancellation does
not release a send slot until its underlying operation finishes. Business contracts use ordinary synchronous methods;
`void` waits for completion. Failures become unchecked `MessagingRpcException`; remote handler/codec failures preserve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,15 @@
*/
package com.dbeaver.datadam.dam.remote.api;

import com.dbeaver.datadam.dam.remote.api.model.DDRemoteDamAuthenticationRequest;
import com.dbeaver.datadam.dam.remote.api.model.DDRemoteDamHandshakeRequest;
import com.dbeaver.datadam.dam.remote.api.model.DDRemoteDamHandshakeResponse;
import com.dbeaver.datadam.dam.remote.api.model.DDRemoteDamMessage;
import com.dbeaver.datadam.dam.remote.api.model.DDRemoteDamPayload;
import com.dbeaver.datadam.dam.remote.api.model.DDRemoteDamSessionRequest;
import com.dbeaver.datadam.dam.remote.api.model.DDRemoteDamSettings;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
import com.google.gson.ToNumberPolicy;
import com.dbeaver.datadam.dam.remote.api.model.*;
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public final class DDRemoteDamProtocol {
private static final Gson GSON = new GsonBuilder().serializeNulls().setObjectToNumberStrategy(ToNumberPolicy.BIG_DECIMAL).create();
Expand All @@ -57,6 +46,7 @@ public final class DDRemoteDamProtocol {
private static final String FIELD_VERSION = "version";
private static final String FIELD_SUGGESTED_NAME = "suggestedName";
private static final String FIELD_DAM_SESSION_ID = "damSessionId";
private static final String FIELD_ACCOUNT_ID = "accountId";

private DDRemoteDamProtocol() {
}
Expand Down Expand Up @@ -152,6 +142,7 @@ public static DDRemoteDamHandshakeRequest decodeHandshakeRequest(@NotNull String
public static String encodeHandshakeResponse(@NotNull DDRemoteDamHandshakeResponse ready) {
JsonObject payload = new JsonObject();
payload.addProperty(FIELD_DAM_SESSION_ID, ready.damSessionId());
payload.addProperty(FIELD_ACCOUNT_ID, ready.accountId().toString());
payload.add("settings", new Gson().toJsonTree(ready.settings()));
if (ready.authenticationRefresh()) {
payload.addProperty("authenticationRefresh", true);
Expand All @@ -176,8 +167,9 @@ public static DDRemoteDamHandshakeResponse decodeHandshakeResponse(@NotNull Stri
&& (!authenticationRefresh.isJsonPrimitive() || !authenticationRefresh.getAsJsonPrimitive().isBoolean())) {
throw new IllegalArgumentException("Expected an authenticationRefresh boolean");
}
UUID accountId = UUID.fromString(readString(payload, FIELD_ACCOUNT_ID));
return new DDRemoteDamHandshakeResponse(readString(payload, FIELD_DAM_SESSION_ID), settings,
authenticationRefresh != null && authenticationRefresh.getAsBoolean());
authenticationRefresh != null && authenticationRefresh.getAsBoolean(), accountId);
}

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

import org.jkiss.code.NotNull;

import java.util.UUID;

public record DDAccountInfo(@NotNull UUID accountId, @NotNull String accountName) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2026 DBeaver Corp
*
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of DBeaver Corp and its suppliers, if any.
* The intellectual and technical concepts contained
* herein are proprietary to DBeaver Corp and its suppliers
* and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package com.dbeaver.datadam.dam.remote.api.model;

import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;

import java.util.UUID;

public record DDGatewayCryptoState(
@NotNull UUID accountId,
boolean cryptoConfigured,
@Nullable String encryptedBundle,
@Nullable Long generation,
@Nullable String salt,
@Nullable Integer iterations,
@Nullable UUID apiKeyId
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,18 @@

import org.jkiss.code.NotNull;

import java.util.Objects;
import java.util.UUID;

public record DDRemoteDamHandshakeResponse(
@NotNull String damSessionId,
@NotNull DDRemoteDamSettings settings,
boolean authenticationRefresh
boolean authenticationRefresh,
@NotNull UUID accountId
) {
public DDRemoteDamHandshakeResponse(@NotNull String damSessionId, @NotNull DDRemoteDamSettings settings) {
this(damSessionId, settings, false);
}

public DDRemoteDamHandshakeResponse(@NotNull String damSessionId) {
this(damSessionId, DDRemoteDamSettings.EMPTY);
}

public DDRemoteDamHandshakeResponse {
java.util.Objects.requireNonNull(settings);
Objects.requireNonNull(settings);
Objects.requireNonNull(accountId);
DDRemoteDamMessage.requireText(damSessionId, "damSessionId");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,27 @@
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;

import java.util.Objects;
import java.util.UUID;

public record DDRemoteDamSessionInfo(
@NotNull String appDeploymentId,
@NotNull String appInstanceId,
@NotNull String damSessionId,
@NotNull DDRemoteDamSettings settings
@NotNull DDRemoteDamSettings settings,
@NotNull UUID accountId
) {
public DDRemoteDamSessionInfo(@NotNull String appDeploymentId, @NotNull String appInstanceId, @NotNull String damSessionId) {
this(appDeploymentId, appInstanceId, damSessionId, DDRemoteDamSettings.EMPTY);
}

public DDRemoteDamSessionInfo {
java.util.Objects.requireNonNull(settings);
Objects.requireNonNull(settings);
Objects.requireNonNull(accountId);
DDRemoteDamMessage.requireText(appDeploymentId, "appDeploymentId");
DDRemoteDamMessage.requireText(appInstanceId, "appInstanceId");
DDRemoteDamMessage.requireText(damSessionId, "damSessionId");
}

public boolean isSameSession(@Nullable DDRemoteDamSessionInfo other) {
return other != null && appDeploymentId.equals(other.appDeploymentId)
&& appInstanceId.equals(other.appInstanceId) && damSessionId.equals(other.damSessionId);
&& appInstanceId.equals(other.appInstanceId) && damSessionId.equals(other.damSessionId)
&& accountId.equals(other.accountId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,63 @@

import com.dbeaver.messaging.rpc.MessagingRpcCodec;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import com.google.gson.ToNumberPolicy;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;

import java.io.IOException;
import java.lang.reflect.Type;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.format.DateTimeParseException;
import java.util.Objects;

public final class DDRemoteDamGsonRpcCodec implements MessagingRpcCodec<Object> {
private static final TypeAdapter<LocalDateTime> LOCAL_DATE_TIME = new TypeAdapter<LocalDateTime>() {
@Override
public void write(@NotNull JsonWriter out, @NotNull LocalDateTime value) throws IOException {
out.value(value.toString());
}

@Override
@NotNull
public LocalDateTime read(@NotNull JsonReader in) throws IOException {
try {
return LocalDateTime.parse(in.nextString());
} catch (DateTimeParseException e) {
throw new JsonParseException("Invalid RPC date", e);
}
}
}.nullSafe();

private static final TypeAdapter<OffsetDateTime> OFFSET_DATE_TIME = new TypeAdapter<OffsetDateTime>() {
@Override
public void write(@NotNull JsonWriter out, @NotNull OffsetDateTime value) throws IOException {
out.value(value.toString());
}

@Override
@NotNull
public OffsetDateTime read(@NotNull JsonReader in) throws IOException {
try {
return OffsetDateTime.parse(in.nextString());
} catch (DateTimeParseException e) {
throw new JsonParseException("Invalid RPC date", e);
}
}
}.nullSafe();

private final Gson gson;

public DDRemoteDamGsonRpcCodec(@NotNull Gson gson) {
this.gson = Objects.requireNonNull(gson).newBuilder().serializeNulls()
this.gson = Objects.requireNonNull(gson).newBuilder()
.registerTypeAdapter(LocalDateTime.class, LOCAL_DATE_TIME)
.registerTypeAdapter(OffsetDateTime.class, OFFSET_DATE_TIME)
Comment thread
SolovevAnton marked this conversation as resolved.
Resolved
.serializeNulls()
.setObjectToNumberStrategy(ToNumberPolicy.BIG_DECIMAL).create();
}

Expand Down
Loading
Loading