+ * Copyright (c) 2002 - 20014 Bruce Mayhew + *
+ * 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. + *
+ * 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. + *
+ * 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. + *
+ * Getting Source ============== + *
+ * Source for this application is maintained at https://github.com/WebGoat/WebGoat, a repository for free software + * projects. + *
+ * + * @author WebGoat + * @version $Id: $Id + * @since July 24, 2016 + */ +@Command(name = "webgoat", descriptions = "Start the WebGoat") +public class Main { + + private final Logger logger = LoggerFactory.getLogger(Main.class); + + @Option(opt = {"-p", "--port"}, description = "HTTP port to use") + int port = 6047; + + @Option(opt = {"-a", "--address"}, description = "Server address to use") + String address = "localhost"; + + void run() throws Exception { + String webappDirLocation = "webgoat-container/src/main/webapp/"; + Tomcat tomcat = new Tomcat(); + StandardContext ctx = (StandardContext) tomcat.addWebapp("/", new File(webappDirLocation).getAbsolutePath()); + + Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); + connector.setPort(port); + + if (connector.getProtocolHandler() instanceof AbstractProtocol) { + AbstractProtocol> protocol = (AbstractProtocol>) connector.getProtocolHandler(); + protocol.setAddress(InetAddress.getByName(address)); + protocol.setPort(port); + } + tomcat.getService().addConnector(connector); + tomcat.start(); + logger.info("Browse to http://{}:{}/WebGoat and happy hacking!", address, port); + tomcat.getServer().await(); + } + + + public static void main(String[] args) throws Exception { + OptionParser parser = new OptionParser(Main.class); + parser.parse(args); + } +} \ No newline at end of file diff --git a/webgoat-standalone/src/main/standalone.properties b/webgoat-standalone/src/main/standalone.properties new file mode 100644 index 000000000..12be50b78 --- /dev/null +++ b/webgoat-standalone/src/main/standalone.properties @@ -0,0 +1 @@ +# Dummy property file to figure out whether we started as a war or as a standalone jar \ No newline at end of file