Adds Entities with backward compatibility#293
Adds Entities with backward compatibility#293muditchaudhary merged 8 commits intocedar-policy:mainfrom
Conversation
Signed-off-by: Mudit Chaudhary <chmudit@amazon.com>
Signed-off-by: Mudit Chaudhary <chmudit@amazon.com>
Signed-off-by: Mudit Chaudhary <chmudit@amazon.com>
Signed-off-by: Mudit Chaudhary <chmudit@amazon.com>
…ward compatiblity Signed-off-by: Mudit Chaudhary <chmudit@amazon.com>
Signed-off-by: Mudit Chaudhary <chmudit@amazon.com>
CedarJava/src/main/java/com/cedarpolicy/model/entity/Entities.java
Outdated
Show resolved
Hide resolved
|
|
||
| @Override | ||
| public String toString() { | ||
| return String.join("\n", this.entities.stream().map(Entity::toString).toList()); |
There was a problem hiding this comment.
Does this style match the behavior in Rust where each is printed on a new line?
There was a problem hiding this comment.
No. The default behavior in Rust is to display the JSON representation of Entities and Entity. .toString() for Entities continues to follow the same display format which was implemented for Entity
There was a problem hiding this comment.
It seems like this format for displaying Entity was introduced in CedarJava 2.x. Maybe we can make the behavior similar to Rust in the next major version update as this will change the behavior of an existing public API
CedarJava/src/main/java/com/cedarpolicy/BasicAuthorizationEngine.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Mudit Chaudhary <chmudit@amazon.com>
adpaco-aws
left a comment
There was a problem hiding this comment.
Are there no plans to deprecate the methods using Set<Entity> in favor of these new ones? It's great to have these APIs but at the moment it's not clear why anyone would use one over the other.
CedarJava/src/main/java/com/cedarpolicy/AuthorizationEngine.java
Outdated
Show resolved
Hide resolved
CedarJava/src/main/java/com/cedarpolicy/BasicAuthorizationEngine.java
Outdated
Show resolved
Hide resolved
Currently, we have not decided the concrete version when we plan to deprecate the methods using |
Signed-off-by: Mudit Chaudhary <chmudit@amazon.com>
Description
This PR introduces the
Entitiesclass to CedarJava, aligning it more closely with CedarRust's implementation. Key changes include:New
Entitiesclass: Replacement for the currentSet<Entity>representation for entity collections. This new class is equivalent to CedarRust'sEntities.Parse Entities from JSON: The
Entitiesclass supports parsing entities from both JSON strings and files.Updated authorization methods:
isAuthorized()andisAuthorizedPartial()methods to accept the newEntitiestype.Set<Entity>in existing method signatures.Testing:
Entitiesclass.EntitiesandSet<Entity>.org.skyscreamer:jsonassert:2.0-rc1as a test dependencyEntitiesusingJSONAssertEquals()..toJson()methods).