No more yml
This commit is contained in:
parent
22a76624e6
commit
7fe6e1bb6e
@ -0,0 +1,52 @@
|
||||
package org.owasp.webgoat.lessons;
|
||||
|
||||
import org.owasp.webgoat.session.WebSession;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ************************************************************************************************
|
||||
* 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>
|
||||
*
|
||||
* @author WebGoat
|
||||
* @version $Id: $Id
|
||||
* @since October 12, 2016
|
||||
*/
|
||||
public abstract class NewLesson extends LessonAdapter {
|
||||
|
||||
@Override
|
||||
public abstract Category getDefaultCategory();
|
||||
|
||||
@Override
|
||||
public abstract List<String> getHints(WebSession s); //TODO we should probably remove WebSession due to old lessons still here
|
||||
|
||||
@Override
|
||||
public abstract Integer getDefaultRanking();
|
||||
|
||||
@Override
|
||||
public abstract String getTitle();
|
||||
|
||||
@Override
|
||||
public abstract String getId();
|
||||
}
|
@ -5,9 +5,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.owasp.webgoat.lessons.AbstractLesson;
|
||||
import org.owasp.webgoat.lessons.NewLesson;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
@ -33,7 +33,8 @@ public class Plugin {
|
||||
|
||||
private PluginClassLoader classLoader;
|
||||
private Class<AbstractLesson> lesson;
|
||||
private YmlBasedLesson ymlBasedLesson;
|
||||
private YmlBasedLesson ymlBasedLesson; //TODO REMOVE!
|
||||
private Class<NewLesson> newLesson;
|
||||
private Map<String, File> solutionLanguageFiles = new HashMap<>();
|
||||
private Map<String, File> lessonPlansLanguageFiles = new HashMap<>();
|
||||
private List<File> pluginFiles = Lists.newArrayList();
|
||||
@ -64,11 +65,14 @@ public class Plugin {
|
||||
if (AbstractLesson.class.isAssignableFrom(clazz)) {
|
||||
this.lesson = clazz;
|
||||
}
|
||||
if (NewLesson.class.isAssignableFrom(clazz)) {
|
||||
this.newLesson = clazz;
|
||||
}
|
||||
} catch (ClassNotFoundException ce) {
|
||||
throw new PluginLoadingFailure("Class " + realClassName + " listed in jar but unable to load the class.", ce);
|
||||
}
|
||||
|
||||
//New code all lessons should work as below
|
||||
//TODO remove
|
||||
readYmlLessonConfiguration();
|
||||
}
|
||||
|
||||
@ -93,19 +97,6 @@ public class Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
private Class findAttack(String id) {
|
||||
try {
|
||||
for (final ClassPath.ClassInfo info : ClassPath.from(this.classLoader).getTopLevelClasses()) {
|
||||
if (info.getName().endsWith(id)) {
|
||||
return info.load();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>loadFiles.</p>
|
||||
*
|
||||
@ -176,6 +167,9 @@ public class Plugin {
|
||||
if (lesson != null) {
|
||||
return Optional.of(lesson.newInstance());
|
||||
}
|
||||
if (newLesson != null) {
|
||||
return Optional.of(newLesson.newInstance());
|
||||
}
|
||||
|
||||
} catch (IllegalAccessException | InstantiationException e) {
|
||||
throw new PluginLoadingFailure("Unable to instantiate the lesson " + lesson.getName(), e);
|
||||
|
Loading…
x
Reference in New Issue
Block a user