include choice between relative path and reference with context root included
This commit is contained in:
		| @ -38,32 +38,32 @@ import java.util.Map; | ||||
|  | ||||
| /** | ||||
|  * ************************************************************************************************* | ||||
|  * | ||||
|  * | ||||
|  * <p> | ||||
|  * <p> | ||||
|  * This file is part of WebGoat, an Open Web Application Security Project | ||||
|  * utility. For details, please see http://www.owasp.org/ | ||||
|  * | ||||
|  * <p> | ||||
|  * Copyright (c) 2002 - 20014 Bruce Mayhew | ||||
|  * | ||||
|  * <p> | ||||
|  * This program is free software; you can redistribute it and/or modify it under | ||||
|  * the terms of the GNU General Public License as published by the Free Software | ||||
|  * Foundation; either version 2 of the License, or (at your option) any later | ||||
|  * version. | ||||
|  * | ||||
|  * <p> | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||||
|  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||||
|  * details. | ||||
|  * | ||||
|  * <p> | ||||
|  * You should have received a copy of the GNU General Public License along with | ||||
|  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||||
|  * Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
|  * | ||||
|  * <p> | ||||
|  * Getting Source ============== | ||||
|  * | ||||
|  * <p> | ||||
|  * Source for this application is maintained at | ||||
|  * https://github.com/WebGoat/WebGoat, a repository for free software projects. | ||||
|  * | ||||
|  * <p> | ||||
|  * For details, please see http://webgoat.github.io | ||||
|  * | ||||
|  * @author Bruce Mayhew <a href="http://code.google.com/p/webgoat">WebGoat</a> | ||||
| @ -163,8 +163,8 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object | ||||
|     /** | ||||
|      * Gets the credits attribute of the AbstractLesson object | ||||
|      * | ||||
|      * @deprecated - Credits have moved to the about page | ||||
|      * @return The credits value | ||||
|      * @deprecated - Credits have moved to the about page | ||||
|      */ | ||||
|     public abstract Element getCredits(); | ||||
|  | ||||
| @ -316,7 +316,6 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object | ||||
|      * Gets the hintCount attribute of the Lesson object | ||||
|      * | ||||
|      * @param s The user's WebSession | ||||
|      * | ||||
|      * @return The hintCount value | ||||
|      */ | ||||
|     public int getHintCount(WebSession s) { | ||||
| @ -337,7 +336,6 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object | ||||
|      * stuck on somthing silly. | ||||
|      * | ||||
|      * @param s The users WebSession | ||||
|      * | ||||
|      * @return The hint1 value | ||||
|      */ | ||||
|     public String getHint(WebSession s, int hintNumber) { | ||||
| @ -371,7 +369,6 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object | ||||
|      * Gets the content of lessonPlanURL | ||||
|      * | ||||
|      * @param s The user's WebSession | ||||
|      * | ||||
|      * @return The HTML content of the current lesson plan | ||||
|      */ | ||||
|     public String getLessonPlan(WebSession s) { | ||||
| @ -481,7 +478,8 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object | ||||
|             src = ("Could not find the source file or source file does not exist.<br/>" | ||||
|                     + "Send this message to: <a href=\"mailto:" + s.getWebgoatContext().getFeedbackAddress() | ||||
|                     + "?subject=Source " + getSourceFileName() + " not found. Lesson: " | ||||
|                     + s.getCurrentLesson().getLessonName() + "\">" + s.getWebgoatContext().getFeedbackAddress() + "</a>"); | ||||
|                     + s.getCurrentLesson().getLessonName() + "\">" + s.getWebgoatContext() | ||||
|                     .getFeedbackAddress() + "</a>"); | ||||
|         } | ||||
|  | ||||
|         Html html = new Html(); | ||||
| @ -512,7 +510,8 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object | ||||
|             src = ("Could not find the source file or source file does not exist.<br/>" | ||||
|                     + "Send this message to: <a href=\"mailto:" + s.getWebgoatContext().getFeedbackAddress() | ||||
|                     + "?subject=Source " + getSourceFileName() + " not found. Lesson: " | ||||
|                     + s.getCurrentLesson().getLessonName() + "\">" + s.getWebgoatContext().getFeedbackAddress() + "</a>"); | ||||
|                     + s.getCurrentLesson().getLessonName() + "\">" + s.getWebgoatContext() | ||||
|                     .getFeedbackAddress() + "</a>"); | ||||
|         } | ||||
|  | ||||
|         return src; | ||||
| @ -530,7 +529,8 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object | ||||
|             src = ("Could not find the solution file or solution file does not exist.<br/>" | ||||
|                     + "Send this message to: <a href=\"mailto:" + s.getWebgoatContext().getFeedbackAddress() | ||||
|                     + "?subject=Solution " + getLessonSolutionFileName() + " not found. Lesson: " | ||||
|                     + s.getCurrentLesson().getLessonName() + "\">" + s.getWebgoatContext().getFeedbackAddress() + "</a>"); | ||||
|                     + s.getCurrentLesson().getLessonName() + "\">" + s.getWebgoatContext() | ||||
|                     .getFeedbackAddress() + "</a>"); | ||||
|         } | ||||
|  | ||||
|         // Solutions are html files | ||||
| @ -540,12 +540,12 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object | ||||
|     /** | ||||
|      * <p> | ||||
|      * Returns the default "path" portion of a lesson's URL.</p> | ||||
|      * | ||||
|      * <p> | ||||
|      * <p> | ||||
|      * Legacy webgoat lesson links are of the form | ||||
|      * "attack?Screen=Xmenu=Ystage=Z". This method returns the path portion of | ||||
|      * the url, i.e., "attack" in the string above.</p> | ||||
|      * | ||||
|      * <p> | ||||
|      * <p> | ||||
|      * Newer, Spring-Controller-based classes will override this method to | ||||
|      * return "*.do"-styled paths.</p> | ||||
| @ -624,7 +624,7 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object | ||||
|                         .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); | ||||
|                 ResultSet answer_results = answer_statement.executeQuery(query); | ||||
|                 authorized = answer_results.first(); | ||||
|                 logger.info("authorized: "+ authorized); | ||||
|                 logger.info("authorized: " + authorized); | ||||
|             } catch (SQLException sqle) { | ||||
|                 s.setMessage("Error authorizing"); | ||||
|                 logger.error("Error authorizing", sqle); | ||||
| @ -803,22 +803,33 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object | ||||
|     } | ||||
|  | ||||
|     protected LabelManager getLabelManager() { | ||||
|     	if(labelManager == null) { | ||||
|         if (labelManager == null) { | ||||
|             labelManager = BeanProvider.getBean("labelManager", LabelManager.class); | ||||
|         } | ||||
|         return labelManager; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * A reference from an image, script and link tag must include the context path. | ||||
|      * <p> | ||||
|      * A reference in include directives are made from within the web application on the server. | ||||
|      * However, img tags (and the like) make references from the client browser. | ||||
|      * In such external references, the context path must be included. | ||||
|      */ | ||||
|     protected final String buildImagePath(WebSession w, String imgResourceName) { | ||||
|         return w.getRequest().getContextPath() + "/plugin_extracted/plugin/" + getLessonName() + "/images/" + imgResourceName; | ||||
|         return w.getRequest() | ||||
|                 .getContextPath() + "/plugin_extracted/plugin/" + getLessonName() + "/images/" + imgResourceName; | ||||
|     } | ||||
|  | ||||
|     protected final String buildJspPath(WebSession w, String jspResourceName) { | ||||
|         return w.getRequest().getContextPath() + "/plugin_extracted/plugin/" + getLessonName() + "/jsp/" + jspResourceName; | ||||
|  | ||||
|     protected final String buildJspPath(WebSession w, String jspResourceName, boolean includeContextPath) { | ||||
|         String path = includeContextPath ? w.getContext().getContextPath() : ""; | ||||
|         return path + "/plugin_extracted/plugin/" + getLessonName() + "/jsp/" + jspResourceName; | ||||
|     } | ||||
|  | ||||
|     protected final String buildJsPath(WebSession w, String jsResourceName) { | ||||
|         return w.getRequest().getContextPath() + "/plugin_extracted/plugin/" + getLessonName() + "/js/" +  jsResourceName; | ||||
|         return w.getRequest() | ||||
|                 .getContextPath() + "/plugin_extracted/plugin/" + getLessonName() + "/js/" + jsResourceName; | ||||
|     } | ||||
|  | ||||
|     protected final File getLessonDirectory(WebSession w) { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user