plugin_extracted directory should be created if it does not exists
This commit is contained in:
parent
abaa8ac1de
commit
0d79d74ef8
@ -3,19 +3,21 @@ package org.owasp.webgoat.plugins;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public final class GlobalProperties {
|
public final class GlobalProperties {
|
||||||
|
|
||||||
private final Plugin plugin;
|
private final Path pluginDirectory;
|
||||||
|
|
||||||
public GlobalProperties(Path pluginDirectory) {
|
public GlobalProperties(Path pluginDirectory) {
|
||||||
this.plugin = new Plugin(pluginDirectory);
|
this.pluginDirectory = Objects.requireNonNull(pluginDirectory, "pluginDirectory cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadProperties(Path globalPropertiesPath) {
|
public void loadProperties(Path globalPropertiesPath) {
|
||||||
try {
|
try {
|
||||||
|
PluginFileUtils.createDirsIfNotExists(pluginDirectory);
|
||||||
List<Path> filesInDirectory = PluginFileUtils.getFilesInDirectory(globalPropertiesPath);
|
List<Path> filesInDirectory = PluginFileUtils.getFilesInDirectory(globalPropertiesPath);
|
||||||
this.plugin.loadFiles(filesInDirectory, true);
|
new Plugin(pluginDirectory).loadFiles(filesInDirectory, true);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Unable to load global properties, check your installation for the directory i18n: " + globalPropertiesPath.toString(), e);
|
throw new IllegalStateException("Unable to load global properties, check your installation for the directory i18n: " + globalPropertiesPath.toString(), e);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.owasp.webgoat.plugins;
|
package org.owasp.webgoat.plugins;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.owasp.webgoat.classloader.PluginClassLoader;
|
import org.owasp.webgoat.classloader.PluginClassLoader;
|
||||||
import org.owasp.webgoat.lessons.AbstractLesson;
|
import org.owasp.webgoat.lessons.AbstractLesson;
|
||||||
@ -36,11 +37,13 @@ public class Plugin {
|
|||||||
private File lessonSourceFile;
|
private File lessonSourceFile;
|
||||||
|
|
||||||
public Plugin(Path pluginDirectory) {
|
public Plugin(Path pluginDirectory) {
|
||||||
|
Preconditions.checkNotNull(pluginDirectory, "plugin directory cannot be null");
|
||||||
|
Preconditions.checkArgument(Files.exists(pluginDirectory), "directory %s does not exists", pluginDirectory);
|
||||||
this.pluginDirectory = pluginDirectory;
|
this.pluginDirectory = pluginDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Plugin(Path pluginDirectory, List<String> classes) {
|
public Plugin(Path pluginDirectory, List<String> classes) {
|
||||||
this.pluginDirectory = pluginDirectory;
|
this(pluginDirectory);
|
||||||
findLesson(classes);
|
findLesson(classes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ public class PluginsLoader implements Runnable {
|
|||||||
List<Plugin> plugins = Lists.newArrayList();
|
List<Plugin> plugins = Lists.newArrayList();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
PluginFileUtils.createDirsIfNotExists(pluginTarget);
|
||||||
List<URL> jars = listJars();
|
List<URL> jars = listJars();
|
||||||
cl.addURL(jars);
|
cl.addURL(jars);
|
||||||
plugins = processPlugins(jars, reload);
|
plugins = processPlugins(jars, reload);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user