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