diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/ConnectionFactory.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/ConnectionFactory.java new file mode 100644 index 000000000..c94a682d6 --- /dev/null +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/ConnectionFactory.java @@ -0,0 +1,41 @@ +/* + * This file is part of dependency-check-core. + * + * Dependency-check-core 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 3 of the License, or (at your option) any + * later version. + * + * Dependency-check-core 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 + * dependency-check-core. If not, see http://www.gnu.org/licenses/. + * + * Copyright (c) 2014 Jeremy Long. All Rights Reserved. + */ +package org.owasp.dependencycheck.data.nvdcve; + +import java.sql.Connection; + +/** + * When implementing this, use code from the following to load the driver. + * http://stackoverflow.com/questions/5674637/loading-jdbc-driver-at-runtime + * + * + * @author Jeremy Long (jeremy.long@owasp.org) + */ +public final class ConnectionFactory { + + /** + * Private constructor for this factory class; no instance is ever needed. + */ + private ConnectionFactory() { + } + + public static Connection getConnection() { + return null; + } +} diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DriverClassLoader.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DriverClassLoader.java new file mode 100644 index 000000000..808b3f1e2 --- /dev/null +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DriverClassLoader.java @@ -0,0 +1,44 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.owasp.dependencycheck.data.nvdcve; + +import java.io.File; +import java.net.URL; +import java.net.URLClassLoader; + +/** + * + * @author Jeremy Long (jeremy.long@owasp.org) + */ +public class DriverClassLoader extends URLClassLoader { + + /** + * Constructs a new DriverClassLoader that performs a deep copy of the URLs + * in the provided class loader. + * + */ + public DriverClassLoader(File pathToDriver, ClassLoader parent) { + File driverFolder = new File("driver"); + File[] files = driverFolder.listFiles(); + for (File file : files) { + try { + loader.addURL(file.toURI().toURL()); + } catch (MalformedURLException e) { + } + } + + super(urls, parent); + } + + /** + * Add additional URLs to the class loader. + * + * @param url the URL to add to the class loader + */ + @Override + public void addURL(URL url) { + super.addURL(url); + } +}