mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-30 04:55:21 +00:00
[FIXED HUDSON-2727] In 1.265.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@13651 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
665bbd0c7b
commit
33ed006eca
4 files changed
+28
-11
No files matched your search
@@ -489,8 +489,25 @@ public class Functions {
|
||||
return hasPermission(Hudson.getInstance(),permission);
|
||||
}
|
||||
|
||||
public static boolean hasPermission(AccessControlled object, Permission permission) throws IOException, ServletException {
|
||||
return permission==null || object.hasPermission(permission);
|
||||
/**
|
||||
* This version is so that the 'hasPermission' can degrade gracefully
|
||||
* if "it" is not an {@link AccessControlled} object.
|
||||
*/
|
||||
public static boolean hasPermission(Object object, Permission permission) throws IOException, ServletException {
|
||||
if (permission == null)
|
||||
return true;
|
||||
if (object instanceof AccessControlled)
|
||||
return ((AccessControlled)object).hasPermission(permission);
|
||||
else {
|
||||
List<Ancestor> ancs = Stapler.getCurrentRequest().getAncestors();
|
||||
for(Ancestor anc : Iterators.reverse(ancs)) {
|
||||
Object o = anc.getObject();
|
||||
if (o instanceof AccessControlled) {
|
||||
return ((AccessControlled)o).hasPermission(permission);
|
||||
}
|
||||
}
|
||||
return Hudson.getInstance().hasPermission(permission);
|
||||
}
|
||||
}
|
||||
|
||||
public static void adminCheck(StaplerRequest req, StaplerResponse rsp, Object required, Permission permission) throws IOException, ServletException {
|
||||
|
||||
Reference in new issue
Block a user