mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-31 13:35:19 +00:00
[JENKINS-61465] Make checkAnyPermission work on non-AccessControlled
This commit is contained in:
1 parent
a79101ce54
commit
7259d8698c
3 files changed
+114
No files matched your search
@@ -1172,6 +1172,31 @@ public class Functions {
|
||||
ac.checkAnyPermission(permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
* This version is so that the 'checkAnyPermission' on {@code layout.jelly}
|
||||
* degrades gracefully if "it" is not an {@link AccessControlled} object.
|
||||
* Otherwise it will perform no check and that problem is hard to notice.
|
||||
*/
|
||||
public static void checkAnyPermission(Object object, Permission[] permissions) throws IOException, ServletException {
|
||||
if (permissions == null || permissions.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (object instanceof AccessControlled)
|
||||
checkAnyPermission((AccessControlled) object, permissions);
|
||||
else {
|
||||
List<Ancestor> ancs = Stapler.getCurrentRequest().getAncestors();
|
||||
for(Ancestor anc : Iterators.reverse(ancs)) {
|
||||
Object o = anc.getObject();
|
||||
if (o instanceof AccessControlled) {
|
||||
checkAnyPermission((AccessControlled) o, permissions);
|
||||
return;
|
||||
}
|
||||
}
|
||||
checkAnyPermission(Jenkins.get(), permissions);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Tag implements Comparable<Tag> {
|
||||
double ordinal;
|
||||
String hierarchy;
|
||||
|
||||
Reference in new issue
Block a user