Skip to content

Commit

Permalink
[SECURITY-412] Simplify implementation as suggested by jglick
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-beck authored and jglick committed Apr 13, 2017
1 parent eeb699e commit 23f4809
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions core/src/main/java/jenkins/model/Jenkins.java
Expand Up @@ -3369,53 +3369,41 @@ public DirectoryBrowserSupport doUserContent() {
*
* This first replaces "app" to {@link HudsonIsRestarting}
*/
@CLIMethod(name="restart")
public void doRestart(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, RestartNotSupportedException {
checkPermission(ADMINISTER);
if (req != null && req.getMethod().equals("GET")) {
req.getView(this,"_restart.jelly").forward(req,rsp);
return;
}

if (req != null && req.getMethod().equals("POST")) {
if (req == null || req.getMethod().equals("POST")) {
restart();
}

rsp.sendRedirect2(".");
}

@CLIMethod(name="restart")
@Restricted(NoExternalUse.class)
public void cliRestart() throws RestartNotSupportedException {
checkPermission(ADMINISTER);
restart();
}

/**
* Queues up a restart of Jenkins for when there are no builds running, if we can.
*
* This first replaces "app" to {@link HudsonIsRestarting}
*
* @since 1.332
*/
@CLIMethod(name="safe-restart")
public HttpResponse doSafeRestart(StaplerRequest req) throws IOException, ServletException, RestartNotSupportedException {
checkPermission(ADMINISTER);
if (req != null && req.getMethod().equals("GET"))
return HttpResponses.forwardToView(this,"_safeRestart.jelly");

if (req != null && req.getMethod().equals("POST")) {
if (req == null || req.getMethod().equals("POST")) {
safeRestart();
}

return HttpResponses.redirectToDot();
}

@CLIMethod(name="safe-restart")
@Restricted(NoExternalUse.class)
public void cliSafeRestart() throws RestartNotSupportedException {
checkPermission(ADMINISTER);
safeRestart();
}

/**
* Performs a restart.
*/
Expand Down

0 comments on commit 23f4809

Please sign in to comment.