From de361f7ca67514d2e325cf5859a3c5550e9a992e Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Tue, 24 Mar 2020 13:23:55 +0100 Subject: [PATCH] [New] Added StrolchComponent.runAsWithResult() --- .../strolch/agent/api/StrolchComponent.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchComponent.java b/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchComponent.java index 4b30e0599..ea6bc1515 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchComponent.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchComponent.java @@ -339,6 +339,26 @@ public class StrolchComponent { this.container.getPrivilegeHandler().runAs(username, runnable); } + /** + * Performs the given {@link PrivilegedRunnable} as the given system user + * + * @param username + * the name of the system user to perform the action as + * @param runnable + * the runnable to perform + * + * @return the result + * + * @throws PrivilegeException + * if the given username is not allowed to perform the action + * @throws Exception + * if anything else goes wrong during execution + */ + protected T runAsWithResult(String username, PrivilegedRunnableWithResult runnable) + throws PrivilegeException, Exception { + return this.container.getPrivilegeHandler().runWithResult(username, runnable); + } + /** * Performs the given {@link PrivilegedRunnable} as the given system user *