Adding PolicySet parsePoliciesJson method - #365
Merged
Conversation
john-h-kastner-aws
approved these changes
Jul 31, 2026
lianah
approved these changes
Aug 3, 2026
`policyFormat`/`schemaFormat` support landed in cedar-policy#366, but `loadPolicySet` still rejected `policyFormat: json` because there was no Java interface for parsing a policy set from its JSON (EST) representation. Now that `PolicySet.parsePoliciesJson` exists, honor the JSON format and add `tests/example_use_cases/2a_json_policy.json` to the handwritten test list.
Addresses review feedback: `format!("{}", policy.id())` allocates a String just to
recover the id text that `AsRef<str>` already exposes. `PolicyId` also implements
`AsRef<ast::PolicyID>`, so the `let` bindings are annotated `&str` to pick the
intended impl.
The note predates commit b53563e (Aug 2023), which wired up executeJsonValidationTest. The schema field has been read since then, feeding both the ValidationRequest and each AuthorizationRequest, and the Java validator interface it waits on exists.
mark-creamer-amazon
force-pushed
the
main
branch
from
August 11, 2026 17:41
ce0a935 to
e912f0c
Compare
muditchaudhary
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Similar to #165, provides utility functions
parsePoliciesJsonthat parse multiple static policies, policy templates, and policy linked templates in via a EST representation in a JSON string or file.Unlike the
parsePolicieshelper, the underlyingPolicySet::from_strmethod can yield template linked policies based on the EST representation via thetemplateLinkskey. So we do resolve template linked policies in this new method, populatingtemplateLinksin thePolicySetPOJOCedarJava
PolicySet parsePoliciesJson(Path filePath)andPolicySet parsePoliciesJson(String policiesJsonString)methods toPolicySet.PolicySetTests.javasrc/test/resourcesdirectory to use for testing.CedarJava/src/test/resources/policies.jsonCedarJava/src/test/resources/template.jsonCedarJavaFFI
parsePoliciesJsonJnithat takes a Java String for policies and templates, usesPolicySet::from_json_strto parse the string intopoliciesandtemplatesand then constructs a JavaPolicySetwith those parameters.parse_policies_internal, extracting common code that converts the Rust PolicySet to the Java PolicySet object in newpolicy_set_to_javahelperJLinkValuearound the existingLinkValueJava object andJTemplateLinkaroundTemplateLink