Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
116 changes: 62 additions & 54 deletions jans-cedarling/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ public MultiIssuerAuthorizeResult authorizeMultiIssuer(
throw new IllegalArgumentException("resource must not be null");
}
EntityData resourceObj = EntityData.Companion.fromJson(resource.toString());
String contextStr = context != null ? context.toString() : "{}";
return cedarling.authorizeMultiIssuer(tokens, action, resourceObj, contextStr);
JsonValue contextJson = context != null ? new JsonValue(context.toString()) : null;
return cedarling.authorizeMultiIssuer(tokens, action, resourceObj, contextJson);
}

// ── authorize_unsigned ──────────────────────────────────────────────
Expand Down Expand Up @@ -159,7 +159,7 @@ public AuthorizeResult authorizeUnsignedEntity(
}
EntityData resourceObj = EntityData.Companion.fromJson(resource.toString());
String contextStr = context != null ? context.toString() : "{}";
return cedarling.authorizeUnsigned(principal, action, resourceObj, contextStr);
return cedarling.authorizeUnsigned(principal, action, resourceObj, new JsonValue(contextStr));
}

// ── authorize_unsigned_batch ────────────────────────────────────────
Expand Down Expand Up @@ -264,8 +264,8 @@ public BatchItem batchItemFromJson(
throw new IllegalArgumentException("resource must not be null");
}
EntityData resourceObj = EntityData.Companion.fromJson(resource.toString());
String contextStr = context != null ? context.toString() : null;
return new BatchItem(resourceObj, action, contextStr);
JsonValue contextJson = context != null ? new JsonValue(context.toString()) : null;
return new BatchItem(resourceObj, action, contextJson);
}

/**
Expand Down Expand Up @@ -362,7 +362,7 @@ public void pushDataCtx(String key, JSONObject value, Long ttlSecs) throws DataE
if (value == null) {
throw new DataException.SerializationException("value cannot be null");
}
cedarling.pushDataCtx(key, value.toString(), ttlSecs);
cedarling.pushDataCtx(key, new JsonValue(value.toString()), ttlSecs);
}

/**
Expand All @@ -382,7 +382,7 @@ public void pushDataCtx(String key, String value, Long ttlSecs) throws DataExcep
if (value == null) {
throw new DataException.SerializationException("value cannot be null");
}
cedarling.pushDataCtx(key, value, ttlSecs);
cedarling.pushDataCtx(key, new JsonValue(value), ttlSecs);
}

/**
Expand Down Expand Up @@ -416,12 +416,12 @@ public void pushDataCtx(String key, String value) throws DataException {
* @throws DataException If the operation fails
*/
public Object getDataCtx(String key) throws DataException {
String result = cedarling.getDataCtx(key);
JsonValue result = cedarling.getDataCtx(key);
if (result == null) {
return null;
}
try {
org.json.JSONTokener tokener = new org.json.JSONTokener(result);
org.json.JSONTokener tokener = new org.json.JSONTokener(result.getValue());
Object value = tokener.nextValue();
if (value == org.json.JSONObject.NULL) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import uniffi.cedarling_uniffi.AuthorizeException;
import uniffi.cedarling_uniffi.BatchAuthorizeMultiIssuerResponse;
import uniffi.cedarling_uniffi.BatchItem;
import uniffi.cedarling_uniffi.JsonValue;
import uniffi.cedarling_uniffi.BatchItemError;
import uniffi.cedarling_uniffi.BatchItemMultiIssuerOutcome;
import uniffi.cedarling_uniffi.EntityData;
Expand Down Expand Up @@ -201,7 +202,8 @@ public void batchMixedDecisionsPreserveOrder() throws Exception {
BatchItem badItem = new BatchItem(
EntityData.Companion.fromJson(resource.toString()),
"this is not a valid uid",
new JSONObject().toString());
new JsonValue("{}")
);
List<BatchItem> items = new ArrayList<>();
items.add(sameItem());
items.add(badItem);
Expand Down
Loading