diff options
author | gregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2005-08-11 13:22:41 +0000 |
---|---|---|
committer | gregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2005-08-11 13:22:41 +0000 |
commit | a67ed8406bb7f9d4bca48891308e7bfead90efe4 (patch) | |
tree | cd351f4a11be4c3ea9e3ecbf4b17da54353c2e35 | |
parent | 8cf117a1d3ae7381c335e037a0a5b97daef08667 (diff) | |
download | moa-id-spss-a67ed8406bb7f9d4bca48891308e7bfead90efe4.tar.gz moa-id-spss-a67ed8406bb7f9d4bca48891308e7bfead90efe4.tar.bz2 moa-id-spss-a67ed8406bb7f9d4bca48891308e7bfead90efe4.zip |
Bug 271: Adpation auf neue Struktur des Konfigurationsfiles abgeschlossen. Modultests durchgeführt.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@436 d688527b-c9ab-4aba-bd8d-4036d912da1d
21 files changed, 644 insertions, 88 deletions
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 @@ <xs:element name="ChainingMode">
<xs:complexType>
<xs:sequence>
- <xs:element name="DefaultMode" type="config:ChainingModeType" default="pkix"/>
+ <xs:element name="DefaultMode" type="config:ChainingModeType"/>
<xs:element name="TrustAnchor" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
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 @@ <xs:element name="ChainingMode">
<xs:complexType>
<xs:sequence>
- <xs:element name="DefaultMode" type="config:ChainingModeType" default="pkix"/>
+ <xs:element name="DefaultMode" type="config:ChainingModeType"/>
<xs:element name="TrustAnchor" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
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ögl 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<MOAConfiguration xmlns="http://reference.e-government.gv.at/namespace/moaconfig/20021122#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"> + <SignatureVerification> + <CertificateValidation> + <PathConstruction> + <AutoAddCertificates>false</AutoAddCertificates> + <UseAuthorityInformationAccess>false</UseAuthorityInformationAccess> + <CertificateStore> + <DirectoryStore> + <Location>certstore</Location> + </DirectoryStore> + </CertificateStore> + </PathConstruction> + <PathValidation> + <ChainingMode> + <DefaultMode>pkix</DefaultMode> + </ChainingMode> + <TrustProfile> + <Id>TP1_Id</Id> + <TrustAnchorsLocation>trustprofiles/tp1/anchors</TrustAnchorsLocation> + </TrustProfile> + </PathValidation> + <RevocationChecking> + <EnableChecking>false</EnableChecking> + <MaxRevocationAge>10000</MaxRevocationAge> + <Archiving> + <EnableArchiving>false</EnableArchiving> + </Archiving> + </RevocationChecking> + </CertificateValidation> + </SignatureVerification> +</MOAConfiguration> 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 @@ <?xml version="1.0" encoding="UTF-8"?> -<!--Sample XML file generated by XMLSPY v2004 rel. 4 U (http://www.xmlspy.com)--> -<MOAConfiguration xmlns="http://reference.e-government.gv.at/namespace/moaconfig/20021122#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://reference.e-government.gv.at/namespace/moaconfig/20021122# -E:\cio\projekte\basismodule\wartung\projekt\common\res\resources\schemas\MOA-SPSS-config-1.3.xsd"> +<MOAConfiguration xmlns="http://reference.e-government.gv.at/namespace/moaconfig/20021122#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"> <HardwareCryptoModule> <Name>HWC1_Name</Name> <SlotId>HWC1_SlotId</SlotId> @@ -26,12 +24,12 @@ E:\cio\projekte\basismodule\wartung\projekt\common\res\resources\schemas\MOA-SPS </HardwareKeyModule> <SoftwareKeyModule> <Id>SWK1_Id</Id> - <FileName>SWK1_FileName</FileName> + <FileName>swk/SWK1_FileName.txt</FileName> <Password>SWK1_Password</Password> </SoftwareKeyModule> <SoftwareKeyModule> <Id>SWK2_Id</Id> - <FileName>SWK1_FileName</FileName> + <FileName>swk/SWK2_FileName.txt</FileName> </SoftwareKeyModule> </KeyModules> <KeyGroup> @@ -74,15 +72,15 @@ E:\cio\projekte\basismodule\wartung\projekt\common\res\resources\schemas\MOA-SPS <dsig:X509SerialNumber>4</dsig:X509SerialNumber> </CustomerId> <KeyGroupId>KG1_Id</KeyGroupId> - <KeyGroupId>KK2_Id</KeyGroupId> + <KeyGroupId>KG2_Id</KeyGroupId> </KeyGroupMapping> <KeyGroupMapping> <KeyGroupId>KG1_Id</KeyGroupId> - <KeyGroupId>KK2_Id</KeyGroupId> + <KeyGroupId>KG2_Id</KeyGroupId> </KeyGroupMapping> <XMLDSIG> - <CanonicalizationAlgorithm>http://an.c14n.alg</CanonicalizationAlgorithm> - <DigestMethodAlgorithm>http://a.digest.method</DigestMethodAlgorithm> + <CanonicalizationAlgorithm>http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments</CanonicalizationAlgorithm> + <DigestMethodAlgorithm>http://www.w3.org/2000/09/xmldsig#sha1</DigestMethodAlgorithm> </XMLDSIG> <CreateTransformsInfoProfile> <Id>CTIP_1</Id> @@ -94,7 +92,7 @@ E:\cio\projekte\basismodule\wartung\projekt\common\res\resources\schemas\MOA-SPS </CreateTransformsInfoProfile> <CreateSignatureEnvironmentProfile> <Id>CSEP_1</Id> - <Location>profiles/csep/CESP_1.xml</Location> + <Location>profiles/csep/CSEP_1.xml</Location> </CreateSignatureEnvironmentProfile> </SignatureCreation> <SignatureVerification> @@ -104,7 +102,7 @@ E:\cio\projekte\basismodule\wartung\projekt\common\res\resources\schemas\MOA-SPS <UseAuthorityInformationAccess>false</UseAuthorityInformationAccess> <CertificateStore> <DirectoryStore> - <Location>certstore</Location> + <Location>certstore_test</Location> </DirectoryStore> </CertificateStore> </PathConstruction> @@ -113,7 +111,7 @@ E:\cio\projekte\basismodule\wartung\projekt\common\res\resources\schemas\MOA-SPS <DefaultMode>pkix</DefaultMode> <TrustAnchor> <Identification> - <dsig:X509IssuerName> </dsig:X509IssuerName> + <dsig:X509IssuerName>CN=TA1_Issuer</dsig:X509IssuerName> <dsig:X509SerialNumber>5</dsig:X509SerialNumber> </Identification> <Mode>chaining</Mode> @@ -133,8 +131,8 @@ E:\cio\projekte\basismodule\wartung\projekt\common\res\resources\schemas\MOA-SPS </TrustProfile> <TrustProfile> <Id>TP2_Id</Id> - <TrustAnchorsLocation>file:e:/cio/projekte/basismodule/wartung/projekt/spss.server/res/test/resources/config/trustprofiles/tp2/anchors/</TrustAnchorsLocation> - <SignerCertsLocation>file:e:/cio/projekte/basismodule/wartung/projekt/spss.server/res/test/resources/config/trustprofiles/tp2/signercerts/</SignerCertsLocation> + <TrustAnchorsLocation>file:e:/cio/projekte/basismodule/wartung/projekt/spss.server/res/test/resources/config/trustprofiles/tp2/anchors</TrustAnchorsLocation> + <SignerCertsLocation>file:e:/cio/projekte/basismodule/wartung/projekt/spss.server/res/test/resources/config/trustprofiles/tp2/signercerts</SignerCertsLocation> </TrustProfile> </PathValidation> <RevocationChecking> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<MOAConfiguration xmlns="http://reference.e-government.gv.at/namespace/moaconfig/20021122#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"> + <SignatureCreation> + <KeyModules> + <HardwareKeyModule> + <Id>HWK1_Id</Id> + <Name>HWK1_Name</Name> + <SlotId>HWK1_SlotId</SlotId> + <UserPIN>HWK1_UserPIN</UserPIN> + </HardwareKeyModule> + </KeyModules> + <KeyGroup> + <Id>KG1_Id</Id> + <Key> + <KeyModuleId>HWK1_Id</KeyModuleId> + <KeyCertIssuerSerial> + <dsig:X509IssuerName>CN=HWK1_Issuer</dsig:X509IssuerName> + <dsig:X509SerialNumber>0</dsig:X509SerialNumber> + </KeyCertIssuerSerial> + </Key> + </KeyGroup> + <KeyGroupMapping> + <CustomerId> + <dsig:X509IssuerName>CN=Customer1_Issuer</dsig:X509IssuerName> + <dsig:X509SerialNumber>4</dsig:X509SerialNumber> + </CustomerId> + <KeyGroupId>KG1_Id</KeyGroupId> + </KeyGroupMapping> + <XMLDSIG></XMLDSIG> + </SignatureCreation> +</MOAConfiguration> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CreateSignatureEnvironmentProfile xmlns="http://reference.e-government.gv.at/namespace/moa/20020822#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"> + <CreateSignatureLocation Index="0"/> +</CreateSignatureEnvironmentProfile> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CreateTransformsInfoProfile xmlns="http://reference.e-government.gv.at/namespace/moa/20020822#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"> + <CreateTransformsInfo> + <FinalDataMetaInfo> + <MimeType>text/plain</MimeType> + </FinalDataMetaInfo> + </CreateTransformsInfo> +</CreateTransformsInfoProfile> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CreateTransformsInfoProfile xmlns="http://reference.e-government.gv.at/namespace/moa/20020822#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"> + <CreateTransformsInfo> + <FinalDataMetaInfo> + <MimeType>text/plain</MimeType> + </FinalDataMetaInfo> + </CreateTransformsInfo> +</CreateTransformsInfoProfile> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<SupplementProfile xmlns="http://reference.e-government.gv.at/namespace/moa/20020822#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"> + <Content Reference="ref"/> +</SupplementProfile> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<VerifyTransformsInfoProfile xmlns="http://reference.e-government.gv.at/namespace/moa/20020822#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"/> 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 --- /dev/null +++ b/spss.server/res/test/resources/config/swk/SWK1_FileName.txt 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 --- /dev/null +++ b/spss.server/res/test/resources/config/swk/SWK2_FileName.txt 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/ConfigurationProviderTest1.java index 68191477e..08f0a9523 100644 --- 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/ConfigurationProviderTest1.java @@ -1,11 +1,13 @@ 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; @@ -16,6 +18,8 @@ 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; @@ -23,31 +27,47 @@ 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 ConfigurationProviderTest extends TestCase +public class ConfigurationProviderTest1 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_; + 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 ConfigurationProviderTest() throws MOAException + public ConfigurationProviderTest1() 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()); @@ -56,15 +76,15 @@ public class ConfigurationProviderTest extends TestCase public void testGetDigestMethodAlgorithmName() { assertEquals( - "http://a.digest.method", + Constants.SHA1_URI, provider_.getDigestMethodAlgorithmName()); } public void testGetCanonicalizationAlgorithmName() { assertEquals( - "http://an.c14n.alg", - provider_.getDigestMethodAlgorithmName()); + Constants.C14N_WITH_COMMENTS_URI, + provider_.getCanonicalizationAlgorithmName()); } public void testGetHardwareCryptoModules() @@ -79,7 +99,7 @@ public class ConfigurationProviderTest extends TestCase HardwareCryptoModule hwc2 = (HardwareCryptoModule) hwcms.get(1); assertEquals("HWC2_Name", hwc2.getName()); - assertNull(hwc1.getSlotID()); + assertNull(hwc2.getSlotID()); assertEquals("HWC2_UserPIN", hwc2.getUserPIN()); } @@ -108,12 +128,12 @@ public class ConfigurationProviderTest extends TestCase SoftwareKeyModule swk1 = (SoftwareKeyModule) swkms.get(0); assertEquals("SWK1_Id", swk1.getId()); - assertEquals("SWK1_FileName", swk1.getFileName()); + assertEquals(CONFIG_BASE_ + "swk/SWK1_FileName.txt", swk1.getFileName().replace('\\', '/')); assertEquals("SWK1_Password", swk1.getPassWord()); SoftwareKeyModule swk2 = (SoftwareKeyModule) swkms.get(1); - assertEquals("HWK2_Id", swk2.getId()); - assertEquals("SWK1_FileName", swk2.getFileName()); + assertEquals("SWK2_Id", swk2.getId()); + assertEquals(CONFIG_BASE_ + "swk/SWK2_FileName.txt", swk2.getFileName().replace('\\', '/')); assertNull(swk2.getPassWord()); } @@ -129,15 +149,22 @@ public class ConfigurationProviderTest extends TestCase 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()); + 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); @@ -146,15 +173,22 @@ public class ConfigurationProviderTest extends TestCase 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()); + 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 @@ -164,11 +198,15 @@ public class ConfigurationProviderTest extends TestCase 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()); + 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 @@ -178,13 +216,13 @@ public class ConfigurationProviderTest extends TestCase Name name = parser.parse(); cert.setIssuerDN(name); cert.setSerialNumber(BigInteger.valueOf(0)); - assertEquals("pkix", provider_.getChainingMode(cert)); // Default chaining mode + 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("chaining", provider_.getChainingMode(cert)); + assertEquals(ChainingModes.CHAIN_MODE, provider_.getChainingMode(cert)); } public void testGetDistributionPoints() throws RFC2253NameParserException @@ -212,7 +250,7 @@ public class ConfigurationProviderTest extends TestCase assertEquals(reasonCodes, dp1.getReasonCodes()); CRLDistributionPoint dp2 = (CRLDistributionPoint) dps.toArray()[1]; - assertEquals("hhttp://crl.myotherca.org", dp2.getUri()); + assertEquals("http://crl.myotherca.org", dp2.getUri()); reasonCodes = iaik.asn1.structures.DistributionPoint.aACompromise | iaik.asn1.structures.DistributionPoint.affiliationChanged; @@ -242,45 +280,45 @@ public class ConfigurationProviderTest extends TestCase public void testGetCertStoreLocation() { assertEquals( - CONFIG_BASE_ + "certstore", - provider_.getCertStoreLocation()); + CONFIG_BASE_ + "certstore_test", + provider_.getCertStoreLocation().replace('\\', '/')); } public void testGetCreateTransformsInfoProfile() { Element ctip1 = provider_.getCreateTransformsInfoProfile("CTIP_1"); - assertEquals("CTIP1", ctip1.getLocalName()); + assertEquals("CreateTransformsInfoProfile", ctip1.getLocalName()); Element ctip2 = provider_.getCreateTransformsInfoProfile("CTIP_2"); - assertEquals("CTIP2", ctip2.getLocalName()); + assertEquals("CreateTransformsInfoProfile", ctip2.getLocalName()); } public void testGetCreateSignatureEnvironmentProfile() { - Element csep = provider_.getCreateTransformsInfoProfile("CSEP_1"); - assertEquals("CSEP1", csep.getLocalName()); + Element csep = provider_.getCreateSignatureEnvironmentProfile("CSEP_1"); + assertEquals("CreateSignatureEnvironmentProfile", csep.getLocalName()); } public void testGetVerifyTransformsInfoProfile() { - Element vtip = provider_.getCreateTransformsInfoProfile("VTIP_1"); - assertEquals("VTIP1", vtip.getLocalName()); + Element vtip = provider_.getVerifyTransformsInfoProfile("VTIP_1"); + assertEquals("VerifyTransformsInfoProfile", vtip.getLocalName()); } public void testGetSupplementProfile() { - Element sp = provider_.getCreateTransformsInfoProfile("SP_1"); - assertEquals("SP1", sp.getLocalName()); + 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", + "file:/" + CONFIG_BASE_ + "trustprofiles/tp1/anchors", tp1.getUri()); assertEquals( - "file:" + CONFIG_BASE_ + "trustprofiles/tp1/signercerts", + "file:/" + CONFIG_BASE_ + "trustprofiles/tp1/signercerts", tp1.getSignerCertsUri()); TrustProfile tp2 = provider_.getTrustProfile("TP2_Id"); 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); + } +} |