Skip to content

Commit

Permalink
core: Updated CallContext.checkAccess() exception messages for clarity
Browse files Browse the repository at this point in the history
Also slightly adjusted logging to match
  • Loading branch information
cederberg committed Dec 8, 2024
1 parent 67191c9 commit 208c311
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/java/org/rapidcontext/core/proc/CallContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

/**
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 208c311

Please sign in to comment.