From a67ed8406bb7f9d4bca48891308e7bfead90efe4 Mon Sep 17 00:00:00 2001 From: gregor Date: Thu, 11 Aug 2005 13:22:41 +0000 Subject: =?UTF-8?q?Bug=20271:=20Adpation=20auf=20neue=20Struktur=20des=20K?= =?UTF-8?q?onfigurationsfiles=20abgeschlossen.=20Modultests=20durchgef?= =?UTF-8?q?=C3=BChrt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@436 d688527b-c9ab-4aba-bd8d-4036d912da1d --- .../res/resources/schemas/MOA-SPSS-config-1.3.xsd | 2 +- .../handbook/config/MOA-SPSS-config-1.3.xsd | 2 +- .../properties/spss_messages_de.properties | 2 +- .../res/test/resources/config/log4j.properties | 10 + .../test/resources/config/moa.sp.noopts-config.xml | 32 ++ .../resources/config/moa.spss.complete-config.xml | 26 +- .../test/resources/config/moa.ss.noopts-config.xml | 31 ++ .../test/resources/config/profiles/csep/CSEP_1.xml | 4 + .../test/resources/config/profiles/ctip/CTIP_1.xml | 8 + .../test/resources/config/profiles/ctip/CTIP_2.xml | 8 + .../res/test/resources/config/profiles/sp/SP_1.xml | 4 + .../test/resources/config/profiles/vtip/VTIP_1.xml | 2 + .../test/resources/config/swk/SWK1_FileName.txt | 0 .../test/resources/config/swk/SWK2_FileName.txt | 0 .../server/config/ConfigurationPartsBuilder.java | 41 ++- .../spss/server/config/ConfigurationProvider.java | 2 +- .../test/at/gv/egovernment/moa/spss/AllTests.java | 3 +- .../moa/spss/server/config/AllTests.java | 20 ++ .../server/config/ConfigurationProviderTest.java | 332 ------------------ .../server/config/ConfigurationProviderTest1.java | 370 +++++++++++++++++++++ .../server/config/ConfigurationProviderTest2.java | 225 +++++++++++++ .../server/config/ConfigurationProviderTest3.java | 166 +++++++++ 22 files changed, 923 insertions(+), 367 deletions(-) create mode 100644 spss.server/res/test/resources/config/log4j.properties create mode 100644 spss.server/res/test/resources/config/moa.sp.noopts-config.xml create mode 100644 spss.server/res/test/resources/config/moa.ss.noopts-config.xml create mode 100644 spss.server/res/test/resources/config/profiles/csep/CSEP_1.xml create mode 100644 spss.server/res/test/resources/config/profiles/ctip/CTIP_1.xml create mode 100644 spss.server/res/test/resources/config/profiles/ctip/CTIP_2.xml create mode 100644 spss.server/res/test/resources/config/profiles/sp/SP_1.xml create mode 100644 spss.server/res/test/resources/config/profiles/vtip/VTIP_1.xml create mode 100644 spss.server/res/test/resources/config/swk/SWK1_FileName.txt create mode 100644 spss.server/res/test/resources/config/swk/SWK2_FileName.txt create mode 100644 spss.server/src/test/at/gv/egovernment/moa/spss/server/config/AllTests.java delete mode 100644 spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest.java create mode 100644 spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest1.java create mode 100644 spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest2.java create mode 100644 spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest3.java diff --git a/common/res/resources/schemas/MOA-SPSS-config-1.3.xsd b/common/res/resources/schemas/MOA-SPSS-config-1.3.xsd index 279311514..57f84eba7 100644 --- a/common/res/resources/schemas/MOA-SPSS-config-1.3.xsd +++ b/common/res/resources/schemas/MOA-SPSS-config-1.3.xsd @@ -115,7 +115,7 @@ - + diff --git a/spss.handbook/handbook/config/MOA-SPSS-config-1.3.xsd b/spss.handbook/handbook/config/MOA-SPSS-config-1.3.xsd index 279311514..57f84eba7 100644 --- a/spss.handbook/handbook/config/MOA-SPSS-config-1.3.xsd +++ b/spss.handbook/handbook/config/MOA-SPSS-config-1.3.xsd @@ -115,7 +115,7 @@ - + diff --git a/spss.server/res/resources/properties/spss_messages_de.properties b/spss.server/res/resources/properties/spss_messages_de.properties index d7dd17464..ee65d561f 100644 --- a/spss.server/res/resources/properties/spss_messages_de.properties +++ b/spss.server/res/resources/properties/spss_messages_de.properties @@ -102,7 +102,7 @@ init.03=Fehler beim Aktivieren des IAIK-JCE/JSSE/JDK1.3 Workaround: SSL ist m init.04=Fehler beim Initialisieren des Schema Pools config.00=Fehler beim Erstellen des KeyGroupMapping: KeyGroup mit id={0} unbekannt - die Erstellung des KeyGroupMapping wird fortgeführt -config.01=Fehler in der Konfiguration: kein gültiger Wert für CRLArchive/duration +config.01=Fehler in der Konfiguration: Wert für maximale Archivierungsdauer von Widerrufsinformationen (ArchiveDuration) nicht konfiguriert oder ungültig config.02=Fehler in der Konfiguration: {0} mit id={1}: falscher Profiltyp in Datei {2} config.03=Fehler in der Konfiguration: {0} mit id={1} konnte nicht geladen werden config.04=Fehler in der Konfiguration: {0} mit id={1} existiert bereits diff --git a/spss.server/res/test/resources/config/log4j.properties b/spss.server/res/test/resources/config/log4j.properties new file mode 100644 index 000000000..c37455300 --- /dev/null +++ b/spss.server/res/test/resources/config/log4j.properties @@ -0,0 +1,10 @@ +# commons-logging setup +org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4jFactory + +# Configure root logger and loggers for moa-spss +log4j.rootLogger=debug, stdout + +# Configure the 'stdout' appender to write logging output to the console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%5p | %d{dd HH:mm:ss,SSS} | %20c | %10t | %m%n diff --git a/spss.server/res/test/resources/config/moa.sp.noopts-config.xml b/spss.server/res/test/resources/config/moa.sp.noopts-config.xml new file mode 100644 index 000000000..43374c81e --- /dev/null +++ b/spss.server/res/test/resources/config/moa.sp.noopts-config.xml @@ -0,0 +1,32 @@ + + + + + + false + false + + + certstore + + + + + + pkix + + + TP1_Id + trustprofiles/tp1/anchors + + + + false + 10000 + + false + + + + + diff --git a/spss.server/res/test/resources/config/moa.spss.complete-config.xml b/spss.server/res/test/resources/config/moa.spss.complete-config.xml index f0cbb9cdb..ce0c47a94 100644 --- a/spss.server/res/test/resources/config/moa.spss.complete-config.xml +++ b/spss.server/res/test/resources/config/moa.spss.complete-config.xml @@ -1,7 +1,5 @@ - - + HWC1_Name HWC1_SlotId @@ -26,12 +24,12 @@ E:\cio\projekte\basismodule\wartung\projekt\common\res\resources\schemas\MOA-SPS SWK1_Id - SWK1_FileName + swk/SWK1_FileName.txt SWK1_Password SWK2_Id - SWK1_FileName + swk/SWK2_FileName.txt @@ -74,15 +72,15 @@ E:\cio\projekte\basismodule\wartung\projekt\common\res\resources\schemas\MOA-SPS 4 KG1_Id - KK2_Id + KG2_Id KG1_Id - KK2_Id + KG2_Id - http://an.c14n.alg - http://a.digest.method + http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments + http://www.w3.org/2000/09/xmldsig#sha1 CTIP_1 @@ -94,7 +92,7 @@ E:\cio\projekte\basismodule\wartung\projekt\common\res\resources\schemas\MOA-SPS CSEP_1 - profiles/csep/CESP_1.xml + profiles/csep/CSEP_1.xml @@ -104,7 +102,7 @@ E:\cio\projekte\basismodule\wartung\projekt\common\res\resources\schemas\MOA-SPS false - certstore + certstore_test @@ -113,7 +111,7 @@ E:\cio\projekte\basismodule\wartung\projekt\common\res\resources\schemas\MOA-SPS pkix - + CN=TA1_Issuer 5 chaining @@ -133,8 +131,8 @@ E:\cio\projekte\basismodule\wartung\projekt\common\res\resources\schemas\MOA-SPS TP2_Id - file:e:/cio/projekte/basismodule/wartung/projekt/spss.server/res/test/resources/config/trustprofiles/tp2/anchors/ - file:e:/cio/projekte/basismodule/wartung/projekt/spss.server/res/test/resources/config/trustprofiles/tp2/signercerts/ + file:e:/cio/projekte/basismodule/wartung/projekt/spss.server/res/test/resources/config/trustprofiles/tp2/anchors + file:e:/cio/projekte/basismodule/wartung/projekt/spss.server/res/test/resources/config/trustprofiles/tp2/signercerts diff --git a/spss.server/res/test/resources/config/moa.ss.noopts-config.xml b/spss.server/res/test/resources/config/moa.ss.noopts-config.xml new file mode 100644 index 000000000..af910ee3c --- /dev/null +++ b/spss.server/res/test/resources/config/moa.ss.noopts-config.xml @@ -0,0 +1,31 @@ + + + + + + HWK1_Id + HWK1_Name + HWK1_SlotId + HWK1_UserPIN + + + + KG1_Id + + HWK1_Id + + CN=HWK1_Issuer + 0 + + + + + + CN=Customer1_Issuer + 4 + + KG1_Id + + + + diff --git a/spss.server/res/test/resources/config/profiles/csep/CSEP_1.xml b/spss.server/res/test/resources/config/profiles/csep/CSEP_1.xml new file mode 100644 index 000000000..c51d6beaf --- /dev/null +++ b/spss.server/res/test/resources/config/profiles/csep/CSEP_1.xml @@ -0,0 +1,4 @@ + + + + diff --git a/spss.server/res/test/resources/config/profiles/ctip/CTIP_1.xml b/spss.server/res/test/resources/config/profiles/ctip/CTIP_1.xml new file mode 100644 index 000000000..4cc6d4f65 --- /dev/null +++ b/spss.server/res/test/resources/config/profiles/ctip/CTIP_1.xml @@ -0,0 +1,8 @@ + + + + + text/plain + + + diff --git a/spss.server/res/test/resources/config/profiles/ctip/CTIP_2.xml b/spss.server/res/test/resources/config/profiles/ctip/CTIP_2.xml new file mode 100644 index 000000000..4cc6d4f65 --- /dev/null +++ b/spss.server/res/test/resources/config/profiles/ctip/CTIP_2.xml @@ -0,0 +1,8 @@ + + + + + text/plain + + + diff --git a/spss.server/res/test/resources/config/profiles/sp/SP_1.xml b/spss.server/res/test/resources/config/profiles/sp/SP_1.xml new file mode 100644 index 000000000..7d69058d7 --- /dev/null +++ b/spss.server/res/test/resources/config/profiles/sp/SP_1.xml @@ -0,0 +1,4 @@ + + + + diff --git a/spss.server/res/test/resources/config/profiles/vtip/VTIP_1.xml b/spss.server/res/test/resources/config/profiles/vtip/VTIP_1.xml new file mode 100644 index 000000000..f97c2a78a --- /dev/null +++ b/spss.server/res/test/resources/config/profiles/vtip/VTIP_1.xml @@ -0,0 +1,2 @@ + + diff --git a/spss.server/res/test/resources/config/swk/SWK1_FileName.txt b/spss.server/res/test/resources/config/swk/SWK1_FileName.txt new file mode 100644 index 000000000..e69de29bb diff --git a/spss.server/res/test/resources/config/swk/SWK2_FileName.txt b/spss.server/res/test/resources/config/swk/SWK2_FileName.txt new file mode 100644 index 000000000..e69de29bb diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/config/ConfigurationPartsBuilder.java b/spss.server/src/at/gv/egovernment/moa/spss/server/config/ConfigurationPartsBuilder.java index e1681690f..d61b995dc 100644 --- a/spss.server/src/at/gv/egovernment/moa/spss/server/config/ConfigurationPartsBuilder.java +++ b/spss.server/src/at/gv/egovernment/moa/spss/server/config/ConfigurationPartsBuilder.java @@ -99,8 +99,8 @@ public class ConfigurationPartsBuilder { ROOT + CONF + "SignatureVerification/" + CONF + "CertificateValidation/" + CONF + "PathConstruction/" - + CONF + "CertificateStore" - + CONF + "DirectoryStore" + + CONF + "CertificateStore/" + + CONF + "DirectoryStore/" + CONF + "Location"; private static final String AUTO_ADD_CERTIFICATES_XPATH_ = ROOT + CONF + "SignatureVerification/" @@ -118,10 +118,10 @@ public class ConfigurationPartsBuilder { + CONF + "PathValidation/" + CONF + "ChainingMode"; private static final String CHAINING_MODES_DEFAULT_XPATH = - CHAINING_MODES_XPATH - + CONF + "/DefaultMode"; + CHAINING_MODES_XPATH + "/" + + CONF + "DefaultMode"; private static final String TRUST_ANCHOR_XPATH = - CHAINING_MODES_XPATH + CHAINING_MODES_XPATH + "/" + CONF + "TrustAnchor"; private static final String TRUST_PROFILE_XPATH = ROOT + CONF + "SignatureVerification/" @@ -132,7 +132,7 @@ public class ConfigurationPartsBuilder { ROOT + CONF + "SignatureVerification/" + CONF + "CertificateValidation/" + CONF + "RevocationChecking/" - + CONF + "DistributionPoints"; + + CONF + "DistributionPoint"; private static final String ENABLE_REVOCATION_CHECKING_XPATH_ = ROOT + CONF + "SignatureVerification/" + CONF + "CertificateValidation/" @@ -147,7 +147,7 @@ public class ConfigurationPartsBuilder { ROOT + CONF + "SignatureVerification/" + CONF + "CertificateValidation/" + CONF + "RevocationChecking/" - + CONF + "ServiceOrder" + + CONF + "ServiceOrder/" + CONF + "Service"; private static final String ENABLE_ARCHIVING_XPATH = ROOT + CONF + "SignatureVerification/" @@ -167,7 +167,7 @@ public class ConfigurationPartsBuilder { + CONF + "RevocationChecking/" + CONF + "Archiving/" + CONF + "Archive/" - + CONF + "DatabaseArchive" + + CONF + "DatabaseArchive/" + CONF + "JDBCURL"; private static final String ACHIVE_JDBC_DRIVER_CLASS_ = ROOT + CONF + "SignatureVerification/" @@ -175,7 +175,7 @@ public class ConfigurationPartsBuilder { + CONF + "RevocationChecking/" + CONF + "Archiving/" + CONF + "Archive/" - + CONF + "DatabaseArchive" + + CONF + "DatabaseArchive/" + CONF + "JDBCDriverClassName"; private static final String CREATE_TRANSFORMS_INFO_PROFILE_XPATH = ROOT + CONF + "SignatureCreation/" @@ -396,7 +396,7 @@ public class ConfigurationPartsBuilder { while ((keyElem = (Element) skIter.nextNode()) != null) { String id = getElementValue(keyElem, CONF + "Id", null); - String fileName = getElementValue(keyElem, CONF + "Filename", null); + String fileName = getElementValue(keyElem, CONF + "FileName", null); String passWord = getElementValue(keyElem, CONF + "Password", null); if (existingIds.contains(id)) @@ -510,7 +510,7 @@ public class ConfigurationPartsBuilder { while ((keyEntryElem = (Element) keyEntryIter.nextNode()) != null) { String keyModuleId = getElementValue(keyEntryElem, CONF + "KeyModuleId", ""); - Element keyCertElem = (Element) XPathUtils.selectSingleNode(keyEntryElem, CONF + "KeyCertIsuerSerial"); + Element keyCertElem = (Element) XPathUtils.selectSingleNode(keyEntryElem, CONF + "KeyCertIssuerSerial"); IssuerAndSerial issuerSerial = buildIssuerAndSerial(keyCertElem); if (!keyModuleIds.contains(keyModuleId)) { @@ -601,7 +601,7 @@ public class ConfigurationPartsBuilder { String defaultChaining = getElementValue( getConfigElem(), CHAINING_MODES_DEFAULT_XPATH, - CM_CHAINING); + CM_PKIX); return translateChainingMode(defaultChaining); @@ -726,7 +726,7 @@ public class ConfigurationPartsBuilder { Element oCSPPElem; while ((oCSPPElem = (Element) oCSPDPPIter.nextNode()) != null) { - OCSPDistributionPoint oCSPDP = (OCSPDistributionPoint) buildDistributionPoint(cRLDPElem, null); + OCSPDistributionPoint oCSPDP = (OCSPDistributionPoint) buildDistributionPoint(oCSPPElem, null); dPsForCA.add(oCSPDP); } } @@ -764,7 +764,7 @@ public class ConfigurationPartsBuilder { if (reasonCodesSB.length() > 0) reasonCodesSB.append(" "); reasonCodesSB.append(getElementValue(reasonCodeElem, ".", "").trim()); } - return new CRLDistributionPoint(uri, reasonCodesSB.toString(), issuerName); + return new CRLDistributionPoint(issuerName, uri, reasonCodesSB.toString()); } else { @@ -995,6 +995,10 @@ public class ConfigurationPartsBuilder { String certStoreLocStr = getElementValue(getConfigElem(), CERTSTORE_LOCATION_XPATH, null); File certStoreLocFile; + // No value specified in configuration file: Set it to a reasonable (absolute) default + if (certStoreLocStr == null) + return new File(configRoot_, "certstore").getAbsolutePath(); + // Make cert store location an absolute value certStoreLocFile = new File(certStoreLocStr); if (!certStoreLocFile.isAbsolute()) @@ -1170,6 +1174,7 @@ public class ConfigurationPartsBuilder { public long getMaxRevocationAge() { String maxRevocationAge = getElementValue(getConfigElem(), MAX_REVOCATION_AGE_XPATH_, null); + if (maxRevocationAge == null) return 0; return Long.valueOf(maxRevocationAge).longValue(); } @@ -1190,7 +1195,13 @@ public class ConfigurationPartsBuilder { { list.add(getElementValue(currentServiceNode, ".", null)); } - return (String[])list.toArray(); + Object[] serviceOrder = list.toArray(); + String[] returnValue = new String[serviceOrder.length]; + for (int i = 0; i < serviceOrder.length; i++) + { + returnValue[i] = (String)serviceOrder[i]; + } + return returnValue; } /** 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 a6cbcc159..e48835286 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 @@ -304,6 +304,7 @@ public class ConfigurationProvider chainingModes = builder.buildChainingModes(); useAuthorityInfoAccess_ = builder.getUseAuthorityInfoAccess(); autoAddCertificates_ = builder.getAutoAddCertificates(); + trustProfiles = builder.buildTrustProfiles(); distributionPoints = builder.buildDistributionPoints(); enableRevocationChecking_ = builder.getEnableRevocationChecking(); maxRevocationAge_ = builder.getMaxRevocationAge(); @@ -317,7 +318,6 @@ public class ConfigurationProvider createSignatureEnvironmentProfiles = builder.buildCreateSignatureEnvironmentProfiles(); verifyTransformsInfoProfiles = builder.buildVerifyTransformsInfoProfiles(); supplementProfiles = builder.buildSupplementProfiles(); - trustProfiles = builder.buildTrustProfiles(); warnings = new ArrayList(builder.getWarnings()); } catch (Throwable t) { throw new ConfigurationException("config.11", null, t); diff --git a/spss.server/src/test/at/gv/egovernment/moa/spss/AllTests.java b/spss.server/src/test/at/gv/egovernment/moa/spss/AllTests.java index 9935685d0..c670b5e55 100644 --- a/spss.server/src/test/at/gv/egovernment/moa/spss/AllTests.java +++ b/spss.server/src/test/at/gv/egovernment/moa/spss/AllTests.java @@ -1,6 +1,5 @@ package test.at.gv.egovernment.moa.spss; -import test.at.gv.egovernment.moa.spss.server.config.ConfigurationProviderTest; import test.at.gv.egovernment.moa.spss.server.iaik.config.ConfigurationDataImplTest; import test.at.gv.egovernment.moa.spss.server.iaik.config.IaikConfiguratorTest; import test.at.gv.egovernment.moa.spss.server.tools.CertToolTest; @@ -20,7 +19,7 @@ public class AllTests { public static Test suite() { TestSuite suite = new TestSuite(); - suite.addTestSuite(ConfigurationProviderTest.class); + suite.addTestSuite(test.at.gv.egovernment.moa.spss.server.config.AllTests.class); suite.addTestSuite(ConfigurationDataImplTest.class); suite.addTestSuite(IaikConfiguratorTest.class); suite.addTest( diff --git a/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/AllTests.java b/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/AllTests.java new file mode 100644 index 000000000..131f38c19 --- /dev/null +++ b/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/AllTests.java @@ -0,0 +1,20 @@ +package test.at.gv.egovernment.moa.spss.server.config; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * @author Gregor Karlinger + * @version $Id$ + */ +public class AllTests +{ + public static Test suite() + { + TestSuite suite = new TestSuite(); + suite.addTestSuite(ConfigurationProviderTest1.class); + suite.addTestSuite(ConfigurationProviderTest2.class); + suite.addTestSuite(ConfigurationProviderTest3.class); + return suite; + } +} diff --git a/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest.java b/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest.java deleted file mode 100644 index 68191477e..000000000 --- a/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest.java +++ /dev/null @@ -1,332 +0,0 @@ -package test.at.gv.egovernment.moa.spss.server.config; - -import iaik.asn1.structures.Name; -import iaik.utils.RFC2253NameParser; -import iaik.utils.RFC2253NameParserException; -import iaik.x509.X509Certificate; - -import java.math.BigInteger; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import junit.framework.TestCase; - -import org.w3c.dom.Element; - -import at.gv.egovernment.moa.spss.MOAException; -import at.gv.egovernment.moa.spss.server.config.CRLDistributionPoint; -import at.gv.egovernment.moa.spss.server.config.HardwareCryptoModule; -import at.gv.egovernment.moa.spss.server.config.HardwareKeyModule; -import at.gv.egovernment.moa.spss.server.config.KeyGroup; -import at.gv.egovernment.moa.spss.server.config.KeyGroupEntry; -import at.gv.egovernment.moa.spss.server.config.OCSPDistributionPoint; -import at.gv.egovernment.moa.spss.server.config.SoftwareKeyModule; -import at.gv.egovernment.moa.spss.server.config.TrustProfile; - -/** - * @author Gregor Karlinger - * @version $Id$ - */ -public class ConfigurationProviderTest extends TestCase -{ - private static final String CONFIG_BASE_ = - "e:/cio/projekte/basismodule/wartung/projekt/spss.server/res/test/resources/config/"; - - at.gv.egovernment.moa.spss.server.config.ConfigurationProvider provider_; - - /** - * Constructor for ConfigurationProvider. - * @param arg0 - */ - public ConfigurationProviderTest() throws MOAException - { - super("ConfigurationProvider"); - System.setProperty( - at.gv.egovernment.moa.spss.server.config.ConfigurationProvider.CONFIG_PROPERTY_NAME, - CONFIG_BASE_ + "moa.spss.complete-config.xml"); - provider_ = at.gv.egovernment.moa.spss.server.config.ConfigurationProvider.getInstance(); - } - - public void testGetWarnings() - { - assertEquals(0, provider_.getWarnings().size()); - } - - public void testGetDigestMethodAlgorithmName() - { - assertEquals( - "http://a.digest.method", - provider_.getDigestMethodAlgorithmName()); - } - - public void testGetCanonicalizationAlgorithmName() - { - assertEquals( - "http://an.c14n.alg", - provider_.getDigestMethodAlgorithmName()); - } - - public void testGetHardwareCryptoModules() - { - List hwcms = provider_.getHardwareCryptoModules(); - assertEquals(2, hwcms.size()); - - HardwareCryptoModule hwc1 = (HardwareCryptoModule) hwcms.get(0); - assertEquals("HWC1_Name", hwc1.getName()); - assertEquals("HWC1_SlotId", hwc1.getSlotID()); - assertEquals("HWC1_UserPIN", hwc1.getUserPIN()); - - HardwareCryptoModule hwc2 = (HardwareCryptoModule) hwcms.get(1); - assertEquals("HWC2_Name", hwc2.getName()); - assertNull(hwc1.getSlotID()); - assertEquals("HWC2_UserPIN", hwc2.getUserPIN()); - } - - public void testGetHardwareKeyModules() - { - List hwkms = provider_.getHardwareKeyModules(); - assertEquals(2, hwkms.size()); - - HardwareKeyModule hwk1 = (HardwareKeyModule) hwkms.get(0); - assertEquals("HWK1_Id", hwk1.getId()); - assertEquals("HWK1_Name", hwk1.getName()); - assertEquals("HWK1_SlotId", hwk1.getSlotID()); - assertEquals("HWK1_UserPIN", hwk1.getUserPIN()); - - HardwareKeyModule hwk2 = (HardwareKeyModule) hwkms.get(1); - assertEquals("HWK2_Id", hwk2.getId()); - assertEquals("HWK2_Name", hwk2.getName()); - assertNull(hwk2.getSlotID()); - assertEquals("HWK2_UserPIN", hwk2.getUserPIN()); - } - - public void testGetSoftwareKeyModules() - { - List swkms = provider_.getSoftwareKeyModules(); - assertEquals(2, swkms.size()); - - SoftwareKeyModule swk1 = (SoftwareKeyModule) swkms.get(0); - assertEquals("SWK1_Id", swk1.getId()); - assertEquals("SWK1_FileName", swk1.getFileName()); - assertEquals("SWK1_Password", swk1.getPassWord()); - - SoftwareKeyModule swk2 = (SoftwareKeyModule) swkms.get(1); - assertEquals("HWK2_Id", swk2.getId()); - assertEquals("SWK1_FileName", swk2.getFileName()); - assertNull(swk2.getPassWord()); - } - - public void testGetKeyGroups() - { - Map keyGroups = provider_.getKeyGroups(); - assertEquals(2, keyGroups.size()); - - KeyGroup kg1 = (KeyGroup) keyGroups.get("KG1_Id"); - assertNotNull(kg1); - assertEquals("KG1_Id", kg1.getId()); - - Set kg1Entries = kg1.getKeyGroupEntries(); - assertEquals(2, kg1Entries.size()); - - KeyGroupEntry kg1Entry1 = (KeyGroupEntry) kg1Entries.toArray()[0]; - assertEquals("HWK1_Id", kg1Entry1.getModuleID()); - assertEquals("HWK1_Issuer", kg1Entry1.getIssuerDN()); - assertEquals(0, kg1Entry1.getSerialNumber().intValue()); - - KeyGroupEntry kg1Entry2 = (KeyGroupEntry) kg1Entries.toArray()[1]; - assertEquals("HWK2_Id", kg1Entry1.getModuleID()); - assertEquals("HWK2_Issuer", kg1Entry1.getIssuerDN()); - assertEquals(1, kg1Entry2.getSerialNumber().intValue()); - - KeyGroup kg2 = (KeyGroup) keyGroups.get("KG2_Id"); - assertNotNull(kg2); - assertEquals("KG2_Id", kg2.getId()); - - Set kg2Entries = kg2.getKeyGroupEntries(); - assertEquals(2, kg2Entries.size()); - - KeyGroupEntry kg2Entry1 = (KeyGroupEntry) kg2Entries.toArray()[0]; - assertEquals("SWK1_Id", kg2Entry1.getModuleID()); - assertEquals("SWK1_Issuer", kg2Entry1.getIssuerDN()); - assertEquals(2, kg2Entry1.getSerialNumber().intValue()); - - KeyGroupEntry kg2Entry2 = (KeyGroupEntry) kg2Entries.toArray()[1]; - assertEquals("SWK2_Id", kg2Entry2.getModuleID()); - assertEquals("SWK2_Issuer", kg2Entry2.getIssuerDN()); - assertEquals(3, kg2Entry2.getSerialNumber().intValue()); - } - - public void testGetKeyGroupEntries() throws RFC2253NameParserException - { - RFC2253NameParser parser = new RFC2253NameParser("CN=Customer1_Issuer"); - Name name = parser.parse(); - Set kgEntries = provider_.getKeyGroupEntries(name, BigInteger.valueOf(4), "KG1_Id"); - assertEquals(2, kgEntries.size()); - - KeyGroupEntry kgEntry1 = (KeyGroupEntry) kgEntries.toArray()[0]; - assertEquals("HWK1_Id", kgEntry1.getModuleID()); - - KeyGroupEntry kgEntry2 = (KeyGroupEntry) kgEntries.toArray()[1]; - assertEquals("HWK2_Id", kgEntry2.getModuleID()); - } - - public void testGetChainingMode() throws RFC2253NameParserException - { - X509Certificate cert = new X509Certificate(); - RFC2253NameParser parser = new RFC2253NameParser("CN=Unknown"); - Name name = parser.parse(); - cert.setIssuerDN(name); - cert.setSerialNumber(BigInteger.valueOf(0)); - assertEquals("pkix", provider_.getChainingMode(cert)); // Default chaining mode - - parser = new RFC2253NameParser("CN=TA1_Issuer"); - name = parser.parse(); - cert.setIssuerDN(name); - cert.setSerialNumber(BigInteger.valueOf(5)); - assertEquals("chaining", provider_.getChainingMode(cert)); - } - - public void testGetDistributionPoints() throws RFC2253NameParserException - { - X509Certificate cert = new X509Certificate(); - RFC2253NameParser parser = new RFC2253NameParser("CN=DP1_Issuer"); - Name name = parser.parse(); - cert.setIssuerDN(name); - - Set dps = provider_.getDistributionPoints(cert); - assertEquals(2, dps.size()); - - CRLDistributionPoint dp1 = (CRLDistributionPoint) dps.toArray()[0]; - assertEquals("http://crl.myca.org", dp1.getUri()); - int reasonCodes = - iaik.asn1.structures.DistributionPoint.unused | - iaik.asn1.structures.DistributionPoint.keyCompromise | - iaik.asn1.structures.DistributionPoint.cACompromise | - iaik.asn1.structures.DistributionPoint.affiliationChanged | - iaik.asn1.structures.DistributionPoint.superseded | - iaik.asn1.structures.DistributionPoint.cessationOfOperation | - iaik.asn1.structures.DistributionPoint.certificateHold | - iaik.asn1.structures.DistributionPoint.privilegeWithdrawn | - iaik.asn1.structures.DistributionPoint.aACompromise; - assertEquals(reasonCodes, dp1.getReasonCodes()); - - CRLDistributionPoint dp2 = (CRLDistributionPoint) dps.toArray()[1]; - assertEquals("hhttp://crl.myotherca.org", dp2.getUri()); - reasonCodes = - iaik.asn1.structures.DistributionPoint.aACompromise | - iaik.asn1.structures.DistributionPoint.affiliationChanged; - assertEquals(reasonCodes, dp2.getReasonCodes()); - - parser = new RFC2253NameParser("CN=DP2_Issuer"); - name = parser.parse(); - cert.setIssuerDN(name); - - dps = provider_.getDistributionPoints(cert); - assertEquals(1, dps.size()); - - OCSPDistributionPoint dpo = (OCSPDistributionPoint) dps.toArray()[0]; - assertEquals("http://crl.yetanotherca.org", dpo.getUri()); - } - - public void testGetCRLArchiveDuration() - { - assertEquals(730, provider_.getCRLArchiveDuration()); - } - - public void testGetEnableRevocationArchiving() - { - assertFalse(provider_.getEnableRevocationArchiving()); - } - - public void testGetCertStoreLocation() - { - assertEquals( - CONFIG_BASE_ + "certstore", - provider_.getCertStoreLocation()); - } - - public void testGetCreateTransformsInfoProfile() - { - Element ctip1 = provider_.getCreateTransformsInfoProfile("CTIP_1"); - assertEquals("CTIP1", ctip1.getLocalName()); - - Element ctip2 = provider_.getCreateTransformsInfoProfile("CTIP_2"); - assertEquals("CTIP2", ctip2.getLocalName()); - } - - public void testGetCreateSignatureEnvironmentProfile() - { - Element csep = provider_.getCreateTransformsInfoProfile("CSEP_1"); - assertEquals("CSEP1", csep.getLocalName()); - } - - public void testGetVerifyTransformsInfoProfile() - { - Element vtip = provider_.getCreateTransformsInfoProfile("VTIP_1"); - assertEquals("VTIP1", vtip.getLocalName()); - } - - public void testGetSupplementProfile() - { - Element sp = provider_.getCreateTransformsInfoProfile("SP_1"); - assertEquals("SP1", sp.getLocalName()); - } - - public void testGetTrustProfile() - { - TrustProfile tp1 = provider_.getTrustProfile("TP1_Id"); - assertEquals( - "file:" + CONFIG_BASE_ + "trustprofiles/tp1/anchors", - tp1.getUri()); - assertEquals( - "file:" + CONFIG_BASE_ + "trustprofiles/tp1/signercerts", - tp1.getSignerCertsUri()); - - TrustProfile tp2 = provider_.getTrustProfile("TP2_Id"); - assertEquals( - "file:" + CONFIG_BASE_ + "trustprofiles/tp2/anchors", - tp2.getUri()); - assertEquals( - "file:" + CONFIG_BASE_ + "trustprofiles/tp2/signercerts", - tp2.getSignerCertsUri()); - } - - public void testGetRevocationArchiveJDBCURL() - { - assertEquals("jdbc://dummy", provider_.getRevocationArchiveJDBCURL()); - } - - public void testGetRevocationArchiveJDBCDriverClass() - { - assertEquals("fully.qualified.classname", provider_.getRevocationArchiveJDBCDriverClass()); - } - - public void testGetEnableRevocationChecking() - { - assertFalse(provider_.getEnableRevocationChecking()); - } - - public void testGetMaxRevocationAge() - { - assertEquals(10000, provider_.getMaxRevocationAge()); - } - - public void testGetServiceOrder() - { - String[] serviceOrder = provider_.getServiceOrder(); - assertEquals(2, serviceOrder.length); - assertEquals("CRL", serviceOrder[0]); - assertEquals("OCSP", serviceOrder[1]); - } - - public void testGetAutoAddCertificates() - { - assertFalse(provider_.getAutoAddCertificates()); - } - - public void testGetUseAuthorityInfoAccess() - { - assertFalse(provider_.getUseAuthorityInfoAccess()); - } -} diff --git a/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest1.java b/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest1.java new file mode 100644 index 000000000..08f0a9523 --- /dev/null +++ b/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest1.java @@ -0,0 +1,370 @@ +package test.at.gv.egovernment.moa.spss.server.config; + +import iaik.asn1.structures.Name; +import iaik.pki.pathvalidation.ChainingModes; +import iaik.utils.RFC2253NameParser; +import iaik.utils.RFC2253NameParserException; +import iaik.x509.X509Certificate; + +import java.math.BigInteger; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import junit.framework.TestCase; + +import org.w3c.dom.Element; + +import at.gv.egovernment.moa.spss.MOAException; +import at.gv.egovernment.moa.spss.server.config.CRLDistributionPoint; +import at.gv.egovernment.moa.spss.server.config.ConfigurationException; +import at.gv.egovernment.moa.spss.server.config.ConfigurationProvider; +import at.gv.egovernment.moa.spss.server.config.HardwareCryptoModule; +import at.gv.egovernment.moa.spss.server.config.HardwareKeyModule; +import at.gv.egovernment.moa.spss.server.config.KeyGroup; +import at.gv.egovernment.moa.spss.server.config.KeyGroupEntry; +import at.gv.egovernment.moa.spss.server.config.OCSPDistributionPoint; +import at.gv.egovernment.moa.spss.server.config.SoftwareKeyModule; +import at.gv.egovernment.moa.spss.server.config.TrustProfile; +import at.gv.egovernment.moa.util.Constants; + +/** + * @author Gregor Karlinger + * @version $Id$ + */ +public class ConfigurationProviderTest1 extends TestCase +{ + private static final String CONFIG_BASE_ = + "e:/cio/projekte/basismodule/wartung/projekt/spss.server/res/test/resources/config/"; + + static at.gv.egovernment.moa.spss.server.config.ConfigurationProvider provider_; + + static + { + System.setProperty( + "log4j.configuration", + "file:/" + CONFIG_BASE_ + "log4j.properties"); + System.setProperty( + at.gv.egovernment.moa.spss.server.config.ConfigurationProvider.CONFIG_PROPERTY_NAME, + CONFIG_BASE_ + "moa.spss.complete-config.xml"); + try + { + ConfigurationProvider.reload(); + provider_ = at.gv.egovernment.moa.spss.server.config.ConfigurationProvider.getInstance(); + } + catch (ConfigurationException e) + { + throw new RuntimeException("Fehler beim Setup des Tests: ", e); + } + } + + /** + * Constructor for ConfigurationProvider. + * @param arg0 + */ + public ConfigurationProviderTest1() throws MOAException + { + super("ConfigurationProvider"); + } + + public void testGetWarnings() + { + assertEquals(0, provider_.getWarnings().size()); + } + + public void testGetDigestMethodAlgorithmName() + { + assertEquals( + Constants.SHA1_URI, + provider_.getDigestMethodAlgorithmName()); + } + + public void testGetCanonicalizationAlgorithmName() + { + assertEquals( + Constants.C14N_WITH_COMMENTS_URI, + provider_.getCanonicalizationAlgorithmName()); + } + + public void testGetHardwareCryptoModules() + { + List hwcms = provider_.getHardwareCryptoModules(); + assertEquals(2, hwcms.size()); + + HardwareCryptoModule hwc1 = (HardwareCryptoModule) hwcms.get(0); + assertEquals("HWC1_Name", hwc1.getName()); + assertEquals("HWC1_SlotId", hwc1.getSlotID()); + assertEquals("HWC1_UserPIN", hwc1.getUserPIN()); + + HardwareCryptoModule hwc2 = (HardwareCryptoModule) hwcms.get(1); + assertEquals("HWC2_Name", hwc2.getName()); + assertNull(hwc2.getSlotID()); + assertEquals("HWC2_UserPIN", hwc2.getUserPIN()); + } + + public void testGetHardwareKeyModules() + { + List hwkms = provider_.getHardwareKeyModules(); + assertEquals(2, hwkms.size()); + + HardwareKeyModule hwk1 = (HardwareKeyModule) hwkms.get(0); + assertEquals("HWK1_Id", hwk1.getId()); + assertEquals("HWK1_Name", hwk1.getName()); + assertEquals("HWK1_SlotId", hwk1.getSlotID()); + assertEquals("HWK1_UserPIN", hwk1.getUserPIN()); + + HardwareKeyModule hwk2 = (HardwareKeyModule) hwkms.get(1); + assertEquals("HWK2_Id", hwk2.getId()); + assertEquals("HWK2_Name", hwk2.getName()); + assertNull(hwk2.getSlotID()); + assertEquals("HWK2_UserPIN", hwk2.getUserPIN()); + } + + public void testGetSoftwareKeyModules() + { + List swkms = provider_.getSoftwareKeyModules(); + assertEquals(2, swkms.size()); + + SoftwareKeyModule swk1 = (SoftwareKeyModule) swkms.get(0); + assertEquals("SWK1_Id", swk1.getId()); + assertEquals(CONFIG_BASE_ + "swk/SWK1_FileName.txt", swk1.getFileName().replace('\\', '/')); + assertEquals("SWK1_Password", swk1.getPassWord()); + + SoftwareKeyModule swk2 = (SoftwareKeyModule) swkms.get(1); + assertEquals("SWK2_Id", swk2.getId()); + assertEquals(CONFIG_BASE_ + "swk/SWK2_FileName.txt", swk2.getFileName().replace('\\', '/')); + assertNull(swk2.getPassWord()); + } + + public void testGetKeyGroups() + { + Map keyGroups = provider_.getKeyGroups(); + assertEquals(2, keyGroups.size()); + + KeyGroup kg1 = (KeyGroup) keyGroups.get("KG1_Id"); + assertNotNull(kg1); + assertEquals("KG1_Id", kg1.getId()); + + Set kg1Entries = kg1.getKeyGroupEntries(); + assertEquals(2, kg1Entries.size()); + + Iterator kg1EntriesIt = kg1Entries.iterator(); + while(kg1EntriesIt.hasNext()) + { + KeyGroupEntry currentEntry = (KeyGroupEntry)kg1EntriesIt.next(); + if ("HWK1_Id".equals(currentEntry.getModuleID())) + { + assertEquals("CN=HWK1_Issuer", currentEntry.getIssuerDN()); + assertEquals(0, currentEntry.getSerialNumber().intValue()); + } + else if ("HWK2_Id".equals(currentEntry.getModuleID())) + { + assertEquals("CN=HWK2_Issuer", currentEntry.getIssuerDN()); + assertEquals(1, currentEntry.getSerialNumber().intValue()); + } + else fail("Invalid module identifer found."); + } + + KeyGroup kg2 = (KeyGroup) keyGroups.get("KG2_Id"); + assertNotNull(kg2); + assertEquals("KG2_Id", kg2.getId()); + + Set kg2Entries = kg2.getKeyGroupEntries(); + assertEquals(2, kg2Entries.size()); + + Iterator kg2EntriesIt = kg1Entries.iterator(); + while(kg1EntriesIt.hasNext()) + { + KeyGroupEntry currentEntry = (KeyGroupEntry)kg2EntriesIt.next(); + if ("SWK1_Id".equals(currentEntry.getModuleID())) + { + assertEquals("CN=CN=SWK1_Issuer", currentEntry.getIssuerDN()); + assertEquals(2, currentEntry.getSerialNumber().intValue()); + } + else if ("SWK2_Id".equals(currentEntry.getModuleID())) + { + assertEquals("CN=SWK2_Issuer", currentEntry.getIssuerDN()); + assertEquals(3, currentEntry.getSerialNumber().intValue()); + } + else fail("Invalid module identifer found."); + } + } + + public void testGetKeyGroupEntries() throws RFC2253NameParserException + { + RFC2253NameParser parser = new RFC2253NameParser("CN=Customer1_Issuer"); + Name name = parser.parse(); + Set kgEntries = provider_.getKeyGroupEntries(name, BigInteger.valueOf(4), "KG1_Id"); + assertEquals(2, kgEntries.size()); + + Iterator kgEntriesIt = kgEntries.iterator(); + while (kgEntriesIt.hasNext()) + { + KeyGroupEntry currentEntry = (KeyGroupEntry) kgEntriesIt.next(); + if (!"HWK1_Id".equals(currentEntry.getModuleID()) && !"HWK2_Id".equals(currentEntry.getModuleID())) + { + fail("Invalid module identifier found."); + } + } + } + + public void testGetChainingMode() throws RFC2253NameParserException + { + X509Certificate cert = new X509Certificate(); + RFC2253NameParser parser = new RFC2253NameParser("CN=Unknown"); + Name name = parser.parse(); + cert.setIssuerDN(name); + cert.setSerialNumber(BigInteger.valueOf(0)); + assertEquals(ChainingModes.PKIX_MODE, provider_.getChainingMode(cert)); // Default chaining mode + + parser = new RFC2253NameParser("CN=TA1_Issuer"); + name = parser.parse(); + cert.setIssuerDN(name); + cert.setSerialNumber(BigInteger.valueOf(5)); + assertEquals(ChainingModes.CHAIN_MODE, provider_.getChainingMode(cert)); + } + + public void testGetDistributionPoints() throws RFC2253NameParserException + { + X509Certificate cert = new X509Certificate(); + RFC2253NameParser parser = new RFC2253NameParser("CN=DP1_Issuer"); + Name name = parser.parse(); + cert.setIssuerDN(name); + + Set dps = provider_.getDistributionPoints(cert); + assertEquals(2, dps.size()); + + CRLDistributionPoint dp1 = (CRLDistributionPoint) dps.toArray()[0]; + assertEquals("http://crl.myca.org", dp1.getUri()); + int reasonCodes = + iaik.asn1.structures.DistributionPoint.unused | + iaik.asn1.structures.DistributionPoint.keyCompromise | + iaik.asn1.structures.DistributionPoint.cACompromise | + iaik.asn1.structures.DistributionPoint.affiliationChanged | + iaik.asn1.structures.DistributionPoint.superseded | + iaik.asn1.structures.DistributionPoint.cessationOfOperation | + iaik.asn1.structures.DistributionPoint.certificateHold | + iaik.asn1.structures.DistributionPoint.privilegeWithdrawn | + iaik.asn1.structures.DistributionPoint.aACompromise; + assertEquals(reasonCodes, dp1.getReasonCodes()); + + CRLDistributionPoint dp2 = (CRLDistributionPoint) dps.toArray()[1]; + assertEquals("http://crl.myotherca.org", dp2.getUri()); + reasonCodes = + iaik.asn1.structures.DistributionPoint.aACompromise | + iaik.asn1.structures.DistributionPoint.affiliationChanged; + assertEquals(reasonCodes, dp2.getReasonCodes()); + + parser = new RFC2253NameParser("CN=DP2_Issuer"); + name = parser.parse(); + cert.setIssuerDN(name); + + dps = provider_.getDistributionPoints(cert); + assertEquals(1, dps.size()); + + OCSPDistributionPoint dpo = (OCSPDistributionPoint) dps.toArray()[0]; + assertEquals("http://crl.yetanotherca.org", dpo.getUri()); + } + + public void testGetCRLArchiveDuration() + { + assertEquals(730, provider_.getCRLArchiveDuration()); + } + + public void testGetEnableRevocationArchiving() + { + assertFalse(provider_.getEnableRevocationArchiving()); + } + + public void testGetCertStoreLocation() + { + assertEquals( + CONFIG_BASE_ + "certstore_test", + provider_.getCertStoreLocation().replace('\\', '/')); + } + + public void testGetCreateTransformsInfoProfile() + { + Element ctip1 = provider_.getCreateTransformsInfoProfile("CTIP_1"); + assertEquals("CreateTransformsInfoProfile", ctip1.getLocalName()); + + Element ctip2 = provider_.getCreateTransformsInfoProfile("CTIP_2"); + assertEquals("CreateTransformsInfoProfile", ctip2.getLocalName()); + } + + public void testGetCreateSignatureEnvironmentProfile() + { + Element csep = provider_.getCreateSignatureEnvironmentProfile("CSEP_1"); + assertEquals("CreateSignatureEnvironmentProfile", csep.getLocalName()); + } + + public void testGetVerifyTransformsInfoProfile() + { + Element vtip = provider_.getVerifyTransformsInfoProfile("VTIP_1"); + assertEquals("VerifyTransformsInfoProfile", vtip.getLocalName()); + } + + public void testGetSupplementProfile() + { + Element sp = provider_.getSupplementProfile("SP_1"); + assertEquals("SupplementProfile", sp.getLocalName()); + } + + public void testGetTrustProfile() + { + TrustProfile tp1 = provider_.getTrustProfile("TP1_Id"); + assertEquals( + "file:/" + CONFIG_BASE_ + "trustprofiles/tp1/anchors", + tp1.getUri()); + assertEquals( + "file:/" + CONFIG_BASE_ + "trustprofiles/tp1/signercerts", + tp1.getSignerCertsUri()); + + TrustProfile tp2 = provider_.getTrustProfile("TP2_Id"); + assertEquals( + "file:" + CONFIG_BASE_ + "trustprofiles/tp2/anchors", + tp2.getUri()); + assertEquals( + "file:" + CONFIG_BASE_ + "trustprofiles/tp2/signercerts", + tp2.getSignerCertsUri()); + } + + public void testGetRevocationArchiveJDBCURL() + { + assertEquals("jdbc://dummy", provider_.getRevocationArchiveJDBCURL()); + } + + public void testGetRevocationArchiveJDBCDriverClass() + { + assertEquals("fully.qualified.classname", provider_.getRevocationArchiveJDBCDriverClass()); + } + + public void testGetEnableRevocationChecking() + { + assertFalse(provider_.getEnableRevocationChecking()); + } + + public void testGetMaxRevocationAge() + { + assertEquals(10000, provider_.getMaxRevocationAge()); + } + + public void testGetServiceOrder() + { + String[] serviceOrder = provider_.getServiceOrder(); + assertEquals(2, serviceOrder.length); + assertEquals("CRL", serviceOrder[0]); + assertEquals("OCSP", serviceOrder[1]); + } + + public void testGetAutoAddCertificates() + { + assertFalse(provider_.getAutoAddCertificates()); + } + + public void testGetUseAuthorityInfoAccess() + { + assertFalse(provider_.getUseAuthorityInfoAccess()); + } +} diff --git a/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest2.java b/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest2.java new file mode 100644 index 000000000..85515bce5 --- /dev/null +++ b/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest2.java @@ -0,0 +1,225 @@ +package test.at.gv.egovernment.moa.spss.server.config; + +import iaik.asn1.structures.Name; +import iaik.pki.pathvalidation.ChainingModes; +import iaik.utils.RFC2253NameParser; +import iaik.utils.RFC2253NameParserException; +import iaik.x509.X509Certificate; + +import java.math.BigInteger; +import java.util.List; +import java.util.Set; + +import junit.framework.TestCase; + +import org.w3c.dom.Element; + +import at.gv.egovernment.moa.spss.MOAException; +import at.gv.egovernment.moa.spss.server.config.ConfigurationException; +import at.gv.egovernment.moa.spss.server.config.ConfigurationProvider; +import at.gv.egovernment.moa.spss.server.config.TrustProfile; +import at.gv.egovernment.moa.util.Constants; + +/** + * @author Gregor Karlinger + * @version $Id$ + */ +public class ConfigurationProviderTest2 extends TestCase +{ + private static final String CONFIG_BASE_ = + "e:/cio/projekte/basismodule/wartung/projekt/spss.server/res/test/resources/config/"; + + static at.gv.egovernment.moa.spss.server.config.ConfigurationProvider provider_; + + static + { + System.setProperty( + "log4j.configuration", + "file:/" + CONFIG_BASE_ + "log4j.properties"); + System.setProperty( + at.gv.egovernment.moa.spss.server.config.ConfigurationProvider.CONFIG_PROPERTY_NAME, + CONFIG_BASE_ + "moa.ss.noopts-config.xml"); + try + { + ConfigurationProvider.reload(); + provider_ = at.gv.egovernment.moa.spss.server.config.ConfigurationProvider.getInstance(); + } + catch (ConfigurationException e) + { + throw new RuntimeException("Fehler beim Setup des Tests: ", e); + } + } + + + /** + * Constructor for ConfigurationProvider. + * @param arg0 + */ + public ConfigurationProviderTest2() throws MOAException + { + super("ConfigurationProvider"); + } + + public void testGetWarnings() + { + // 3 Warnings should be collected: C14N not found, DigestMethod not found, ArchiveDuration not found + assertEquals(3, provider_.getWarnings().size()); + } + + public void testGetDigestMethodAlgorithmName() + { + // Element is missing in config file, check if default value is returned + assertEquals( + Constants.SHA1_URI, + provider_.getDigestMethodAlgorithmName()); + } + + public void testGetCanonicalizationAlgorithmName() + { + // Element is missing in config file, check if default value is returned + assertEquals( + Constants.C14N_URI, + provider_.getCanonicalizationAlgorithmName()); + } + + public void testGetHardwareCryptoModules() + { + // No hardware crypto modules in config file, check for empty list + List hwcms = provider_.getHardwareCryptoModules(); + assertEquals(0, hwcms.size()); + } + + public void testGetHardwareKeyModules() + { + List hwkms = provider_.getHardwareKeyModules(); + assertEquals(1, hwkms.size()); + } + + public void testGetSoftwareKeyModules() + { + // No software key modules in config file, check for empty list + List swkms = provider_.getSoftwareKeyModules(); + assertEquals(0, swkms.size()); + } + + public void testGetChainingMode() throws RFC2253NameParserException + { + // Default Chaining Mode not set in configuration, check for default value + X509Certificate cert = new X509Certificate(); + RFC2253NameParser parser = new RFC2253NameParser("CN=Unknown"); + Name name = parser.parse(); + cert.setIssuerDN(name); + cert.setSerialNumber(BigInteger.valueOf(0)); + assertEquals(ChainingModes.PKIX_MODE, provider_.getChainingMode(cert)); + } + + public void testGetDistributionPoints() throws RFC2253NameParserException + { + // Element is missing in config file, check if emty list is returned + X509Certificate cert = new X509Certificate(); + RFC2253NameParser parser = new RFC2253NameParser("CN=DP1_Issuer"); + Name name = parser.parse(); + cert.setIssuerDN(name); + + Set dps = provider_.getDistributionPoints(cert); + assertEquals(0, dps.size()); + } + + public void testGetCRLArchiveDuration() + { + // Element is missing in config file, check if default value is returned + assertEquals(0, provider_.getCRLArchiveDuration()); + } + + public void testGetEnableRevocationArchiving() + { + // Element is missing in config file, check if default value is returned + assertFalse(provider_.getEnableRevocationArchiving()); + } + + public void testGetCertStoreLocation() + { + // Element is missing in config file, check if default value is returned + assertEquals( + CONFIG_BASE_ + "certstore", + provider_.getCertStoreLocation().replace('\\', '/')); + } + + public void testGetCreateTransformsInfoProfile() + { + // No profile in config file, check for null + Element ctip1 = provider_.getCreateTransformsInfoProfile("CTIP_1"); + assertNull(ctip1); + } + + public void testGetCreateSignatureEnvironmentProfile() + { + // No profile in config file, check for null + Element csep = provider_.getCreateSignatureEnvironmentProfile("CSEP_1"); + assertNull(csep); + } + + public void testGetVerifyTransformsInfoProfile() + { + // No profile in config file, check for null + Element vtip = provider_.getVerifyTransformsInfoProfile("VTIP_1"); + assertNull(vtip); + } + + public void testGetSupplementProfile() + { + // No profile in config file, check for null + Element sp = provider_.getSupplementProfile("SP_1"); + assertNull(sp); + } + + public void testGetTrustProfile() + { + // No trust profiles config file, check for null + TrustProfile tp1 = provider_.getTrustProfile("TP1_Id"); + assertNull(tp1); + } + + public void testGetRevocationArchiveJDBCURL() + { + // Element is missing in config file, check for null + assertNull(provider_.getRevocationArchiveJDBCURL()); + } + + public void testGetRevocationArchiveJDBCDriverClass() + { + // Element is missing in config file, check for null + assertNull(provider_.getRevocationArchiveJDBCDriverClass()); + } + + public void testGetEnableRevocationChecking() + { + // Element is missing in config file, check for default value + assertFalse(provider_.getEnableRevocationChecking()); + } + + public void testGetMaxRevocationAge() + { + // Element is missing in config file, check for default value + assertEquals(0, provider_.getMaxRevocationAge()); + } + + public void testGetServiceOrder() + { + // Element is missing in config file, check for empty array + String[] serviceOrder = provider_.getServiceOrder(); + assertEquals(0, serviceOrder.length); + } + + public void testGetAutoAddCertificates() + { + // Element is missing in config file, check for default value + assertFalse(provider_.getAutoAddCertificates()); + } + + public void testGetUseAuthorityInfoAccess() + { + // Element is missing in config file, check for default value + assertFalse(provider_.getUseAuthorityInfoAccess()); + } +} diff --git a/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest3.java b/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest3.java new file mode 100644 index 000000000..3416fcfb0 --- /dev/null +++ b/spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest3.java @@ -0,0 +1,166 @@ +package test.at.gv.egovernment.moa.spss.server.config; + +import iaik.asn1.structures.Name; +import iaik.utils.RFC2253NameParser; +import iaik.utils.RFC2253NameParserException; +import iaik.x509.X509Certificate; + +import java.util.List; +import java.util.Set; + +import junit.framework.TestCase; + +import org.w3c.dom.Element; + +import at.gv.egovernment.moa.spss.MOAException; +import at.gv.egovernment.moa.spss.server.config.ConfigurationException; +import at.gv.egovernment.moa.spss.server.config.ConfigurationProvider; +import at.gv.egovernment.moa.util.Constants; + +/** + * @author Gregor Karlinger + * @version $Id$ + */ +public class ConfigurationProviderTest3 extends TestCase +{ + private static final String CONFIG_BASE_ = + "e:/cio/projekte/basismodule/wartung/projekt/spss.server/res/test/resources/config/"; + + static at.gv.egovernment.moa.spss.server.config.ConfigurationProvider provider_; + + static + { + System.setProperty( + "log4j.configuration", + "file:/" + CONFIG_BASE_ + "log4j.properties"); + System.setProperty( + at.gv.egovernment.moa.spss.server.config.ConfigurationProvider.CONFIG_PROPERTY_NAME, + CONFIG_BASE_ + "moa.sp.noopts-config.xml"); + try + { + ConfigurationProvider.reload(); + provider_ = at.gv.egovernment.moa.spss.server.config.ConfigurationProvider.getInstance(); + } + catch (ConfigurationException e) + { + throw new RuntimeException("Fehler beim Setup des Tests: ", e); + } + } + + /** + * Constructor for ConfigurationProvider. + * @param arg0 + */ + public ConfigurationProviderTest3() throws MOAException + { + super("ConfigurationProvider"); + } + + public void testGetWarnings() + { + // 3 Warnings should be collected: C14N not found, DigestMethod not found, ArchiveDuration not found + assertEquals(3, provider_.getWarnings().size()); + } + + public void testGetDigestMethodAlgorithmName() + { + // Element is missing in config file, check if default value is returned + assertEquals( + Constants.SHA1_URI, + provider_.getDigestMethodAlgorithmName()); + } + + public void testGetCanonicalizationAlgorithmName() + { + // Element is missing in config file, check if default value is returned + assertEquals( + Constants.C14N_URI, + provider_.getCanonicalizationAlgorithmName()); + } + + public void testGetHardwareCryptoModules() + { + // No hardware crypto modules in config file, check for empty list + List hwcms = provider_.getHardwareCryptoModules(); + assertEquals(0, hwcms.size()); + } + + public void testGetHardwareKeyModules() + { + // No hardware key modules in config file, check for empty list + List hwkms = provider_.getHardwareKeyModules(); + assertEquals(0, hwkms.size()); + } + + public void testGetSoftwareKeyModules() + { + // No software key modules in config file, check for empty list + List swkms = provider_.getSoftwareKeyModules(); + assertEquals(0, swkms.size()); + } + + public void testGetDistributionPoints() throws RFC2253NameParserException + { + // No distribution points in config file, check for emtpy set + X509Certificate cert = new X509Certificate(); + RFC2253NameParser parser = new RFC2253NameParser("CN=DP1_Issuer"); + Name name = parser.parse(); + cert.setIssuerDN(name); + + Set dps = provider_.getDistributionPoints(cert); + assertEquals(0, dps.size()); + } + + public void testGetCRLArchiveDuration() + { + // No archive duration in config file, check for default value + assertEquals(0, provider_.getCRLArchiveDuration()); + } + + public void testGetCreateTransformsInfoProfile() + { + // No profile in config file, check for null + Element ctip1 = provider_.getCreateTransformsInfoProfile("CTIP_1"); + assertNull(ctip1); + } + + public void testGetCreateSignatureEnvironmentProfile() + { + // No profile in config file, check for null + Element csep = provider_.getCreateSignatureEnvironmentProfile("CSEP_1"); + assertNull(csep); + } + + public void testGetVerifyTransformsInfoProfile() + { + // No profile in config file, check for null + Element vtip = provider_.getVerifyTransformsInfoProfile("VTIP_1"); + assertNull(vtip); + } + + public void testGetSupplementProfile() + { + // No profile in config file, check for null + Element sp = provider_.getSupplementProfile("SP_1"); + assertNull(sp); + } + + public void testGetRevocationArchiveJDBCURL() + { + // No archive in config file, check for null + assertNull(provider_.getRevocationArchiveJDBCURL()); + } + + public void testGetRevocationArchiveJDBCDriverClass() + { + // No archive in config file, check for null + assertNull(provider_.getRevocationArchiveJDBCDriverClass()); + } + + public void testGetServiceOrder() + { + // Element is missing in config file, check for empty array + String[] serviceOrder = provider_.getServiceOrder(); + assertEquals(0, serviceOrder.length); + } +} -- cgit v1.2.3