From cb4e837f4a9c8da34af69b7c201f739480d657f2 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Thu, 25 Feb 2021 10:30:35 +0000 Subject: [PATCH] Fix for #120. The NullPointerException occurred because there has been an entry in the ACL of an entity which referred to a non-existing realm (aka user source, aka authentication provider). This case is now treated as "user does not exist". --- CHANGELOG.md | 2 ++ .../org/caosdb/server/accessControl/UserSources.java | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5223612..76e20e39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +* #120 - Editing entities that were created with a no longer existing user + leads to a server error. * #31 - Queries with keywords in the path (e.g. `... STORED AT 0in.txt`) * #116 - Queries `FIND [ANY VERSION OF] *` and `FIND [ANY VERSION OF] ENTITY`. diff --git a/src/main/java/org/caosdb/server/accessControl/UserSources.java b/src/main/java/org/caosdb/server/accessControl/UserSources.java index 8f69c8c5..a7abd140 100644 --- a/src/main/java/org/caosdb/server/accessControl/UserSources.java +++ b/src/main/java/org/caosdb/server/accessControl/UserSources.java @@ -79,8 +79,18 @@ public class UserSources extends HashMap<String, UserSource> { private static UserSources instance = new UserSources(); + /** + * Check whether a user exists. + * + * @param principal - principal of the user. + * @return true iff the user identified by the given {@link Principal} exists. + */ public static boolean isUserExisting(final Principal principal) { - return instance.get(principal.getRealm()).isUserExisting(principal.getUsername()); + UserSource userSource = instance.get(principal.getRealm()); + if (userSource != null) { + return userSource.isUserExisting(principal.getUsername()); + } + return false; } private UserSources() { -- GitLab