From 208c3116a344fc82502d516d83d4455cc2e0fb63 Mon Sep 17 00:00:00 2001 From: Per Cederberg Date: Sun, 8 Dec 2024 09:53:50 +0100 Subject: [PATCH] core: Updated CallContext.checkAccess() exception messages for clarity Also slightly adjusted logging to match --- src/java/org/rapidcontext/core/proc/CallContext.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/java/org/rapidcontext/core/proc/CallContext.java b/src/java/org/rapidcontext/core/proc/CallContext.java index e493750a..20929f34 100644 --- a/src/java/org/rapidcontext/core/proc/CallContext.java +++ b/src/java/org/rapidcontext/core/proc/CallContext.java @@ -14,9 +14,12 @@ package org.rapidcontext.core.proc; +import static org.rapidcontext.core.security.SecurityContext.currentUser; + import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.Objects; import java.util.logging.Level; import java.util.logging.Logger; @@ -30,7 +33,6 @@ import org.rapidcontext.core.type.Environment; import org.rapidcontext.core.type.Role; import org.rapidcontext.core.type.Procedure; -import org.rapidcontext.core.type.User; import org.rapidcontext.util.DateUtil; /** @@ -299,10 +301,10 @@ public static void checkAccess(String path, String permission) throws ProcedureException { if (!SecurityContext.hasAccess(path, permission)) { - User user = SecurityContext.currentUser(); - String id = (user == null) ? "anonymous user" : user.toString(); - LOG.info(permission + " permission denied for " + path + ", " + id); - throw new ProcedureException("permission denied"); + String user = Objects.toString(currentUser(), "anonymous user"); + String msg = permission + " access denied for " + user; + LOG.info(msg + ", path: " + path); + throw new ProcedureException(msg); } }