Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #8 from jenkinsci/jenkins-31860
[JENKINS-31860] Restore return type to match API
  • Loading branch information
stephenc committed Dec 15, 2015
2 parents 74cbb6e + c25012f commit a9380a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Expand Up @@ -117,7 +117,7 @@ private void add(String shortForm) {
}

@Override
public SidACL getRootACL() {
public ACL getRootACL() {
return acl;
}

Expand Down
Expand Up @@ -35,6 +35,8 @@
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.mapper.Mapper;
import com.thoughtworks.xstream.core.JVM;
import org.acegisecurity.Authentication;
import org.acegisecurity.acls.sid.Sid;
import org.jenkinsci.plugins.matrixauth.Messages;

import java.util.HashSet;
Expand All @@ -56,16 +58,29 @@ public ACL getACL(Job<?,?> project) {
SidACL projectAcl = amp.getACL();

if (!amp.isBlocksInheritance()) {
projectAcl = projectAcl.newInheritingACL(getACL(project.getParent()));
final ACL parentAcl = getACL(project.getParent());
return inheritingACL(parentAcl, projectAcl);
} else {
return projectAcl;
}

return projectAcl;
} else {
return getACL(project.getParent());
}
}

public SidACL getACL(ItemGroup g) {
private static ACL inheritingACL(final ACL parent, final ACL child) {
if (parent instanceof SidACL && child instanceof SidACL) {
return ((SidACL) parent).newInheritingACL((SidACL) child);
}
return new ACL() {
@Override
public boolean hasPermission(Authentication a, Permission permission) {
return child.hasPermission(a, permission) || parent.hasPermission(a, permission);
}
};
}

public ACL getACL(ItemGroup g) {
if (g instanceof Item) {
Item item = (Item) g;
return (SidACL)item.getACL();
Expand All @@ -74,7 +89,7 @@ public SidACL getACL(ItemGroup g) {
}

@Override
public SidACL getACL(AbstractItem item) {
public ACL getACL(AbstractItem item) {
return getACL(item.getParent());
}

Expand Down

0 comments on commit a9380a6

Please sign in to comment.