From d5a386b533a3e56006c13c875f6ee80a97569777 Mon Sep 17 00:00:00 2001 From: tknall Date: Tue, 27 Nov 2007 13:39:27 +0000 Subject: serious bug in EGIZDate fixed (comparison was performed in 12-hour-mode, therefore sigs over noon were broken), jce- and ecc-provider are now being registered in Settingsreader git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@231 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java | 13 +++++++++++++ .../knowcenter/wag/egov/egiz/ldap/api/LDAPAPIFactory.java | 11 ----------- .../wag/egov/egiz/ldap/client/LDAPClientFactoryImpl.java | 7 +++++-- src/main/java/at/knowcenter/wag/egov/egiz/pdf/EGIZDate.java | 10 +++++++++- 4 files changed, 27 insertions(+), 14 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov/egiz') 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 b7fcb96..97929af 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 @@ -18,6 +18,11 @@ package at.knowcenter.wag.egov.egiz.cfg; +import iaik.asn1.ObjectID; +import iaik.security.ecc.provider.ECCProvider; +import iaik.security.provider.IAIK; +import iaik.utils.RFC2253NameParser; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -681,5 +686,13 @@ public class SettingsReader implements Serializable CONFIG_PATH = RESOURCES_PATH + CFG + FILE_SEP; CERT_PATH = RESOURCES_PATH + CERT + FILE_SEP; } + + 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); + } } \ No newline at end of file diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/ldap/api/LDAPAPIFactory.java b/src/main/java/at/knowcenter/wag/egov/egiz/ldap/api/LDAPAPIFactory.java index a54d861..3aa16bf 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/ldap/api/LDAPAPIFactory.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/ldap/api/LDAPAPIFactory.java @@ -1,10 +1,5 @@ package at.knowcenter.wag.egov.egiz.ldap.api; -import iaik.asn1.ObjectID; -import iaik.security.ecc.provider.ECCProvider; -import iaik.security.provider.IAIK; -import iaik.utils.RFC2253NameParser; - import org.apache.log4j.Logger; import at.knowcenter.wag.egov.egiz.ldap.client.LDAPIssuerNameFilter; @@ -19,12 +14,6 @@ public abstract class LDAPAPIFactory { private final Logger log = Logger.getLogger(LDAPAPIFactory.class); protected LDAPAPIFactory() { - 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); } public static synchronized LDAPAPIFactory getInstance(LDAPIssuerNameFilter ldapIssuerNameFilter) { diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/ldap/client/LDAPClientFactoryImpl.java b/src/main/java/at/knowcenter/wag/egov/egiz/ldap/client/LDAPClientFactoryImpl.java index bf233a8..1390202 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/ldap/client/LDAPClientFactoryImpl.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/ldap/client/LDAPClientFactoryImpl.java @@ -69,8 +69,11 @@ public final class LDAPClientFactoryImpl extends LDAPClientFactory { } public synchronized LDAPClient createClient(String issuerName) throws LDAPException { - if (issuerName == null || issuerName.length() == 0) { - throw new NullPointerException("Issuer name must not be null or empty."); + if (issuerName == null) { + throw new NullPointerException("Issuer name must not be null."); + } + if (issuerName.length() == 0) { + throw new IllegalArgumentException("Issuer name must not be empty."); } LDAPClient ldapClient = (LDAPClient) ldapClients.get(issuerName); if (ldapClient == null) { diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/EGIZDate.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/EGIZDate.java index a9463b2..ddbea0b 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/EGIZDate.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/EGIZDate.java @@ -164,9 +164,17 @@ public class EGIZDate { LOG.debug("Parsing date string \"" + date_value + "\" returns: " + date); + +// return new EGIZDate(calendar.get(Calendar.YEAR), calendar +// .get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), +// calendar.get(Calendar.HOUR), calendar.get(Calendar.MINUTE), +// calendar.get(Calendar.SECOND)); + + // fixed by tknall: really bad bug: Calendar.HOUR means hour in 12-hour-mode instead f 24-hour. !!!! + // this leads to false comparison of two dates where one date is prior noon and one after noon. return new EGIZDate(calendar.get(Calendar.YEAR), calendar .get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), - calendar.get(Calendar.HOUR), calendar.get(Calendar.MINUTE), + calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND)); } -- cgit v1.2.3