add links and fix titles to lesson menu service
add list of built in accounts to login screen
This commit is contained in:
parent
d5024b7739
commit
ba9b60a99c
105
java/org/owasp/webgoat/lessons/model/LessonMenuItem.java
Normal file
105
java/org/owasp/webgoat/lessons/model/LessonMenuItem.java
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package org.owasp.webgoat.lessons.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author rlawson
|
||||||
|
*/
|
||||||
|
public class LessonMenuItem {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private LessonMenuItemType type;
|
||||||
|
private List<LessonMenuItem> children = new ArrayList<LessonMenuItem>();
|
||||||
|
private boolean complete;
|
||||||
|
private String link;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name the name to set
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the children
|
||||||
|
*/
|
||||||
|
public List<LessonMenuItem> getChildren() {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param children the children to set
|
||||||
|
*/
|
||||||
|
public void setChildren(List<LessonMenuItem> children) {
|
||||||
|
this.children = children;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the type
|
||||||
|
*/
|
||||||
|
public LessonMenuItemType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param type the type to set
|
||||||
|
*/
|
||||||
|
public void setType(LessonMenuItemType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addChild(LessonMenuItem child) {
|
||||||
|
children.add(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder bldr = new StringBuilder();
|
||||||
|
bldr.append("Name: ").append(name).append(" | ");
|
||||||
|
bldr.append("Type: ").append(type).append(" | ");
|
||||||
|
return bldr.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the complete
|
||||||
|
*/
|
||||||
|
public boolean isComplete() {
|
||||||
|
return complete;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param complete the complete to set
|
||||||
|
*/
|
||||||
|
public void setComplete(boolean complete) {
|
||||||
|
this.complete = complete;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the link
|
||||||
|
*/
|
||||||
|
public String getLink() {
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param link the link to set
|
||||||
|
*/
|
||||||
|
public void setLink(String link) {
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
17
java/org/owasp/webgoat/lessons/model/LessonMenuItemType.java
Normal file
17
java/org/owasp/webgoat/lessons/model/LessonMenuItemType.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.owasp.webgoat.lessons.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author rlawson
|
||||||
|
*/
|
||||||
|
public enum LessonMenuItemType {
|
||||||
|
CATEGORY,
|
||||||
|
LESSON,
|
||||||
|
STAGE
|
||||||
|
}
|
@ -10,7 +10,6 @@ import java.util.List;
|
|||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
import org.owasp.webgoat.lessons.AbstractLesson;
|
import org.owasp.webgoat.lessons.AbstractLesson;
|
||||||
import org.owasp.webgoat.lessons.model.Hint;
|
import org.owasp.webgoat.lessons.model.Hint;
|
||||||
import org.owasp.webgoat.session.Course;
|
|
||||||
import org.owasp.webgoat.session.WebSession;
|
import org.owasp.webgoat.session.WebSession;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
@ -56,7 +56,8 @@ public class LessonMenuService extends BaseService {
|
|||||||
List<AbstractLesson> lessons = ws.getLessons(category);
|
List<AbstractLesson> lessons = ws.getLessons(category);
|
||||||
for (AbstractLesson lesson : lessons) {
|
for (AbstractLesson lesson : lessons) {
|
||||||
LessonMenuItem lessonItem = new LessonMenuItem();
|
LessonMenuItem lessonItem = new LessonMenuItem();
|
||||||
lessonItem.setName(lesson.getName());
|
lessonItem.setName(lesson.getTitle());
|
||||||
|
lessonItem.setLink(lesson.getLink());
|
||||||
lessonItem.setType(LessonMenuItemType.LESSON);
|
lessonItem.setType(LessonMenuItemType.LESSON);
|
||||||
if (lesson.isCompleted(ws)) {
|
if (lesson.isCompleted(ws)) {
|
||||||
lessonItem.setComplete(true);
|
lessonItem.setComplete(true);
|
||||||
@ -67,14 +68,20 @@ public class LessonMenuService extends BaseService {
|
|||||||
RandomLessonAdapter rla = (RandomLessonAdapter) lesson;
|
RandomLessonAdapter rla = (RandomLessonAdapter) lesson;
|
||||||
String[] stages = rla.getStages();
|
String[] stages = rla.getStages();
|
||||||
if (stages != null) {
|
if (stages != null) {
|
||||||
|
String lessonLink = lesson.getLink();
|
||||||
|
int stageIdx = 1;
|
||||||
for (String stage : stages) {
|
for (String stage : stages) {
|
||||||
LessonMenuItem stageItem = new LessonMenuItem();
|
LessonMenuItem stageItem = new LessonMenuItem();
|
||||||
stageItem.setName(stage);
|
stageItem.setName("Stage " + stageIdx + ": " + stage);
|
||||||
|
// build the link for the stage
|
||||||
|
String stageLink = lessonLink + "&stage=" + stageIdx;
|
||||||
|
stageItem.setLink(stageLink);
|
||||||
stageItem.setType(LessonMenuItemType.STAGE);
|
stageItem.setType(LessonMenuItemType.STAGE);
|
||||||
if (rla.isStageComplete(ws, stage)) {
|
if (rla.isStageComplete(ws, stage)) {
|
||||||
stageItem.setComplete(true);
|
stageItem.setComplete(true);
|
||||||
}
|
}
|
||||||
lessonItem.addChild(stageItem);
|
lessonItem.addChild(stageItem);
|
||||||
|
stageIdx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,26 @@
|
|||||||
value="${_csrf.token}" />
|
value="${_csrf.token}" />
|
||||||
<button class="btn btn-large btn-primary" type="submit">Sign in</button>
|
<button class="btn btn-large btn-primary" type="submit">Sign in</button>
|
||||||
</form>
|
</form>
|
||||||
|
<div class="panel panel-info" style="max-width: 300px; margin: 0 auto 20px;">
|
||||||
|
<div class="panel-heading">
|
||||||
|
Logon with one of the following accounts
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<!-- Table -->
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr><td>Account</td><td>User</td><td>Password</td></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr><td>Webgoat User</td><td>guest</td><td>guest</td></tr>
|
||||||
|
<tr><td>Webgoat Admin</td><td>webgoat</td><td>webgoat</td></tr>
|
||||||
|
<tr><td>Server Admin</td><td>server</td><td>server</td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div> <!-- /container -->
|
</div> <!-- /container -->
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user