Skip to content

Commit

Permalink
dont use jsonadapter annotation, call deserializer manually
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethhealy committed Nov 20, 2024
1 parent 677c86c commit a32a60e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 3 additions & 2 deletions sdk/src/main/java/io/opentdf/platform/sdk/Manifest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@
* of data integrity, encryption, payload, and assertions within a certain
* context.
*/
@JsonAdapter(Manifest.ManifestDeserializer.class) // Custom deserializer
public class Manifest {

private static final String kAssertionHash = "assertionHash";
private static final String kAssertionSignature = "assertionSig";

private static final Gson gson = new Gson();
private static final Gson gson = new GsonBuilder()
.registerTypeAdapter(Manifest.class, new ManifestDeserializer())
.create();

@Override
public boolean equals(Object o) {
Expand Down
6 changes: 5 additions & 1 deletion sdk/src/main/java/io/opentdf/platform/sdk/TDF.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package io.opentdf.platform.sdk;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.nimbusds.jose.*;

import io.opentdf.platform.policy.Value;
import io.opentdf.platform.policy.attributes.AttributesServiceGrpc.AttributesServiceFutureStub;
import io.opentdf.platform.sdk.Config.TDFConfig;
import io.opentdf.platform.sdk.Manifest.ManifestDeserializer;
import io.opentdf.platform.sdk.Autoconfigure.AttributeValueFQN;
import io.opentdf.platform.sdk.Config.KASInfo;

Expand Down Expand Up @@ -75,7 +77,9 @@ public TDF() {

private static final SecureRandom sRandom = new SecureRandom();

private static final Gson gson = new Gson();
private static final Gson gson = new GsonBuilder()
.registerTypeAdapter(Manifest.class, new ManifestDeserializer())
.create();

public class SplitKeyException extends IOException {
public SplitKeyException(String errorMessage) {
Expand Down
10 changes: 9 additions & 1 deletion sdk/src/test/java/io/opentdf/platform/sdk/ZipReaderTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.opentdf.platform.sdk;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import io.opentdf.platform.sdk.Manifest.ManifestDeserializer;

import org.apache.commons.compress.archivers.zip.Zip64Mode;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
Expand Down Expand Up @@ -36,7 +40,11 @@ public void testReadingExistingZip() throws Exception {
if (entry.getName().endsWith(".json")) {
entry.getData().transferTo(stream);
var data = stream.toString(StandardCharsets.UTF_8);
var map = new Gson().fromJson(data, Map.class);
var gson = new GsonBuilder()
.registerTypeAdapter(Manifest.class, new ManifestDeserializer())
.create();
var map = gson.fromJson(data, Map.class);

assertThat(map.get("encryptionInformation")).isNotNull();
}
}
Expand Down

0 comments on commit a32a60e

Please sign in to comment.