forked from WebGoat/WebGoat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added service for fetching the title of a lesson
- Loading branch information
Showing
6 changed files
with
53 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/org/owasp/webgoat/service/LessonTitleService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.owasp.webgoat.service; | ||
|
||
import javax.servlet.http.HttpSession; | ||
|
||
import org.owasp.webgoat.lessons.AbstractLesson; | ||
import org.owasp.webgoat.session.Course; | ||
import org.owasp.webgoat.session.WebSession; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
@Controller | ||
public class LessonTitleService extends BaseService { | ||
|
||
/** | ||
* Returns the title for the current attack | ||
* | ||
* @param session | ||
* @return | ||
*/ | ||
@RequestMapping(value = "/lessontitle.mvc", produces = "application/html") | ||
public @ResponseBody | ||
String showPlan(HttpSession session) { | ||
WebSession ws = getWebSession(session); | ||
return getLessonTitle(ws); | ||
} | ||
|
||
private String getLessonTitle(WebSession s) { | ||
String title = ""; | ||
int scr = s.getCurrentScreen(); | ||
Course course = s.getCourse(); | ||
|
||
if (s.isUser() || s.isChallenge()) { | ||
AbstractLesson lesson = course.getLesson(s, scr, AbstractLesson.USER_ROLE); | ||
title = lesson != null ? lesson.getTitle() : ""; | ||
} | ||
return title; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters