Skip to content

Commit 5c1b3e1

Browse files
committed
Add flags to lesson menu items if the lesson should show source or hints
1 parent 13e3bb8 commit 5c1b3e1

File tree

2 files changed

+90
-47
lines changed

2 files changed

+90
-47
lines changed

src/main/java/org/owasp/webgoat/lessons/model/LessonMenuItem.java

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
/***************************************************************************************************
2-
*
3-
*
4-
* This file is part of WebGoat, an Open Web Application Security Project utility. For details,
5-
* please see http://www.owasp.org/
6-
*
1+
/**
2+
* *************************************************************************************************
3+
*
4+
*
5+
* This file is part of WebGoat, an Open Web Application Security Project
6+
* utility. For details, please see http://www.owasp.org/
7+
*
78
* Copyright (c) 2002 - 20014 Bruce Mayhew
8-
*
9-
* This program is free software; you can redistribute it and/or modify it under the terms of the
10-
* GNU General Public License as published by the Free Software Foundation; either version 2 of the
11-
* License, or (at your option) any later version.
12-
*
13-
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
14-
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15-
* General Public License for more details.
16-
*
17-
* You should have received a copy of the GNU General Public License along with this program; if
18-
* not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19-
* 02111-1307, USA.
20-
*
9+
*
10+
* This program is free software; you can redistribute it and/or modify it under
11+
* the terms of the GNU General Public License as published by the Free Software
12+
* Foundation; either version 2 of the License, or (at your option) any later
13+
* version.
14+
*
15+
* This program is distributed in the hope that it will be useful, but WITHOUT
16+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18+
* details.
19+
*
20+
* You should have received a copy of the GNU General Public License along with
21+
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22+
* Place - Suite 330, Boston, MA 02111-1307, USA.
23+
*
2124
* Getting Source ==============
22-
*
23-
* Source for this application is maintained at https://github.com/WebGoat/WebGoat, a repository for free software
24-
* projects.
25-
*
25+
*
26+
* Source for this application is maintained at
27+
* https://github.com/WebGoat/WebGoat, a repository for free software projects.
28+
*
2629
* For details, please see http://webgoat.github.io
2730
*/
2831
package org.owasp.webgoat.lessons.model;
@@ -40,7 +43,9 @@ public class LessonMenuItem {
4043
private LessonMenuItemType type;
4144
private List<LessonMenuItem> children = new ArrayList<LessonMenuItem>();
4245
private boolean complete;
43-
private String link;
46+
private String link;
47+
private boolean showSource;
48+
private boolean showHints;
4449

4550
/**
4651
* @return the name
@@ -124,4 +129,32 @@ public void setLink(String link) {
124129
this.link = link;
125130
}
126131

132+
/**
133+
* @return the showSource
134+
*/
135+
public boolean isShowSource() {
136+
return showSource;
137+
}
138+
139+
/**
140+
* @param showSource the showSource to set
141+
*/
142+
public void setShowSource(boolean showSource) {
143+
this.showSource = showSource;
144+
}
145+
146+
/**
147+
* @return the showHints
148+
*/
149+
public boolean isShowHints() {
150+
return showHints;
151+
}
152+
153+
/**
154+
* @param showHints the showHints to set
155+
*/
156+
public void setShowHints(boolean showHints) {
157+
this.showHints = showHints;
158+
}
159+
127160
}

src/main/java/org/owasp/webgoat/service/LessonMenuService.java

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
/***************************************************************************************************
2-
*
3-
*
4-
* This file is part of WebGoat, an Open Web Application Security Project utility. For details,
5-
* please see http://www.owasp.org/
6-
*
1+
/**
2+
* *************************************************************************************************
3+
*
4+
*
5+
* This file is part of WebGoat, an Open Web Application Security Project
6+
* utility. For details, please see http://www.owasp.org/
7+
*
78
* Copyright (c) 2002 - 20014 Bruce Mayhew
8-
*
9-
* This program is free software; you can redistribute it and/or modify it under the terms of the
10-
* GNU General Public License as published by the Free Software Foundation; either version 2 of the
11-
* License, or (at your option) any later version.
12-
*
13-
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
14-
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15-
* General Public License for more details.
16-
*
17-
* You should have received a copy of the GNU General Public License along with this program; if
18-
* not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19-
* 02111-1307, USA.
20-
*
9+
*
10+
* This program is free software; you can redistribute it and/or modify it under
11+
* the terms of the GNU General Public License as published by the Free Software
12+
* Foundation; either version 2 of the License, or (at your option) any later
13+
* version.
14+
*
15+
* This program is distributed in the hope that it will be useful, but WITHOUT
16+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18+
* details.
19+
*
20+
* You should have received a copy of the GNU General Public License along with
21+
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22+
* Place - Suite 330, Boston, MA 02111-1307, USA.
23+
*
2124
* Getting Source ==============
22-
*
23-
* Source for this application is maintained at https://github.com/WebGoat/WebGoat, a repository for free software
24-
* projects.
25-
*
25+
*
26+
* Source for this application is maintained at
27+
* https://github.com/WebGoat/WebGoat, a repository for free software projects.
28+
*
2629
* For details, please see http://webgoat.github.io
2730
*/
2831
package org.owasp.webgoat.service;
@@ -77,6 +80,13 @@ List<LessonMenuItem> showLeftNav(HttpSession session) {
7780
if (lesson.isCompleted(ws)) {
7881
lessonItem.setComplete(true);
7982
}
83+
if (ws.isAuthorizedInLesson(ws.getRole(), WebSession.SHOWHINTS)) {
84+
lessonItem.setShowHints(true);
85+
}
86+
87+
if (ws.isAuthorizedInLesson(ws.getRole(), WebSession.SHOWSOURCE)) {
88+
lessonItem.setShowSource(true);
89+
}
8090
categoryItem.addChild(lessonItem);
8191
// Does the lesson have stages
8292
if (lesson instanceof RandomLessonAdapter) {

0 commit comments

Comments
 (0)