Skip to content

Commit

Permalink
[FIXED JENKINS-13223]
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob_robertson committed Mar 26, 2012
1 parent 3d3a3b7 commit 2509535
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/main/java/hudson/views/SecuredJobsFilter.java
@@ -0,0 +1,47 @@
package hudson.views;

import hudson.Extension;
import hudson.model.JobProperty;
import hudson.model.TopLevelItem;
import hudson.model.Descriptor;
import hudson.model.Job;
import hudson.security.AuthorizationMatrixProperty;

import org.kohsuke.stapler.DataBoundConstructor;

/**
* Simply filters on whether a job is secured through the "Project-based Matrix Authorization Strategy".
*
* @author jacob
*/
public class SecuredJobsFilter extends AbstractIncludeExcludeJobFilter {

@DataBoundConstructor
public SecuredJobsFilter(String includeExcludeTypeString) {
super(includeExcludeTypeString);
}

@SuppressWarnings({ "rawtypes", "unchecked" })
protected boolean matches(TopLevelItem item) {
if (item instanceof Job) {
Job job = (Job) item;
JobProperty prop = job.getProperty(AuthorizationMatrixProperty.class);
return (prop != null);
} else {
return false;
}
}

@Extension
public static class DescriptorImpl extends Descriptor<ViewJobFilter> {
@Override
public String getDisplayName() {
return "Project-based Secured Jobs";
}
@Override
public String getHelpFile() {
return "/plugin/view-job-filters/secured-jobs-help.html";
}
}

}
5 changes: 5 additions & 0 deletions src/main/webapp/secured-jobs-help.html
@@ -0,0 +1,5 @@
<div>
Filters on whether a job has selected the "Enable project-based security" option.
<br/><br/>
<b>NOTE:</b> This filter does not <u>provide</u> security - it merely provides convenient views that feed off of the security you've already set up.
</div>

0 comments on commit 2509535

Please sign in to comment.