plugin_extracted directory should be created if it does not exists
This commit is contained in:
		| @ -3,19 +3,21 @@ package org.owasp.webgoat.plugins; | ||||
| import java.io.IOException; | ||||
| import java.nio.file.Path; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
|  | ||||
| public final class GlobalProperties { | ||||
|  | ||||
|     private final Plugin plugin; | ||||
|     private final 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) { | ||||
|         try { | ||||
|             PluginFileUtils.createDirsIfNotExists(pluginDirectory); | ||||
|             List<Path> filesInDirectory = PluginFileUtils.getFilesInDirectory(globalPropertiesPath); | ||||
|             this.plugin.loadFiles(filesInDirectory, true); | ||||
|             new Plugin(pluginDirectory).loadFiles(filesInDirectory, true); | ||||
|         } catch (IOException 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; | ||||
|  | ||||
| import com.google.common.base.Optional; | ||||
| import com.google.common.base.Preconditions; | ||||
| import com.google.common.collect.Lists; | ||||
| import org.owasp.webgoat.classloader.PluginClassLoader; | ||||
| import org.owasp.webgoat.lessons.AbstractLesson; | ||||
| @ -36,11 +37,13 @@ public class Plugin { | ||||
|     private File lessonSourceFile; | ||||
|  | ||||
|     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; | ||||
|     } | ||||
|  | ||||
|     public Plugin(Path pluginDirectory, List<String> classes) { | ||||
|         this.pluginDirectory = pluginDirectory; | ||||
|         this(pluginDirectory); | ||||
|         findLesson(classes); | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -38,6 +38,7 @@ public class PluginsLoader implements Runnable { | ||||
|         List<Plugin> plugins = Lists.newArrayList(); | ||||
|  | ||||
|         try { | ||||
|             PluginFileUtils.createDirsIfNotExists(pluginTarget); | ||||
|             List<URL> jars = listJars(); | ||||
|             cl.addURL(jars); | ||||
|             plugins = processPlugins(jars, reload); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user