Solution and Java source are optional they don't need to be presnt in a plugin
This commit is contained in:
		| @ -1,5 +1,6 @@ | ||||
| package org.owasp.webgoat.plugins; | ||||
|  | ||||
| import com.google.common.base.Optional; | ||||
| import org.owasp.webgoat.lessons.AbstractLesson; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| @ -61,7 +62,7 @@ public class Plugin { | ||||
|  | ||||
|     private void loadClass(String name, byte[] classFile) { | ||||
|         ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); | ||||
|         PluginClassLoader pluginClassLoader = new PluginClassLoader(contextClassLoader, classFile); | ||||
|         PluginClassLoader pluginClassLoader = new PluginClassLoader(contextClassLoader, name, classFile); | ||||
|         try { | ||||
|             String realClassName = name.replaceFirst("/", "").replaceAll("/", ".").replaceAll(".class", ""); | ||||
|             Class clazz = pluginClassLoader.loadClass(realClassName); | ||||
| @ -128,12 +129,16 @@ public class Plugin { | ||||
|         return lesson; | ||||
|     } | ||||
|  | ||||
|     public Optional<File> getLessonSolution(String language) { | ||||
|         return Optional.fromNullable(this.solutionLanguageFiles.get(language)); | ||||
|     } | ||||
|  | ||||
|     public Map<String, File> getLessonSolutions() { | ||||
|         return this.solutionLanguageFiles; | ||||
|     } | ||||
|  | ||||
|     public File getLessonSource() { | ||||
|         return lessonSourceFile; | ||||
|     public Optional<File> getLessonSource() { | ||||
|         return Optional.fromNullable(lessonSourceFile); | ||||
|     } | ||||
|  | ||||
|     public Map<String, File> getLessonPlans() { | ||||
|  | ||||
| @ -18,7 +18,7 @@ import java.util.Collections; | ||||
| import java.util.Iterator; | ||||
| import java.util.LinkedList; | ||||
| import java.util.List; | ||||
| import java.util.Map | ||||
| import java.util.Map; | ||||
| import javax.servlet.ServletContext; | ||||
|  | ||||
| import org.owasp.webgoat.HammerHead; | ||||
| @ -318,8 +318,12 @@ public class Course { | ||||
|                 for(Map.Entry<String, File> lessonPlan : plugin.getLessonPlans().entrySet()) { | ||||
|                     lesson.setLessonPlanFileName(lessonPlan.getKey(), lessonPlan.getValue().toString()); | ||||
|                 } | ||||
|                 lesson.setLessonSolutionFileName(plugin.getLessonSolutions().get("en").toString()); | ||||
|                 lesson.setSourceFileName(plugin.getLessonSource().toString()); | ||||
|                 if (plugin.getLessonSolution("en").isPresent()) { | ||||
|                     lesson.setLessonSolutionFileName(plugin.getLessonSolution("en").toString()); | ||||
|                 } | ||||
|                 if (plugin.getLessonSource().isPresent()) { | ||||
|                     lesson.setSourceFileName(plugin.getLessonSource().get().toString()); | ||||
|                 } | ||||
|             } catch (Exception e) { | ||||
|                 logger.error("Error in loadLessons: ", e); | ||||
|             } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user