diff --git a/CedarJava/build.gradle b/CedarJava/build.gradle index 65de46e7..b4e3afcd 100644 --- a/CedarJava/build.gradle +++ b/CedarJava/build.gradle @@ -70,6 +70,7 @@ dependencies { implementation 'com.fasterxml.jackson.core:jackson-databind:2.16.1' implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.16.1' implementation 'org.slf4j:slf4j-api:2.0.12' + implementation 'com.google.guava:guava:33.0.0-jre' compileOnly 'com.github.spotbugs:spotbugs-annotations:4.8.3' testImplementation 'org.slf4j:slf4j-simple:2.0.12' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2' diff --git a/CedarJava/config.sh b/CedarJava/config.sh index 41cde92b..54ac158c 100755 --- a/CedarJava/config.sh +++ b/CedarJava/config.sh @@ -14,7 +14,7 @@ if [ "$(uname)" == "Darwin" ]; then else ffi_lib_str=" environment 'CEDAR_JAVA_FFI_LIB', '"$parent_dir"/CedarJavaFFI/target/debug/libcedar_java_ffi.so'" fi -sed "85s;.*;$ffi_lib_str;" "build.gradle" > new_build.gradle +sed "83s;.*;$ffi_lib_str;" "build.gradle" > new_build.gradle mv new_build.gradle build.gradle # In CI, we need to pull the latest cedar-policy to match the latest cedar-integration-tests @@ -23,7 +23,7 @@ mv new_build.gradle build.gradle # If you call this script with `run_int_tests`, we assume you have `cedar` checkout out in the `cedar-java` dir if [ "$#" -ne 0 ] && [ "$1" == "run_int_tests" ]; then integration_tests_str=" environment 'CEDAR_INTEGRATION_TESTS_ROOT', '"$parent_dir"/cedar/cedar-integration-tests'" - sed "84s;.*;$integration_tests_str;" "build.gradle" > new_build.gradle + sed "82s;.*;$integration_tests_str;" "build.gradle" > new_build.gradle mv new_build.gradle build.gradle export MUST_RUN_CEDAR_INTEGRATION_TESTS=1 diff --git a/CedarJava/src/main/java/com/cedarpolicy/model/AuthorizationResponse.java b/CedarJava/src/main/java/com/cedarpolicy/model/AuthorizationResponse.java index ba69a29d..925d2cf3 100644 --- a/CedarJava/src/main/java/com/cedarpolicy/model/AuthorizationResponse.java +++ b/CedarJava/src/main/java/com/cedarpolicy/model/AuthorizationResponse.java @@ -19,9 +19,10 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.Collections; import java.util.List; import java.util.Set; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; /** * The result of processing an AuthorizationRequest. The answer to the request is contained in the @@ -53,10 +54,10 @@ public static class Diagnostics { * Set of policyID's that caused the decision. For example, when a policy evaluates to Deny, * all deny policies that evaluated to True will appear in Reasons. */ - private Set reason; + private ImmutableSet reason; /** Set of errors and warnings returned by Cedar. */ - private List errors; + private ImmutableList errors; /** * Read the reasons and errors from a JSON object. @@ -68,8 +69,8 @@ public static class Diagnostics { public Diagnostics( @JsonProperty("reason") Set reason, @JsonProperty("errors") List errors) { - this.errors = Collections.unmodifiableList(errors); - this.reason = Collections.unmodifiableSet(reason); + this.errors = ImmutableList.copyOf(errors); + this.reason = ImmutableSet.copyOf(reason); } /** diff --git a/CedarJava/src/main/java/com/cedarpolicy/model/slice/TemplateInstantiation.java b/CedarJava/src/main/java/com/cedarpolicy/model/slice/TemplateInstantiation.java index aa0f4735..ed31afaa 100644 --- a/CedarJava/src/main/java/com/cedarpolicy/model/slice/TemplateInstantiation.java +++ b/CedarJava/src/main/java/com/cedarpolicy/model/slice/TemplateInstantiation.java @@ -18,8 +18,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Collections; import java.util.List; +import com.google.common.collect.ImmutableList; /** Template instantiation. */ public class TemplateInstantiation { @@ -46,7 +46,7 @@ public TemplateInstantiation( @JsonProperty("instantiations") List instantiations) { this.templateId = templateId; this.resultPolicyId = resultPolicyId; - this.instantiations = Collections.unmodifiableList(instantiations); + this.instantiations = ImmutableList.copyOf(instantiations); } /** Get the template ID. */