Skip to content

Commit

Permalink
Merge pull request #72 from jenkinsci/job-permission
Browse files Browse the repository at this point in the history
Add a new facade method to check permissions for a job
  • Loading branch information
uhafner authored Feb 9, 2021
2 parents b87e7b1 + 5540f88 commit ed52355
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/io/jenkins/plugins/util/JenkinsFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ public boolean hasPermission(final Permission permission) {
return getJenkins().getACL().hasPermission(permission);
}

/**
* Checks if the current security principal has this permission for the specified project.
*
* @param permission
* the permission to check for
* @param project
* the project to check the permissions for
*
* @return {@code false} if the user doesn't have the permission
*/
public boolean hasPermission(final Permission permission, final Job<?, ?> project) {
return getJenkins().getAuthorizationStrategy().getACL(project).hasPermission(permission);
}

/**
* Gets a {@link Job} by its full name. Full names are like path names, where each name of {@link Item} is combined
* by '/'.
Expand Down

0 comments on commit ed52355

Please sign in to comment.