mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-29 20:45:20 +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 {
|
||||
|
||||
@@ -5,9 +5,9 @@ import hudson.model.Job;
|
||||
import hudson.model.JobProperty;
|
||||
import hudson.model.JobPropertyDescriptor;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.model.Run;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -136,7 +136,7 @@ public class AuthorizationMatrixProperty extends JobProperty<Job<?, ?>> {
|
||||
}
|
||||
|
||||
public List<PermissionGroup> getAllGroups() {
|
||||
return Collections.singletonList(PermissionGroup.get(Item.class));
|
||||
return Arrays.asList(PermissionGroup.get(Item.class),PermissionGroup.get(Run.class));
|
||||
}
|
||||
|
||||
public boolean showPermission(Permission p) {
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
<st:include page="sidepanel.jelly" />
|
||||
<l:main-panel>
|
||||
<div style="float:right; background-color:white; z-index: 1; position:relative; margin-left: 1em">
|
||||
<j:if test="${h.hasPermission(it.UPDATE)}">
|
||||
<l:hasPermission permission="${it.UPDATE}">
|
||||
<st:include page="logKeep.jelly" />
|
||||
</j:if>
|
||||
<j:if test="${h.hasPermission(it.DELETE)}">
|
||||
</l:hasPermission>
|
||||
<l:hasPermission permission="${it.DELETE}">
|
||||
<st:include page="delete.jelly" />
|
||||
</j:if>
|
||||
</l:hasPermission>
|
||||
<div style="margin-top:1em">
|
||||
${%startedAgo(it.timestampString)}
|
||||
</div><div>
|
||||
@@ -125,4 +125,4 @@
|
||||
</ul>
|
||||
</l:main-panel>
|
||||
</l:layout>
|
||||
</j:jelly>
|
||||
</j:jelly>
|
||||
@@ -13,7 +13,7 @@ Attributes:
|
||||
permission object. If specified, the link will be displayed only if you have a permission
|
||||
-->
|
||||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
|
||||
<j:if test="${h.hasPermission(attrs.permission)}">
|
||||
<j:if test="${h.hasPermission(it,attrs.permission)}">
|
||||
<j:if test="${attrs.icon!=null}">
|
||||
<tr>
|
||||
<td>
|
||||
@@ -30,4 +30,4 @@ Attributes:
|
||||
</tr>
|
||||
</j:if>
|
||||
</j:if>
|
||||
</j:jelly>
|
||||
</j:jelly>
|
||||
Reference in new issue
Block a user