From a042ee746381ba0765ed5df716fb1e5f79d4df86 Mon Sep 17 00:00:00 2001 From: gregor Date: Mon, 14 Jul 2003 11:42:29 +0000 Subject: Bug 7 fixed. git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@11 d688527b-c9ab-4aba-bd8d-4036d912da1d --- .../spss/server/config/ConfigurationProvider.java | 9 ++++- .../iaik/config/ArchiveConfigurationImpl.java | 43 +++++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) (limited to 'spss.server/src') diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/config/ConfigurationProvider.java b/spss.server/src/at/gv/egovernment/moa/spss/server/config/ConfigurationProvider.java index fbae33b72..c3ba9fe23 100644 --- a/spss.server/src/at/gv/egovernment/moa/spss/server/config/ConfigurationProvider.java +++ b/spss.server/src/at/gv/egovernment/moa/spss/server/config/ConfigurationProvider.java @@ -76,9 +76,16 @@ public class ConfigurationProvider { * The name of the generic configuration property giving the database URL of * the CRL archive. */ - public static final String DATABASE_ARCHIVE_PARAMETER_PROPERTY = + public static final String DATABASE_ARCHIVE_PARAMETER_URL_PROPERTY = "DataBaseArchiveParameter.JDBCUrl"; + /** + * The name of the generic configuration property giving the JDBC driver + * class name for accessing the database used for the the CRL archive. + */ + public static final String DATABASE_ARCHIVE_PARAMETER_DRIVERCLASS_PROPERTY = + "DataBaseArchiveParameter.JDBCDriverClass"; + /** The name of the generic configuration property determining whether * to check the revocation status of signer certificates. */ public static final String REVOCATION_CHECKING_PROPERTY = "checkRevocation"; diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/iaik/config/ArchiveConfigurationImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/server/iaik/config/ArchiveConfigurationImpl.java index 22d798bc3..daff07bd2 100644 --- a/spss.server/src/at/gv/egovernment/moa/spss/server/iaik/config/ArchiveConfigurationImpl.java +++ b/spss.server/src/at/gv/egovernment/moa/spss/server/iaik/config/ArchiveConfigurationImpl.java @@ -4,6 +4,10 @@ import iaik.pki.store.revocation.archive.ArchiveConfiguration; import iaik.pki.store.revocation.archive.ArchiveParameter; import iaik.pki.store.revocation.archive.ArchiveTypes; +import java.sql.Driver; +import java.sql.DriverManager; +import java.util.Enumeration; + import at.gv.egovernment.moa.spss.server.config.ConfigurationProvider; /** @@ -30,11 +34,48 @@ public class ArchiveConfigurationImpl public ArchiveConfigurationImpl(ConfigurationProvider config) { String jdbcUrl = config.getGenericConfiguration( - ConfigurationProvider.DATABASE_ARCHIVE_PARAMETER_PROPERTY); + ConfigurationProvider.DATABASE_ARCHIVE_PARAMETER_URL_PROPERTY); if (jdbcUrl != null) { this.archiveParameters = new DataBaseArchiveParameterImpl(jdbcUrl); } + + // Register JDBC driver class specified in generic configuration parameters + String jdbcDriverClass = config.getGenericConfiguration( + ConfigurationProvider.DATABASE_ARCHIVE_PARAMETER_DRIVERCLASS_PROPERTY); + if (jdbcDriverClass != null) + { + try + { + Class.forName(jdbcDriverClass); + } + catch (ClassNotFoundException e) + { + // TODO 20030709 GK Improve exception handling + throw new RuntimeException("JDBC driver class \"" + jdbcDriverClass + " could not be found."); + } + + Enumeration regDrivers = DriverManager.getDrivers(); + boolean isRegistered = false; + while (regDrivers.hasMoreElements()) + { + Object currentDriver = regDrivers.nextElement(); + if (jdbcDriverClass.equals(currentDriver.getClass().getName())) isRegistered = true; + } + if (!isRegistered) + { + // Workaround for a driver which does not register itselve at invocation of Class.forName(drvname) + try + { + DriverManager.registerDriver((Driver)Class.forName(jdbcDriverClass).newInstance()); + } + catch (Exception e) + { + // TODO 20030709 GK Improve exception handling + throw new RuntimeException("Registering JDBC driver \"" + jdbcDriverClass + " failed."); + } + } + } } /** -- cgit v1.2.3