From 046cb5b235866e66ca9d2c55bd20ed7ec85ef12d Mon Sep 17 00:00:00 2001 From: tknall Date: Wed, 11 Jun 2008 12:09:06 +0000 Subject: Serious bug solved. Method storeCertificate tried to fetch a certificate from store before storing it. If not found (within the store resp. via ldap) the certificate was not stored. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@282 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../wag/egov/egiz/cfg/SettingsReader.java | 52 +++++++--------------- 1 file changed, 16 insertions(+), 36 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/cfg') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java index 31ca5e1..c7e5933 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java @@ -152,11 +152,6 @@ public class SettingsReader implements Serializable // private static final String TEMP_FILE_PATH = // System.getProperty("java.io.tmpdir"); - /** - * The current user path - */ - private static final String USER_DIR = System.getProperty("user.dir"); - // /** // * The home path of the tomcat webaplication // */ @@ -400,7 +395,14 @@ public class SettingsReader implements Serializable logger_.info(" certstore path = \"" + CERT_PATH + "\""); logger_.info(" temporary path = \"" + TMP_PATH + "\""); logger_.info(StringUtils.repeat("*", length + 25)); - instance_ = new SettingsReader(settingsFile); + + IAIK.addAsProvider(); + ECCProvider.addAsProvider(); + // Does not conform with PKIX, but is used by belgium citizen card +// log.info("Registering RDN \"SERIALNUMBER\" as " + ObjectID.serialNumber + "."); + RFC2253NameParser.register("SERIALNUMBER", ObjectID.serialNumber); + + instance_ = new SettingsReader(settingsFile); } return instance_; } @@ -681,17 +683,6 @@ public class SettingsReader implements Serializable TempDirHelper.clearTemporaryDirectory(); } - private static String assertFileSeparator(String path) { - if (path == null) { - throw new NullPointerException("Path must not be null."); - } - if (path.endsWith(File.separator) || path.endsWith("/") || path.endsWith("\\")) { - return path; - } else { - return (path + File.separator); - } - } - public static synchronized void initialize(String configdir, String tmpdir) { String defaultConfigDeployedTo = null; @@ -710,7 +701,7 @@ public class SettingsReader implements Serializable if (userHome == null || userHome.length() == 0) { throw new RuntimeException("Unable to resolve user's home directory."); } - configdir = assertFileSeparator(userHome) + Constants.USERHOME_CONFIG_FOLDER; + configdir = ConfigUtils.assertFileSeparator(userHome) + Constants.USERHOME_CONFIG_FOLDER; try { defaultConfigDeployedTo = ConfigUtils.deployDefaultConfiguration(configdir, false); } catch (ConfigUtilsException e) { @@ -732,9 +723,9 @@ public class SettingsReader implements Serializable } File configdirFile = new File(StrSubstitutor.replaceSystemProperties(configdir)); try { - configdir = assertFileSeparator(configdirFile.getCanonicalPath()); + configdir = ConfigUtils.assertFileSeparator(configdirFile.getCanonicalPath()); } catch (IOException e) { - configdir = assertFileSeparator(configdirFile.getPath()); + configdir = ConfigUtils.assertFileSeparator(configdirFile.getPath()); } if (!configdirFile.isDirectory()) { @@ -752,26 +743,20 @@ public class SettingsReader implements Serializable } else { logger_.debug("Temporary directory explicitely set."); } - File tmpdirFile = new File(StrSubstitutor.replaceSystemProperties(assertFileSeparator(tmpdir) + Constants.TEMP_DIR_NAME)); + File tmpdirFile = new File(StrSubstitutor.replaceSystemProperties(ConfigUtils.assertFileSeparator(tmpdir) + Constants.TEMP_DIR_NAME)); try { - tmpdir = assertFileSeparator(tmpdirFile.getCanonicalPath()); + tmpdir = ConfigUtils.assertFileSeparator(tmpdirFile.getCanonicalPath()); } catch (IOException e) { - tmpdir = assertFileSeparator(tmpdirFile.getPath()); + tmpdir = ConfigUtils.assertFileSeparator(tmpdirFile.getPath()); } RESOURCES_PATH = configdir; TMP_PATH = tmpdir; CONFIG_PATH = RESOURCES_PATH + CFG + FILE_SEP; CERT_PATH = RESOURCES_PATH + CERT + FILE_SEP; + +// ConfigUtils.printConfigInfo(logger_); - int length = Utils.max(new int[] { RESOURCES_PATH.length(), TMP_PATH.length(), CONFIG_PATH.length(), CERT_PATH.length() }); - - logger_.debug(StringUtils.repeat("*", length + 25)); - logger_.debug(" resources path = \"" + RESOURCES_PATH + "\""); - logger_.debug(" configuration path = \"" + CONFIG_PATH + "\""); - logger_.debug(" certstore path = \"" + CERT_PATH + "\""); - logger_.debug(" temporary path = \"" + TMP_PATH + "\""); - logger_.debug(StringUtils.repeat("*", length + 25)); if (defaultConfigDeployedTo != null) { logger_.debug("** Default configuration successfully deployed to \"" + defaultConfigDeployedTo + "\" **"); } @@ -805,11 +790,6 @@ public class SettingsReader implements Serializable } static { - IAIK.addAsProvider(); - ECCProvider.addAsProvider(); - // Does not conform with PKIX, but is used by belgium citizen card -// log.info("Registering RDN \"SERIALNUMBER\" as " + ObjectID.serialNumber + "."); - RFC2253NameParser.register("SERIALNUMBER", ObjectID.serialNumber); String versionString = "* PDF-AS library version " + PdfAS.PDFAS_VERSION + " *"; String paddingString = StringUtils.repeat("*", versionString.length()); -- cgit v1.2.3