aboutsummaryrefslogtreecommitdiff
path: root/spss.server/src
diff options
context:
space:
mode:
Diffstat (limited to 'spss.server/src')
-rw-r--r--spss.server/src/at/gv/egovernment/moa/spss/server/config/ConfigurationPartsBuilder.java41
-rw-r--r--spss.server/src/at/gv/egovernment/moa/spss/server/config/ConfigurationProvider.java2
-rw-r--r--spss.server/src/test/at/gv/egovernment/moa/spss/AllTests.java3
-rw-r--r--spss.server/src/test/at/gv/egovernment/moa/spss/server/config/AllTests.java20
-rw-r--r--spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest1.java (renamed from spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest.java)144
-rw-r--r--spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest2.java225
-rw-r--r--spss.server/src/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest3.java166
7 files changed, 530 insertions, 71 deletions
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);
+ }
+}