@Override protected int act(List<Run<?, ?>> builds) throws IOException { job.checkPermission(Run.DELETE); final HashSet<Integer> hsBuilds = new HashSet<>(); for (Run<?, ?> build : builds) { if (!hsBuilds.contains(build.number)) { build.delete(); hsBuilds.add(build.number); } } stdout.println("Deleted "+hsBuilds.size()+" builds"); return 0; }
@Override @Restricted(NoExternalUse.class) public Object getTarget() { if (!SKIP_PERMISSION_CHECK) { // This is a bit weird, but while the Run's PermissionScope does not have READ, delegate to the parent if (!getParent().hasPermission(Item.DISCOVER)) { return null; } getParent().checkPermission(Item.READ); } return this; }
protected int run() throws Exception { job.checkPermission(Item.READ);
public static void checkPermission(Job<?,?> project, BuildAuthorizationToken token, StaplerRequest req, StaplerResponse rsp) throws IOException { if (!Jenkins.getInstance().isUseSecurity()) return; // everyone is authorized if(token!=null && token.token != null) { //check the provided token String providedToken = req.getParameter("token"); if (providedToken != null && providedToken.equals(token.token)) return; if (providedToken != null) throw new AccessDeniedException(Messages.BuildAuthorizationToken_InvalidTokenProvided()); } project.checkPermission(Item.BUILD); if (req.getMethod().equals("POST")) { return; } if (req.getAttribute(ApiTokenProperty.class.getName()) instanceof User) { return; } rsp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); rsp.addHeader("Allow", "POST"); throw HttpResponses.forwardToView(project, "requirePOST.jelly"); }
/** * Accepts and serves the job description */ public void doDescription(StaplerRequest req, StaplerResponse rsp) throws IOException { if (req.getMethod().equals("GET")) { //read rsp.setContentType("text/plain;charset=UTF-8"); rsp.getWriter().write(Util.fixNull(this.getDescription())); return; } if (req.getMethod().equals("POST")) { checkPermission(CONFIGURE); // submission if (req.getParameter("description") != null) { this.setDescription(req.getParameter("description")); rsp.sendError(SC_NO_CONTENT); return; } } // huh? rsp.sendError(SC_BAD_REQUEST); }
/** * Standard implementation of {@link ParameterizedJob#doCancelQueue}. */ @RequirePOST public final void doCancelQueue( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { asJob().checkPermission(Item.CANCEL); Jenkins.getInstance().getQueue().cancel(asJob()); rsp.forwardToPreviousPage(req); }
protected int run() throws Exception { job.checkPermission(Item.BUILD);
public synchronized void doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException { checkPermission(CONFIGURE);
@Override public Object getTarget() { item.checkPermission(Item.EXTENDED_READ); return this; }
public void superCheckPermission(Permission p) { super.checkPermission(p); }
@Override protected int act(List<Run<?, ?>> builds) throws IOException { job.checkPermission(Run.DELETE); final HashSet<Integer> hsBuilds = new HashSet<Integer>(); for (Run<?, ?> build : builds) { if (!hsBuilds.contains(build.number)) { build.delete(); hsBuilds.add(build.number); } } stdout.println("Deleted "+hsBuilds.size()+" builds"); return 0; }
/** * Resets overridden properties to the values defined in parent. * * @param propertyName the name of the properties. It possible to pass several names * separated with {@link #PROPERTY_NAME_SEPARATOR}. * @throws java.io.IOException exception. */ public void doResetProjectProperty(@QueryParameter final String propertyName) throws IOException { checkPermission(CONFIGURE); for (String name : StringUtils.split(propertyName, PROPERTY_NAME_SEPARATOR)) { final IProjectProperty property = getProperty(name); if (null != property) { property.resetValue(); } } save(); }
/** * Resets overridden properties to the values defined in parent. * * @param propertyName the name of the properties. It possible to pass several names * separated with {@link #PROPERTY_NAME_SEPARATOR}. * @throws java.io.IOException exception. */ public void doResetProjectProperty(@QueryParameter final String propertyName) throws IOException { checkPermission(CONFIGURE); for (String name : StringUtils.split(propertyName, PROPERTY_NAME_SEPARATOR)) { final IProjectProperty property = getProperty(name); if (null != property) { property.resetValue(); } } save(); }
@Override protected int run() throws Exception { Run r = getCurrentlyBuilding(); r.getParent().checkPermission(Item.BUILD); r.setResult(result); return 0; } }
@Override protected int run() throws Exception { Run r = getCurrentlyBuilding(); r.getParent().checkPermission(Item.BUILD); r.setResult(result); return 0; } }
@Override protected int run() throws Exception { Run r = getCurrentlyBuilding(); r.getParent().checkPermission(Item.BUILD); r.setResult(result); return 0; } }
@Override protected int run() throws Exception { Run r = getCurrentlyBuilding(); r.getParent().checkPermission(Item.BUILD); r.setResult(result); return 0; } }
@Override public void checkPermission(Permission p) { initPython(); if (pexec.isImplemented(90)) { pexec.execPythonVoid("check_permission", p); } else { super.checkPermission(p); } }
@SuppressWarnings("unchecked") private void removeActions(Class type, StaplerRequest req, StaplerResponse rsp) throws IOException { req.findAncestorObject(Job.class).checkPermission(Run.UPDATE); Run run = req.findAncestorObject(Run.class); if (run != null) { List<Action> actions = run.getActions(); List<Action> groovyActions = run.getActions(type); for(Action action : groovyActions) { actions.remove(action); } run.save(); rsp.sendRedirect(req.getRequestURI().substring(0, req.getRequestURI().indexOf("parent/parent"))); } }
/** * Standard implementation of {@link ParameterizedJob#doCancelQueue}. */ @RequirePOST public final void doCancelQueue( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { asJob().checkPermission(Item.CANCEL); Jenkins.getInstance().getQueue().cancel(asJob()); rsp.forwardToPreviousPage(req); }