From 7155fb5bda6cfba58e783ee41fb891ba545d230b Mon Sep 17 00:00:00 2001 From: kohsuke Date: Fri, 4 Jan 2008 01:32:30 +0000 Subject: [PATCH] adding more convenience methods. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6467 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/Functions.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index e61ca1f1cc..2fe578d54d 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -414,6 +414,17 @@ public class Functions { return Util.xmlEscape(s); } + public static void checkPermission(Permission permission) throws IOException, ServletException { + Hudson.getInstance().getACL().checkPermission(permission); + } + + /** + * Returns true if the current user has the given permission. + */ + public static boolean hasPermission(Permission permission) throws IOException, ServletException { + return Hudson.getInstance().getACL().hasPermission(permission); + } + public static void adminCheck(StaplerRequest req, StaplerResponse rsp, Object required, Permission permission) throws IOException, ServletException { // this is legacy --- all views should be eventually converted to // the permission based model. @@ -426,7 +437,7 @@ public class Functions { // make sure the user owns the necessary permission to access this page. if(permission!=null) - Hudson.getInstance().getACL().checkPermission(permission); + checkPermission(permission); } /**