Skip to content

Commit

Permalink
Prevent NullPointerException in ACL parser
Browse files Browse the repository at this point in the history
Parsing `{}` as ACL resulted in a NullPointerException since Opencast
just expected the object to contain a field `acl`. That means, something
like `{"acl":{}}` would be fine and result in an empty ACL. The empty
object should be handled gracefully and be treated the same. That is,
what this patch does.
  • Loading branch information
lkiesow committed Jul 11, 2024
1 parent 3388edb commit b514454
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,14 @@ public static AccessControlList parseAcl(InputStream in) throws IOException, Acc
*/
private static AccessControlList parseJson(String content) throws AccessControlParsingException {
try {
AccessControlList acl = new AccessControlList();
JSONObject json = (JSONObject) new JSONParser().parse(content);
JSONObject jsonAcl = (JSONObject) json.get(ACL);
if (jsonAcl == null) {
return acl;
}
Object jsonAceObj = jsonAcl.get(ACE);

AccessControlList acl = new AccessControlList();
if (jsonAceObj == null)
return acl;

Expand Down

0 comments on commit b514454

Please sign in to comment.