diff --git a/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/SoapRequest.java b/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/SoapRequest.java index f2218b09f..49d198258 100644 --- a/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/SoapRequest.java +++ b/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/SoapRequest.java @@ -409,7 +409,7 @@ public class SoapRequest extends LessonAdapter { try { - Connection connection = DatabaseUtilities.makeConnection(); + Connection connection = DatabaseUtilities.makeConnection(getWebgoatContext()); if (connection == null) { return null; diff --git a/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/WSDLScanning.java b/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/WSDLScanning.java index c4cf058a0..59958daed 100644 --- a/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/WSDLScanning.java +++ b/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/WSDLScanning.java @@ -271,7 +271,7 @@ public class WSDLScanning extends LessonAdapter { try { - Connection connection = DatabaseUtilities.makeConnection(); + Connection connection = DatabaseUtilities.makeConnection(getWebgoatContext()); if (connection == null) { return null; diff --git a/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/WsSqlInjection.java b/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/WsSqlInjection.java index e20b004d6..b40690718 100644 --- a/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/WsSqlInjection.java +++ b/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/WsSqlInjection.java @@ -226,7 +226,7 @@ public class WsSqlInjection extends LessonAdapter { try { - Connection connection = DatabaseUtilities.makeConnection(); + Connection connection = DatabaseUtilities.makeConnection(getWebgoatContext()); if (connection == null) { return null; diff --git a/ webgoat/main/project/JavaSource/org/owasp/webgoat/session/DatabaseUtilities.java b/ webgoat/main/project/JavaSource/org/owasp/webgoat/session/DatabaseUtilities.java index eb209b8bd..624d872ca 100644 --- a/ webgoat/main/project/JavaSource/org/owasp/webgoat/session/DatabaseUtilities.java +++ b/ webgoat/main/project/JavaSource/org/owasp/webgoat/session/DatabaseUtilities.java @@ -47,9 +47,6 @@ import org.apache.ecs.html.Table; public class DatabaseUtilities { - public static String servletContextRealPath = null; - - /** * Description of the Method * @@ -81,51 +78,6 @@ public class DatabaseUtilities } } - - public static Connection makeConnection(String driverName, - String connectionString) throws ClassNotFoundException, - SQLException - { - Class.forName(driverName); - - return (DriverManager.getConnection(connectionString)); - } - - - public static Connection makeConnection() - { - try - { - // FIXME: Work around for not having a session object with the web service lessons - // This is the same "logic" in the web.xml file - // Get the path to webgoat database - - String dbName = (servletContextRealPath + "database" + File.separator); - String os = System.getProperty("os.name", "Windows"); - if (os.toLowerCase().indexOf("window") != -1) - { - dbName = dbName.concat("webgoat.mdb"); - System.out.println("DBName: " + dbName); - Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); - return DriverManager - .getConnection("jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ=" - + dbName + ";PWD=webgoat"); - } - else - { - dbName = dbName.concat("database.prp"); - Class.forName("org.enhydra.instantdb.jdbc.idbDriver"); - return DriverManager.getConnection("jdbc:idb:" + dbName); - } - } - catch (Exception e) - { - e.printStackTrace(); - return null; - } - } - - /** * Description of the Method * diff --git a/ webgoat/main/project/JavaSource/org/owasp/webgoat/session/WebgoatContext.java b/ webgoat/main/project/JavaSource/org/owasp/webgoat/session/WebgoatContext.java index e36d6fa99..b149f9c60 100755 --- a/ webgoat/main/project/JavaSource/org/owasp/webgoat/session/WebgoatContext.java +++ b/ webgoat/main/project/JavaSource/org/owasp/webgoat/session/WebgoatContext.java @@ -38,9 +38,6 @@ public class WebgoatContext { databaseUser = servlet.getInitParameter(DATABASE_USER); databasePassword = servlet.getInitParameter(DATABASE_PASSWORD); - // FIXME: hack to save context for web service calls - DatabaseUtilities.servletContextRealPath = servlet.getServletContext().getRealPath("/"); - System.out.println("Context Path: " + DatabaseUtilities.servletContextRealPath); // FIXME: need to solve concurrency problem here -- make tables for this user if ( !databaseBuilt ) { try {