From b33fd8084f4ea1562c9056422ebc111b4a92f2a6 Mon Sep 17 00:00:00 2001 From: pdanner Date: Mon, 10 Sep 2007 18:08:08 +0000 Subject: moved test classes, fixed spss-tools build git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@1003 d688527b-c9ab-4aba-bd8d-4036d912da1d --- spss/server/pom.xml | 2 +- spss/server/serverlib/pom.xml | 426 +++++++++++---------- .../java/at/gv/egovernment/moa/spss/AllTests.java | 40 -- .../at/gv/egovernment/moa/spss/SPSSTestCase.java | 82 ---- .../egovernment/moa/spss/api/xmlbind/AllTests.java | 24 -- .../CreateXMLSignatureRequestParserTest.java | 71 ---- .../moa/spss/api/xmlbind/TransformParserTest.java | 113 ------ .../VerifyCMSSignatureRequestParserTest.java | 61 --- .../VerifyXMLSignatureRequestParserTest.java | 81 ---- .../moa/spss/server/config/AllTests.java | 20 - .../server/config/ConfigurationProviderTest1.java | 377 ------------------ .../server/config/ConfigurationProviderTest2.java | 225 ----------- .../server/config/ConfigurationProviderTest3.java | 166 -------- .../iaik/config/ConfigurationDataImplTest.java | 149 ------- .../server/iaik/config/IaikConfiguratorTest.java | 36 -- .../moa/spss/server/invoke/AllTests.java | 25 -- .../CMSSignatureVerificationInvokerTest.java | 63 --- .../spss/server/invoke/DataObjectFactoryTest.java | 180 --------- .../server/invoke/TransformationFactoryTest.java | 201 ---------- .../invoke/XMLSignatureCreationInvokerTest.java | 63 --- .../XMLSignatureVerificationInvokerTest.java | 61 --- .../moa/spss/server/tools/CertToolTest.java | 50 --- .../test/at/gv/egovernment/moa/spss/AllTests.java | 40 ++ .../at/gv/egovernment/moa/spss/SPSSTestCase.java | 82 ++++ .../egovernment/moa/spss/api/xmlbind/AllTests.java | 24 ++ .../CreateXMLSignatureRequestParserTest.java | 71 ++++ .../moa/spss/api/xmlbind/TransformParserTest.java | 113 ++++++ .../VerifyCMSSignatureRequestParserTest.java | 61 +++ .../VerifyXMLSignatureRequestParserTest.java | 81 ++++ .../moa/spss/server/config/AllTests.java | 20 + .../server/config/ConfigurationProviderTest1.java | 377 ++++++++++++++++++ .../server/config/ConfigurationProviderTest2.java | 225 +++++++++++ .../server/config/ConfigurationProviderTest3.java | 166 ++++++++ .../iaik/config/ConfigurationDataImplTest.java | 149 +++++++ .../server/iaik/config/IaikConfiguratorTest.java | 36 ++ .../moa/spss/server/invoke/AllTests.java | 25 ++ .../CMSSignatureVerificationInvokerTest.java | 63 +++ .../spss/server/invoke/DataObjectFactoryTest.java | 180 +++++++++ .../server/invoke/TransformationFactoryTest.java | 201 ++++++++++ .../invoke/XMLSignatureCreationInvokerTest.java | 63 +++ .../XMLSignatureVerificationInvokerTest.java | 61 +++ .../moa/spss/server/tools/CertToolTest.java | 49 +++ spss/server/serverws/pom.xml | 2 +- spss/server/serverws/tools/ConfigurationMapper.xsl | 343 ----------------- spss/server/tools/pom.xml | 84 ++-- spss/server/tools/run/certtool.bat | 25 ++ spss/server/tools/run/certtool.sh | 20 + spss/server/tools/run/configtool.bat | 25 ++ spss/server/tools/run/configtool.sh | 20 + .../main/resources/tools/ConfigurationMapper.xsl | 343 +++++++++++++++++ .../tools/src/main/resources/tools/certtool.bat | 25 -- .../tools/src/main/resources/tools/certtool.sh | 20 - .../tools/src/main/resources/tools/configtool.bat | 25 -- .../tools/src/main/resources/tools/configtool.sh | 20 - 54 files changed, 2791 insertions(+), 2764 deletions(-) delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/AllTests.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/SPSSTestCase.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/AllTests.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParserTest.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/TransformParserTest.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParserTest.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParserTest.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/AllTests.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest1.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest2.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest3.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/iaik/config/ConfigurationDataImplTest.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/iaik/config/IaikConfiguratorTest.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/AllTests.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/CMSSignatureVerificationInvokerTest.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactoryTest.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/TransformationFactoryTest.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvokerTest.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvokerTest.java delete mode 100644 spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/tools/CertToolTest.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/AllTests.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/SPSSTestCase.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/AllTests.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParserTest.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/TransformParserTest.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParserTest.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParserTest.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/AllTests.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest1.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest2.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest3.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/iaik/config/ConfigurationDataImplTest.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/iaik/config/IaikConfiguratorTest.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/AllTests.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/CMSSignatureVerificationInvokerTest.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactoryTest.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/TransformationFactoryTest.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvokerTest.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvokerTest.java create mode 100644 spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/tools/CertToolTest.java delete mode 100644 spss/server/serverws/tools/ConfigurationMapper.xsl create mode 100644 spss/server/tools/run/certtool.bat create mode 100644 spss/server/tools/run/certtool.sh create mode 100644 spss/server/tools/run/configtool.bat create mode 100644 spss/server/tools/run/configtool.sh create mode 100644 spss/server/tools/src/main/resources/tools/ConfigurationMapper.xsl delete mode 100644 spss/server/tools/src/main/resources/tools/certtool.bat delete mode 100644 spss/server/tools/src/main/resources/tools/certtool.sh delete mode 100644 spss/server/tools/src/main/resources/tools/configtool.bat delete mode 100644 spss/server/tools/src/main/resources/tools/configtool.sh (limited to 'spss/server') diff --git a/spss/server/pom.xml b/spss/server/pom.xml index 82e8a8c2f..39593518e 100644 --- a/spss/server/pom.xml +++ b/spss/server/pom.xml @@ -14,9 +14,9 @@ MOA SP/SS Server + tools serverlib serverws - tools diff --git a/spss/server/serverlib/pom.xml b/spss/server/serverlib/pom.xml index c49a234a1..87e9b5575 100644 --- a/spss/server/serverlib/pom.xml +++ b/spss/server/serverlib/pom.xml @@ -1,208 +1,218 @@ - - - MOA.spss - moa-spss - 1.4.x - - - 4.0.0 - MOA.spss.server - moa-spss-lib - jar - 1.4.2 - MOA SP/SS API - - - ${basedir}/../../../repository - - - - - axis - axis - - - commons-discovery - commons-discovery - - - commons-logging - commons-logging - - - javax.activation - activation - - - javax.mail - mail - - - junit - junit - - - log4j - log4j - - - postgresql - postgresql - - - javax.servlet - servlet-api - provided - - - xalan-bin-dist - xalan - compile - - - xerces - xercesImpl - - - xalan-bin-dist - xml-apis - - - xalan-bin-dist - serializer - - - iaik.prod - iaik_moa - - - iaik.prod - iaik_ixsil - - - iaik.prod - iaik_jce_full - compile - - - iaik.prod - iaik_ecc - compile - - - iaik.prod - iaik_cms - runtime - - - iaik.prod - iaik_Pkcs11Provider - runtime - - - iaik.prod - iaik_Pkcs11Wrapper - runtime - - - iaik.prod - iaik_Pkcs11Wrapper - win32 - dll - runtime - true - - - MOA - moa-common - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - false - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.2 - - true - false - false - true - at.gv.egovernment.moa.spss.server.*;at.gv.egovernment.moa.spss.api.impl.*;at.gv.egovernment.moa.spss.impl.* - - - pre - a - Preconditions: - - - post - a - Postconditions: - - - - - API Factory and Services - at.gv.egovernment.moa.spss.api - - - Exceptions - at.gv.egovernment.moa.spss - - - API Objects for Signature Creation - at.gv.egovernment.moa.spss.api.xmlsign - - - API Objects for CMS Signature Verification - at.gv.egovernment.moa.spss.api.cmsverify - - - API Objects for XML Signature Verification - at.gv.egovernment.moa.spss.api.xmlverify - - - Common API Objects - at.gv.egovernment.moa.spss.api.common - - - Builders and Parsers to convert API Objects to and from XML - at.gv.egovernment.moa.spss.api.xmlbind - - - Utilities - at.gv.egovernment.moa.util - at.gv.egovernment.moa.spss.util - - - Logging - at.gv.egovernment.moa.logging - - - http://java.sun.com/j2se/1.4/docs/api/ - - - - generate-javadoc - package - - jar - - - - - - - - + + + MOA.spss + moa-spss + 1.4.x + + + 4.0.0 + MOA.spss.server + moa-spss-lib + jar + 1.4.2 + MOA SP/SS API + + + ${basedir}/../../../repository + + + + + axis + axis + + + commons-discovery + commons-discovery + + + commons-logging + commons-logging + + + javax.activation + activation + + + javax.mail + mail + + + junit + junit + + + log4j + log4j + + + postgresql + postgresql + + + javax.servlet + servlet-api + provided + + + xalan-bin-dist + xalan + compile + + + xerces + xercesImpl + + + xalan-bin-dist + xml-apis + + + xalan-bin-dist + serializer + + + iaik.prod + iaik_moa + + + iaik.prod + iaik_ixsil + + + iaik.prod + iaik_jce_full + compile + + + iaik.prod + iaik_ecc + compile + + + iaik.prod + iaik_cms + runtime + + + iaik.prod + iaik_Pkcs11Provider + runtime + + + iaik.prod + iaik_Pkcs11Wrapper + runtime + + + iaik.prod + iaik_Pkcs11Wrapper + win32 + dll + runtime + true + + + MOA + moa-common + jar + + + MOA + moa-common + test-jar + + + MOA.spss.server + moa-spss-tools + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + false + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.2 + + true + false + false + true + at.gv.egovernment.moa.spss.server.*;at.gv.egovernment.moa.spss.api.impl.*;at.gv.egovernment.moa.spss.impl.* + + + pre + a + Preconditions: + + + post + a + Postconditions: + + + + + API Factory and Services + at.gv.egovernment.moa.spss.api + + + Exceptions + at.gv.egovernment.moa.spss + + + API Objects for Signature Creation + at.gv.egovernment.moa.spss.api.xmlsign + + + API Objects for CMS Signature Verification + at.gv.egovernment.moa.spss.api.cmsverify + + + API Objects for XML Signature Verification + at.gv.egovernment.moa.spss.api.xmlverify + + + Common API Objects + at.gv.egovernment.moa.spss.api.common + + + Builders and Parsers to convert API Objects to and from XML + at.gv.egovernment.moa.spss.api.xmlbind + + + Utilities + at.gv.egovernment.moa.util + at.gv.egovernment.moa.spss.util + + + Logging + at.gv.egovernment.moa.logging + + + http://java.sun.com/j2se/1.4/docs/api/ + + + + generate-javadoc + package + + jar + + + + + + + + diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/AllTests.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/AllTests.java deleted file mode 100644 index c670b5e55..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/AllTests.java +++ /dev/null @@ -1,40 +0,0 @@ -package test.at.gv.egovernment.moa.spss; - -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; - -import junit.awtui.TestRunner; -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Test suite for all unit tests. - * - * @author Patrick Peck - * @version $Id$ - */ -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite(); - - suite.addTestSuite(test.at.gv.egovernment.moa.spss.server.config.AllTests.class); - suite.addTestSuite(ConfigurationDataImplTest.class); - suite.addTestSuite(IaikConfiguratorTest.class); - suite.addTest( - test.at.gv.egovernment.moa.spss.server.invoke.AllTests.suite()); - suite.addTest(test.at.gv.egovernment.moa.spss.api.xmlbind.AllTests.suite()); - suite.addTestSuite(CertToolTest.class); - - return suite; - } - - public static void main(String[] args) { - try { - TestRunner.run(AllTests.class); - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/SPSSTestCase.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/SPSSTestCase.java deleted file mode 100644 index a585e30a0..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/SPSSTestCase.java +++ /dev/null @@ -1,82 +0,0 @@ -package test.at.gv.egovernment.moa.spss; - -import java.security.Security; - -import test.at.gv.egovernment.moa.MOATestCase; - -import at.gv.egovernment.moa.logging.Logger; -import at.gv.egovernment.moa.logging.LoggingContext; -import at.gv.egovernment.moa.logging.LoggingContextManager; -import at.gv.egovernment.moa.util.MessageProvider; - -import at.gv.egovernment.moa.spss.server.config.ConfigurationProvider; -import at.gv.egovernment.moa.spss.server.iaik.config.IaikConfigurator; -import at.gv.egovernment.moa.spss.server.transaction.TransactionContext; -import at.gv.egovernment.moa.spss.server.transaction.TransactionContextManager; - -/** - * Base class for MOA test cases. - * - * Provides some utility functions. - * - * @author Patrick Peck - * @version $Id$ - */ -public class SPSSTestCase extends MOATestCase { - - protected static final String TESTDATA_ROOT = "data/test/"; - - /** - * Constructor for MOATestCase. - * @param arg0 - */ - public SPSSTestCase(String name) { - super(name); - } - - /** - * Set up a transaction context with a test configuration. - */ - protected void setUpTransactionContext() throws Exception { - System.setProperty( - ConfigurationProvider.CONFIG_PROPERTY_NAME, - "data/test/conf/moa-spss/MOA-SPSSConfiguration.xml"); - ConfigurationProvider config = ConfigurationProvider.getInstance(); - TransactionContext context = new TransactionContext("test", null, config); - TransactionContextManager.getInstance().setTransactionContext(context); - } - - protected void setUpLoggingContext() throws Exception { - LoggingContext context = new LoggingContext("test"); - LoggingContextManager.getInstance().setLoggingContext(context); - } - - /** - * Configure the IAIK modules with the current configuration. - * - * A TransactionContext must have been set up before. - */ - protected void setUpIaikConfiguration() throws Exception { - TransactionContext context = - TransactionContextManager.getInstance().getTransactionContext(); - ClassLoader cl = getClass().getClassLoader(); - MessageProvider msg = MessageProvider.getInstance(); - - try { - cl.loadClass("javax.security.cert.Certificate"); // from jcert.jar - } catch (ClassNotFoundException e) { - Logger.warn(msg.getMessage("init.03", null), e); - } - - new IaikConfigurator().configure(context.getConfiguration()); - } - - protected void setUpSSL() throws Exception { - //System.setProperty("javax.net.debug", "all"); - Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); - System.setProperty( - "java.protocol.handler.pkgs", - "com.sun.net.ssl.internal.www.protocol"); - } - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/AllTests.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/AllTests.java deleted file mode 100644 index 28f79729e..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/AllTests.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.at.gv.egovernment.moa.spss.api.xmlbind; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Runs all tests in this package. - * - * @author Patrick Peck - * @version $Id$ - */ -public class AllTests { - public static Test suite() { - TestSuite suite = new TestSuite(); - - suite.addTestSuite(CreateXMLSignatureRequestParserTest.class); - suite.addTestSuite(TransformParserTest.class); - suite.addTestSuite(VerifyCMSSignatureRequestParserTest.class); - suite.addTestSuite(VerifyXMLSignatureRequestParserTest.class); - - return suite; - } - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParserTest.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParserTest.java deleted file mode 100644 index 7ce705b01..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParserTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package test.at.gv.egovernment.moa.spss.api.xmlbind; - -import org.w3c.dom.Element; - -import test.at.gv.egovernment.moa.spss.SPSSTestCase; - -import at.gv.egovernment.moa.spss.api.xmlbind.CreateXMLSignatureRequestParser; -import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureEnvironmentProfileExplicit; -import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfoProfileExplicit; -import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureRequest; -import at.gv.egovernment.moa.spss.api.xmlsign.DataObjectInfo; -import at.gv.egovernment.moa.spss.api.xmlsign.SingleSignatureInfo; - -/** - * Test the CreateXMLSignatureRequestParser. - * - * @author Patrick Peck - * @version $Id$ - */ -public class CreateXMLSignatureRequestParserTest extends SPSSTestCase { - private static final String TESTDATA_BASE = - TESTDATA_ROOT + "xml/CreateXMLSignature/"; - - private CreateXMLSignatureRequestParser requestParser; - - public CreateXMLSignatureRequestParserTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - requestParser = new CreateXMLSignatureRequestParser(); - } - - public void testParse() throws Exception { - Element requestElem = - parseXml(TESTDATA_BASE + "TestGeneratorCX2.001.Req.xml") - .getDocumentElement(); - CreateXMLSignatureRequest request = requestParser.parse(requestElem); - SingleSignatureInfo sigInfo; - DataObjectInfo dataObjInfo; - CreateTransformsInfoProfileExplicit transProfile; - CreateSignatureEnvironmentProfileExplicit envProfile; - - assertNotNull(request); - assertEquals("PKCS12RSAKey1", request.getKeyIdentifier()); - assertEquals(1, request.getSingleSignatureInfos().size()); - - sigInfo = (SingleSignatureInfo) request.getSingleSignatureInfos().get(0); - assertEquals(1, sigInfo.getDataObjectInfos().size()); - assertFalse(sigInfo.isSecurityLayerConform()); - - dataObjInfo = (DataObjectInfo) sigInfo.getDataObjectInfos().get(0); - assertNotNull(dataObjInfo.getDataObject()); - - transProfile = - (CreateTransformsInfoProfileExplicit) dataObjInfo - .getCreateTransformsInfoProfile(); - assertNotNull( - transProfile.getCreateTransformsInfo().getFinalDataMetaInfo()); - - envProfile = - (CreateSignatureEnvironmentProfileExplicit) sigInfo - .getCreateSignatureInfo() - .getCreateSignatureEnvironmentProfile(); - assertEquals( - "//data:Document", - envProfile.getCreateSignatureLocation().getXPathExpression()); - assertEquals(0, envProfile.getCreateSignatureLocation().getIndex()); - } - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/TransformParserTest.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/TransformParserTest.java deleted file mode 100644 index f580f86bc..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/TransformParserTest.java +++ /dev/null @@ -1,113 +0,0 @@ -package test.at.gv.egovernment.moa.spss.api.xmlbind; - -import java.util.List; - -import org.w3c.dom.Element; - -import test.at.gv.egovernment.moa.spss.SPSSTestCase; - -import at.gv.egovernment.moa.spss.api.common.CanonicalizationTransform; -import at.gv.egovernment.moa.spss.api.common.EnvelopedSignatureTransform; -import at.gv.egovernment.moa.spss.api.common.ExclusiveCanonicalizationTransform; -import at.gv.egovernment.moa.spss.api.common.XPathFilter2Transform; -import at.gv.egovernment.moa.spss.api.common.XPathTransform; -import at.gv.egovernment.moa.spss.api.common.XSLTTransform; -import at.gv.egovernment.moa.spss.api.xmlbind.TransformParser; - -/** - * Test the TransformParser. - * - * @author Patrick Peck - * @version $Id$ - */ -public class TransformParserTest extends SPSSTestCase { - private static String TESTDATA_BASE = TESTDATA_ROOT + "xml/dsigTransform/"; - - private TransformParser transformParser; - - public TransformParserTest(String name) { - super(name); - } - - protected void setUp() { - transformParser = new TransformParser(); - } - - public void testParseTransforms() throws Exception { - Element transformsElem = - parseXml(TESTDATA_BASE + "transforms.xml").getDocumentElement(); - List transforms = transformParser.parseTransforms(transformsElem); - - assertNotNull(transforms); - assertEquals(3, transforms.size()); - - } - - public void testParseCanonicalizationTransform() throws Exception { - Element transformElem = - parseXml(TESTDATA_BASE + "canonicalization.xml").getDocumentElement(); - CanonicalizationTransform transform = - (CanonicalizationTransform) transformParser.parseTransform(transformElem); - - assertNotNull(transform); - assertEquals( - CanonicalizationTransform.CANONICAL_XML, - transform.getAlgorithmURI()); - } - - public void testParseExclCanonicalizationTransform() throws Exception { - Element transformElem = - parseXml(TESTDATA_BASE + "exclusiveCanonicalization.xml") - .getDocumentElement(); - ExclusiveCanonicalizationTransform transform = - (ExclusiveCanonicalizationTransform) transformParser.parseTransform( - transformElem); - - assertNotNull(transform); - assertEquals( - ExclusiveCanonicalizationTransform.EXCLUSIVE_CANONICAL_XML, - transform.getAlgorithmURI()); - assertEquals(3, transform.getInclusiveNamespacePrefixes().size()); - } - - public void testParseEnvelopedTransform() throws Exception { - Element transformElem = - parseXml(TESTDATA_BASE + "enveloped.xml").getDocumentElement(); - EnvelopedSignatureTransform transform = - (EnvelopedSignatureTransform) transformParser.parseTransform( - transformElem); - - assertNotNull(transform); - } - - public void testParseXPathTransform() throws Exception { - Element transformElem = - parseXml(TESTDATA_BASE + "xpath.xml").getDocumentElement(); - XPathTransform transform = - (XPathTransform) transformParser.parseTransform(transformElem); - - assertNotNull(transform); - assertEquals("//ToBeSigned/Data", transform.getXPathExpression()); - assertEquals(1, transform.getNamespaceDeclarations().size()); - } - - public void testParseXPathFilter2Transform() throws Exception { - Element transformElem = - parseXml(TESTDATA_BASE + "xpath2.xml").getDocumentElement(); - XPathFilter2Transform transform = - (XPathFilter2Transform) transformParser.parseTransform(transformElem); - - assertNotNull(transform); - assertEquals(3, transform.getFilters().size()); - } - - public void testParseXSLTTransform() throws Exception { - Element transformElem = - parseXml(TESTDATA_BASE + "xslt.xml").getDocumentElement(); - XSLTTransform transform = - (XSLTTransform) transformParser.parseTransform(transformElem); - - assertNotNull(transform); - } - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParserTest.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParserTest.java deleted file mode 100644 index 4be7667eb..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParserTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package test.at.gv.egovernment.moa.spss.api.xmlbind; - -import org.w3c.dom.Element; - -import at.gv.egovernment.moa.util.DateTimeUtils; - -import test.at.gv.egovernment.moa.spss.SPSSTestCase; - -import at.gv.egovernment.moa.spss.api.cmsverify.CMSContentExcplicit; -import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureRequest; -import at.gv.egovernment.moa.spss.api.common.MetaInfo; -import at.gv.egovernment.moa.spss.api.xmlbind.VerifyCMSSignatureRequestParser; - -/** - * Test the VerifyCMSSignatureRequestParserTest. - * - * @author Patrick Peck - * @version $Id$ - */ -public class VerifyCMSSignatureRequestParserTest extends SPSSTestCase { - private static String TESTDATA_BASE = - TESTDATA_ROOT + "xml/VerifyCMSSignature/"; - - private VerifyCMSSignatureRequestParser requestParser; - - public VerifyCMSSignatureRequestParserTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - requestParser = new VerifyCMSSignatureRequestParser(); - } - - public void testParse() throws Exception { - Element requestElem = - parseXml(TESTDATA_BASE + "TestGeneratorVC0.001.Req.xml") - .getDocumentElement(); - VerifyCMSSignatureRequest request = requestParser.parse(requestElem); - MetaInfo metaInfo; - CMSContentExcplicit content; - - assertNotNull(request); - assertEquals(1, request.getSignatories()[0]); - assertEquals( - DateTimeUtils.parseDateTime("2003-04-04T09:30:47-05:00"), - request.getDateTime()); - assertNotNull(request.getCMSSignature()); - assertNotNull(request.getDataObject()); - assertEquals("TrustProfile1", request.getTrustProfileId()); - - metaInfo = request.getDataObject().getMetaInfo(); - assertNotNull(metaInfo); - assertEquals("text/plain", metaInfo.getMimeType()); - assertEquals("http://10.16.46.109/TestDatenGenerator/resources/testDaten.txt", metaInfo.getDescription()); - - content = (CMSContentExcplicit) request.getDataObject().getContent(); - assertNotNull(content.getBinaryContent()); - - } - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParserTest.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParserTest.java deleted file mode 100644 index 3b8e8b00e..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParserTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package test.at.gv.egovernment.moa.spss.api.xmlbind; - -import org.w3c.dom.Element; - -import test.at.gv.egovernment.moa.spss.SPSSTestCase; - -import at.gv.egovernment.moa.util.DateTimeUtils; - -import at.gv.egovernment.moa.spss.api.xmlbind.VerifyXMLSignatureRequestParser; -import at.gv.egovernment.moa.spss.api.xmlverify.ReferenceInfo; -import at.gv.egovernment.moa.spss.api.xmlverify.SignatureManifestCheckParams; -import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureInfo; -import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureLocation; -import at.gv.egovernment.moa.spss.api.xmlverify.VerifyTransformsInfoProfileExplicit; -import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureRequest; - -/** - * Test the VerifyXMLSignatureRequestParserTest. - * - * @author Patrick Peck - * @version $Id$ - */ -public class VerifyXMLSignatureRequestParserTest extends SPSSTestCase { - private static String TESTDATA_BASE = - TESTDATA_ROOT + "xml/VerifyXMLSignature/"; - - private VerifyXMLSignatureRequestParser parser; - - public VerifyXMLSignatureRequestParserTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - parser = new VerifyXMLSignatureRequestParser(); - } - - public void testParse() throws Exception { - Element requestElem = - parseXml(TESTDATA_BASE + "TestGeneratorVX.201.Req.xml") - .getDocumentElement(); - VerifyXMLSignatureRequest request = parser.parse(requestElem); - VerifySignatureInfo verifySignatureInfo; - VerifySignatureLocation verifyLocation; - SignatureManifestCheckParams checkParams; - ReferenceInfo refInfo; - VerifyTransformsInfoProfileExplicit transformsProfile; - - assertNotNull(request); - assertEquals( - DateTimeUtils.parseDateTime("2003-04-01T12:53:57+01:00"), - request.getDateTime()); - assertFalse(request.getReturnHashInputData()); - assertEquals("TrustProfile1", request.getTrustProfileId()); - - verifySignatureInfo = request.getSignatureInfo(); - assertNotNull(verifySignatureInfo); - assertNotNull(verifySignatureInfo.getVerifySignatureEnvironment()); - - verifyLocation = verifySignatureInfo.getVerifySignatureLocation(); - assertNotNull(verifyLocation); - assertEquals("//dsig:Signature", verifyLocation.getXPathExpression()); - assertEquals(3, verifyLocation.getNamespaceDeclarations().size()); - - checkParams = request.getSignatureManifestCheckParams(); - assertNotNull(checkParams); - assertEquals(true, checkParams.getReturnReferenceInputData()); - assertEquals(1, checkParams.getReferenceInfos().size()); - - refInfo = (ReferenceInfo) checkParams.getReferenceInfos().get(0); - assertEquals(1, refInfo.getVerifyTransformsInfoProfiles().size()); - - transformsProfile = - (VerifyTransformsInfoProfileExplicit) refInfo - .getVerifyTransformsInfoProfiles() - .get(0); - assertEquals(1, transformsProfile.getTransforms().size()); - assertEquals(1, transformsProfile.getTransformParameters().size()); - - } - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/AllTests.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/AllTests.java deleted file mode 100644 index 131f38c19..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/AllTests.java +++ /dev/null @@ -1,20 +0,0 @@ -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/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest1.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest1.java deleted file mode 100644 index 474a387ad..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest1.java +++ /dev/null @@ -1,377 +0,0 @@ -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.getMessage()); - } - } - - /** - * 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()); - - Iterator dpIt = dps.iterator(); - while (dpIt.hasNext()) - { - CRLDistributionPoint currentDP = (CRLDistributionPoint)dpIt.next(); - if ("http://crl.myca.org".equals(currentDP.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, currentDP.getReasonCodes()); - } - else if ("http://crl.myotherca.org".equals(currentDP.getUri())) - { - int reasonCodes = - iaik.asn1.structures.DistributionPoint.aACompromise | - iaik.asn1.structures.DistributionPoint.affiliationChanged; - assertEquals(reasonCodes, currentDP.getReasonCodes()); - } - else fail("Invalid CRL DP URI found: " + currentDP.getUri()); - } - - 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/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest2.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest2.java deleted file mode 100644 index adf02809b..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest2.java +++ /dev/null @@ -1,225 +0,0 @@ -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.getMessage()); - } - } - - - /** - * 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/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest3.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest3.java deleted file mode 100644 index 7da2165cb..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest3.java +++ /dev/null @@ -1,166 +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.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.getMessage()); - } - } - - /** - * 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); - } -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/iaik/config/ConfigurationDataImplTest.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/iaik/config/ConfigurationDataImplTest.java deleted file mode 100644 index be1090e4a..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/iaik/config/ConfigurationDataImplTest.java +++ /dev/null @@ -1,149 +0,0 @@ -package test.at.gv.egovernment.moa.spss.server.iaik.config; - -import java.io.FileInputStream; -import java.security.KeyStore; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import test.at.gv.egovernment.moa.spss.SPSSTestCase; - -import iaik.asn1.structures.DistributionPoint; -import iaik.pki.PKIConfiguration; -import iaik.pki.pathvalidation.ChainingModes; -import iaik.pki.pathvalidation.ValidationConfiguration; -import iaik.pki.revocation.CRLDistributionPoint; -import iaik.pki.revocation.RevocationConfiguration; -import iaik.pki.store.certstore.CertStoreConfiguration; -import iaik.pki.store.certstore.CertStoreTypes; -import iaik.pki.store.revocation.archive.ArchiveConfiguration; -import iaik.pki.store.revocation.archive.db.DataBaseArchiveParameter; -import iaik.server.ConfigurationData; -import iaik.server.modules.keys.HardwareKeyModuleConfiguration; -import iaik.server.modules.keys.SoftwareKeyModuleConfiguration; - -import at.gv.egovernment.moa.spss.server.iaik.config.ConfigurationDataImpl; -import at.gv.egovernment.moa.spss.server.transaction.TransactionContext; -import at.gv.egovernment.moa.spss.server.transaction.TransactionContextManager; - -/** - * Tests the ConfigurationDataImpl. - * - * @author Patrick Peck - * @version $Id$ - */ -public class ConfigurationDataImplTest extends SPSSTestCase { - - private ConfigurationData config; - private X509Certificate iaikCert; - - public ConfigurationDataImplTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - TransactionContext context; - - setUpTransactionContext(); - context = TransactionContextManager.getInstance().getTransactionContext(); - - config = new ConfigurationDataImpl(context.getConfiguration()); - - KeyStore ks = KeyStore.getInstance("JKS", "SUN"); - ks.load( - new FileInputStream(TESTDATA_ROOT + "security/server.keystore"), - "changeit".toCharArray()); - - CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); - Collection certs = - certFactory.generateCertificates( - new FileInputStream( - TESTDATA_ROOT - + "conf/moa-spss/trustprofiles/TrustProfile1/IAIKRoot.cer")); - iaikCert = (X509Certificate) certs.toArray()[0]; - - } - - public void testGetPKIConfiguration() { - PKIConfiguration pkiConfig = config.getPKIConfiguration(); - ArchiveConfiguration archiveConfig = pkiConfig.getArchiveConfiguration(); - CertStoreConfiguration certStoreConfig = - pkiConfig.getCertStoreConfiguration(); - RevocationConfiguration revocationConfig = - pkiConfig.getRevocationConfiguration(); - ValidationConfiguration validationConfig = - pkiConfig.getValidationConfiguration(); - DataBaseArchiveParameter archiveParam; - Set distributionPoints; - Iterator iter; - boolean found; - - // test archive parameters - archiveParam = - (DataBaseArchiveParameter) archiveConfig.getArchiveParameters(); - assertEquals( - archiveParam.getJDBCUrl(), - "jdbc:postgresql://10.16.46.108/moa?user=moa&password=moatest"); - - // test cert store configuration - assertEquals(1, certStoreConfig.getParameters().length); - assertEquals( - CertStoreTypes.DIRECTORY, - certStoreConfig.getParameters()[0].getType()); - - // test revocation configuration - distributionPoints = - revocationConfig.getAlternativeDistributionPoints(iaikCert, null, new Date()); - assertEquals(3, distributionPoints.size()); - found = false; - for (iter = distributionPoints.iterator(); iter.hasNext();) { - CRLDistributionPoint dp = (CRLDistributionPoint) iter.next(); - if (dp.getUri().equals("http://www.iaik.at/testCA/iaik_test_sig.crl")) { - found = - dp.getReasonCodes() - == (DistributionPoint.keyCompromise - | DistributionPoint.affiliationChanged); - } - } - assertTrue(found); - - // test validation configuration - assertEquals( - ChainingModes.PKIX_MODE, - validationConfig.getChainingMode(iaikCert)); - } - - /* - public void testGetCryptoModuleConfigurations() { - List cryptoConfigs = config.getCryptoModuleConfigurations(); - HardwareCryptoModuleConfiguration moduleConfig; - - assertEquals(2, cryptoConfigs.size()); - moduleConfig = (HardwareCryptoModuleConfiguration) cryptoConfigs.get(0); - assertEquals("Module1", moduleConfig.getModuleName()); - assertEquals("Slot1", moduleConfig.getSlotID()); - assertEquals("PIN1", new String(moduleConfig.getUserPIN())); - } - */ - - public void testGetKeyModuleConfigurations() { - List keyConfigs = config.getKeyModuleConfigurations(); - HardwareKeyModuleConfiguration hwKey; - SoftwareKeyModuleConfiguration swKey; - - assertEquals(7, keyConfigs.size()); - hwKey = (HardwareKeyModuleConfiguration) keyConfigs.get(0); - assertEquals("cryptoki.dll", hwKey.getModuleName()); - assertEquals("0", hwKey.getSlotID()); - assertEquals("0000", new String(hwKey.getUserPIN())); - swKey = (SoftwareKeyModuleConfiguration) keyConfigs.get(1); - assertEquals( - "buergerkarte", - new String(swKey.getKeyStoreAuthenticationData())); - } - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/iaik/config/IaikConfiguratorTest.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/iaik/config/IaikConfiguratorTest.java deleted file mode 100644 index 3b403dc19..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/iaik/config/IaikConfiguratorTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package test.at.gv.egovernment.moa.spss.server.iaik.config; - -import test.at.gv.egovernment.moa.spss.SPSSTestCase; - -import at.gv.egovernment.moa.spss.server.iaik.config.IaikConfigurator; -import at.gv.egovernment.moa.spss.server.transaction.TransactionContext; -import at.gv.egovernment.moa.spss.server.transaction.TransactionContextManager; - -/** - * Tests the IaikConfigurator. - * - * @author Patrick Peck - * @version $Id$ - */ -public class IaikConfiguratorTest extends SPSSTestCase { - - public IaikConfiguratorTest(String name) { - super(name); - } - - /** - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUpTransactionContext(); - } - - public void testConfigure() throws Exception { - IaikConfigurator configurator = new IaikConfigurator(); - TransactionContext context = - TransactionContextManager.getInstance().getTransactionContext(); - - configurator.configure(context.getConfiguration()); - } - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/AllTests.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/AllTests.java deleted file mode 100644 index 65fa2bf72..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/AllTests.java +++ /dev/null @@ -1,25 +0,0 @@ -package test.at.gv.egovernment.moa.spss.server.invoke; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Runs all tests in this package. - * - * @author Patrick Peck - * @version $Id$ - */ -public class AllTests { - public static Test suite() { - TestSuite suite = new TestSuite(); - - suite.addTestSuite(DataObjectFactoryTest.class); - suite.addTestSuite(TransformationFactoryTest.class); - suite.addTestSuite(XMLSignatureCreationInvokerTest.class); - suite.addTestSuite(CMSSignatureVerificationInvokerTest.class); - suite.addTestSuite(XMLSignatureVerificationInvokerTest.class); - - return suite; - } - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/CMSSignatureVerificationInvokerTest.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/CMSSignatureVerificationInvokerTest.java deleted file mode 100644 index 3024730f4..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/CMSSignatureVerificationInvokerTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package test.at.gv.egovernment.moa.spss.server.invoke; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import test.at.gv.egovernment.moa.spss.SPSSTestCase; - -import at.gv.egovernment.moa.util.DOMUtils; - -import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureRequest; -import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponse; -import at.gv.egovernment.moa.spss.api.xmlbind.VerifyCMSSignatureRequestParser; -import at.gv.egovernment.moa.spss.api.xmlbind.VerifyCMSSignatureResponseBuilder; -import at.gv.egovernment.moa.spss.server.invoke.CMSSignatureVerificationInvoker; - -/** - * Mainly a smoke test for debugging the CMSSignatureVerificationInvoker. - * - * @author Patrick Peck - * @version $Id$ - */ -public class CMSSignatureVerificationInvokerTest extends SPSSTestCase { - private static final String TESTDATA_BASE = - TESTDATA_ROOT + "xml/VerifyCMSSignature/"; - - /** - * Constructor for CMSSignatureVerificationInvokerTest. - * @param name - */ - public CMSSignatureVerificationInvokerTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - setUpTransactionContext(); - setUpLoggingContext(); - setUpIaikConfiguration(); - } - - public void testVerifyCMSSignature() throws Exception { - try { - CMSSignatureVerificationInvoker invoker = - CMSSignatureVerificationInvoker.getInstance(); - VerifyCMSSignatureRequestParser requestParser = - new VerifyCMSSignatureRequestParser(); - Document doc = - SPSSTestCase.parseXmlValidating( - TESTDATA_BASE + "TestGeneratorVC0.001.Req.xml"); - VerifyCMSSignatureRequest request = - requestParser.parse(doc.getDocumentElement()); - VerifyCMSSignatureResponse response = invoker.verifyCMSSignature(request); - VerifyCMSSignatureResponseBuilder responseBuilder = - new VerifyCMSSignatureResponseBuilder(); - Element result = responseBuilder.build(response).getDocumentElement(); - - System.out.println(DOMUtils.serializeNode(result)); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - } - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactoryTest.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactoryTest.java deleted file mode 100644 index 7de2add33..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactoryTest.java +++ /dev/null @@ -1,180 +0,0 @@ -package test.at.gv.egovernment.moa.spss.server.invoke; - -import java.io.InputStream; -import java.security.Security; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import test.at.gv.egovernment.moa.spss.SPSSTestCase; - -import iaik.server.modules.xml.BinaryDataObject; -import iaik.server.modules.xml.DataObject; -import iaik.server.modules.xml.XMLDataObject; - -import at.gv.egovernment.moa.util.Base64Utils; - -import at.gv.egovernment.moa.spss.MOAException; -import at.gv.egovernment.moa.spss.api.SPSSFactory; -import at.gv.egovernment.moa.spss.api.common.Content; -import at.gv.egovernment.moa.spss.server.iaik.xml.ByteArrayDataObjectImpl; -import at.gv.egovernment.moa.spss.server.iaik.xml.ByteStreamDataObjectImpl; -import at.gv.egovernment.moa.spss.server.iaik.xml.XMLDataObjectImpl; -import at.gv.egovernment.moa.spss.server.iaik.xml.XMLNodeListDataObjectImpl; -import at.gv.egovernment.moa.spss.server.invoke.DataObjectFactory; - -/** - * Test cases for the DataObjectFactory class. - * - * @author Patrick Peck - * @version $Id$ - */ -public class DataObjectFactoryTest extends SPSSTestCase { - - private static final String HTTP_BINARY_CONTENT_URL = "http://www.google.com"; - private static final String HTTP_XML_CONTENT_URL = - "http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"; - private static final String HTTPS_BINARY_CONTENT_URL = - "https://businessnet.ba-ca.com"; - private static final String HTTPS_UNTRUSTED_URL = - "https://heribert.anecon.com"; - private static final String HTTP_UNKNOWN_HOST_URL = "http://uurjmjmruuw.com"; - private static final String MALFORMED_URL = "//hsld///ddd"; - private static final String FILE_BINARY_CONTENT_URL = "file:/C:/boot.ini"; - private static final String XML_CONTENT = - "" - + " " - + " " - + ""; - private static final String BASE64_CONTENT = "U3Zlbg=="; - - private SPSSFactory spssFactory = SPSSFactory.getInstance(); - private DataObjectFactory factory; - - /** - * Constructor for DataObjectFactoryTest. - * @param name - */ - public DataObjectFactoryTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - factory = DataObjectFactory.getInstance(); - - // set up SSL - Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); - System.setProperty( - "java.protocol.handler.pkgs", - "com.sun.net.ssl.internal.www.protocol"); - /* - System.setProperty( - "javax.net.ssl.keyStore", - "data/test/security/client.keystore"); - System.setProperty("javax.net.ssl.keyStorePassword", "changeit"); - System.setProperty( - "javax.net.ssl.trustStore", - "data/test/security/client.keystore"); - System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); - */ - } - - public void testCreateFromURIWithBinaryHttp() throws Exception { - DataObject dataObject = - factory.createFromURI(HTTP_BINARY_CONTENT_URL, false); - - assertNotNull(dataObject); - assertTrue(dataObject instanceof ByteStreamDataObjectImpl); - assertNotNull(((BinaryDataObject) dataObject).getInputStream()); - } - - public void testCreateFromURIWithXmlHttp() throws Exception { - DataObject dataObject = factory.createFromURI(HTTP_XML_CONTENT_URL, false); - Element element; - - assertNotNull(dataObject); - assertTrue(dataObject instanceof XMLDataObjectImpl); - element = ((XMLDataObject) dataObject).getElement(); - assertNotNull(element); - assertEquals("schema", element.getTagName()); - } - - public void testCreateFromURIWithMalformedURI() throws Exception { - try { - factory.createFromURI(MALFORMED_URL, false); - fail(); - } catch (MOAException e) { - } - } - - public void testCreateFromURIWithNonExistingHttpURL() throws Exception { - try { - factory.createFromURI(HTTP_UNKNOWN_HOST_URL, false); - fail(); - } catch (MOAException e) { - } - } - - public void testCreateFromURIWithHttps() throws Exception { - DataObject dataObject = - factory.createFromURI(HTTPS_BINARY_CONTENT_URL, false); - assertNotNull(dataObject); - assertTrue(dataObject instanceof BinaryDataObject); - } - - public void testCreateFromURIWithUntrustedHttps() throws Exception { - try { - factory.createFromURI(HTTPS_UNTRUSTED_URL, false); - fail(); - } catch (MOAException e) { - - } - } - - public void testCreateFromURIWithFile() throws Exception { - try { - factory.createFromURI(FILE_BINARY_CONTENT_URL, false); - fail(); - } catch (MOAException e) { - } - } - - public void testCreateFromContentOptionalRefTypeWithXmlContent() - throws Exception { - Document doc = parseXmlString(XML_CONTENT); - Content content = - spssFactory.createContent( - doc.getDocumentElement().getChildNodes(), - "http://data"); - DataObject dataObject = - factory.createFromContentOptionalRefType( - content, - null, - null, - true, - false, - true, - false); - - assertTrue(dataObject instanceof XMLNodeListDataObjectImpl); - } - - public void testCreateFromContentOptionalRefTypeWithBase64Content() - throws Exception { - InputStream is = Base64Utils.decodeToStream(BASE64_CONTENT, true); - Content content = spssFactory.createContent(is, "http://data"); - DataObject dataObject = - factory.createFromContentOptionalRefType( - content, - null, - null, - false, - false, - true, - false); - - assertNotNull(dataObject); - assertTrue(dataObject instanceof ByteArrayDataObjectImpl); - } - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/TransformationFactoryTest.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/TransformationFactoryTest.java deleted file mode 100644 index 13a80cbf1..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/TransformationFactoryTest.java +++ /dev/null @@ -1,201 +0,0 @@ -package test.at.gv.egovernment.moa.spss.server.invoke; - -import java.util.List; -import java.util.Map; - -import org.w3c.dom.Document; - -import test.at.gv.egovernment.moa.spss.SPSSTestCase; - -import iaik.ixsil.init.IXSILInit; -import iaik.ixsil.util.URI; -import iaik.server.modules.xml.Base64Transformation; -import iaik.server.modules.xml.Canonicalization; -import iaik.server.modules.xml.EnvelopedSignatureTransformation; -import iaik.server.modules.xml.Transformation; -import iaik.server.modules.xml.XPath2Transformation; -import iaik.server.modules.xml.XPathTransformation; -import iaik.server.modules.xml.XSLTTransformation; - -import at.gv.egovernment.moa.util.Constants; - -import at.gv.egovernment.moa.spss.MOAApplicationException; -import at.gv.egovernment.moa.spss.api.common.Transform; -import at.gv.egovernment.moa.spss.api.xmlbind.TransformParser; -import at.gv.egovernment.moa.spss.server.invoke.TransformationFactory; - -/** - * Test cases for the TransformationFactory class. - * - * @author Patrick Peck - * @version $Id$ - */ -public class TransformationFactoryTest extends SPSSTestCase { - - private static final String TESTDATA_BASE = - TESTDATA_ROOT + "xml/dsigTransform/"; - private TransformationFactory factory = TransformationFactory.getInstance(); - private TransformParser transformParser = new TransformParser(); - - /** - * Constructor for TransformationFactoryTest. - * @param name - */ - public TransformationFactoryTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - IXSILInit.init(new URI("init/properties/init.properties")); - //IXSILInit.init(new URI("file:data/deploy/ixsil/init/properties/init.properties")); - - } - - public void testCreateCanonicalization() throws Exception { - Document transform = parseXml(TESTDATA_BASE + "canonicalization.xml"); - Transform tr = - transformParser.parseTransform(transform.getDocumentElement()); - Transformation t = factory.createTransformation(tr); - - assertTrue(t instanceof Canonicalization); - assertEquals( - "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", - t.getAlgorithmURI()); - } - - public void testCreateCanonicalizationWithComments() throws Exception { - Document transform = - parseXml(TESTDATA_BASE + "canonicalizationWithComments.xml"); - Transform tr = - transformParser.parseTransform(transform.getDocumentElement()); - Transformation t = factory.createTransformation(tr); - - assertTrue(t instanceof Canonicalization); - assertEquals( - "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments", - t.getAlgorithmURI()); - } - - public void testCreateBase64Decode() throws Exception { - Document transform = parseXml(TESTDATA_BASE + "base64.xml"); - Transform tr = - transformParser.parseTransform(transform.getDocumentElement()); - Transformation t = factory.createTransformation(tr); - assertTrue(t instanceof Base64Transformation); - } - - public void testCreateEnvelopedSignature() throws Exception { - Document transform = parseXml(TESTDATA_BASE + "enveloped.xml"); - Transform tr = - transformParser.parseTransform(transform.getDocumentElement()); - Transformation t = factory.createTransformation(tr); - assertTrue(t instanceof EnvelopedSignatureTransformation); - } - - public void testXPathTransformation() throws Exception { - Document transform = parseXml(TESTDATA_BASE + "xpath.xml"); - Transform tr = - transformParser.parseTransform(transform.getDocumentElement()); - Transformation t = factory.createTransformation(tr); - Map nsDecls; - - assertTrue(t instanceof XPathTransformation); - nsDecls = ((XPathTransformation) t).getNamespaceDeclarations(); - assertEquals(1, nsDecls.size()); - assertEquals(Constants.DSIG_NS_URI, nsDecls.get("dsig")); - } - - public void testCreateXPath2Transformation() throws Exception { - Document transform = parseXml(TESTDATA_BASE + "xpath2.xml"); - Transform tr = - transformParser.parseTransform(transform.getDocumentElement()); - Transformation t = factory.createTransformation(tr); - assertTrue(t instanceof XPath2Transformation); - } - - public void testCreateXSLTTransformation() throws Exception { - Document transform = parseXml(TESTDATA_BASE + "xslt.xml"); - Transform tr = - transformParser.parseTransform(transform.getDocumentElement()); - XSLTTransformation t = - (XSLTTransformation) factory.createTransformation(tr); - assertNotNull(t.getStylesheetElement()); - } - - public void testCreateWithIllegalAlgorithm() throws Exception { - try { - Document transform = parseXml(TESTDATA_BASE + "illegalAlgorithm.xml"); - Transform tr = - transformParser.parseTransform(transform.getDocumentElement()); - factory.createTransformation(tr); - fail(); - } catch (MOAApplicationException e) { - } - } - - public void testEqualsXslt() throws Exception { - Document xslt = parseXml(TESTDATA_BASE + "xslt.xml"); - Transform tr = transformParser.parseTransform(xslt.getDocumentElement()); - Transformation trXslt = factory.createTransformation(tr); - - Document xsltEqu = parseXml(TESTDATA_BASE + "xsltEqual.xml"); - tr = transformParser.parseTransform(xsltEqu.getDocumentElement()); - Transformation trXsltEqu = factory.createTransformation(tr); - - Document xsltDiff = parseXml(TESTDATA_BASE + "xsltDifferent.xml"); - tr = transformParser.parseTransform(xsltDiff.getDocumentElement()); - Transformation trXsltDiff = factory.createTransformation(tr); - - Document canonicalization = - parseXml(TESTDATA_BASE + "canonicalization.xml"); - - assertTrue(trXslt.equals(trXsltEqu)); - assertFalse(trXslt.equals(trXsltDiff)); - assertFalse(trXsltEqu.equals(trXsltDiff)); - assertEquals(trXslt.hashCode(), trXsltEqu.hashCode()); - assertFalse(trXslt.hashCode() == trXsltDiff.hashCode()); - assertFalse(trXsltEqu.hashCode() == trXsltDiff.hashCode()); - assertFalse(trXslt.equals(canonicalization)); - } - - public void testEqualsXPath() throws Exception { - Document xpath = parseXml(TESTDATA_BASE + "xpath.xml"); - Transform tr = transformParser.parseTransform(xpath.getDocumentElement()); - Transformation trXpath = factory.createTransformation(tr); - Transformation trXpathEqu = factory.createTransformation(tr); - - Document xpathDiff = parseXml(TESTDATA_BASE + "xpathDifferent.xml"); - tr = transformParser.parseTransform(xpathDiff.getDocumentElement()); - Transformation trXpathDiff = factory.createTransformation(tr); - - assertTrue(trXpath.equals(trXpathEqu)); - assertEquals(trXpath.hashCode(), trXpathEqu.hashCode()); - assertFalse(trXpath.equals(trXpathDiff)); - assertFalse(trXpath.hashCode() == trXpathDiff.hashCode()); - } - - public void testEqualsXPath2() throws Exception { - Document xpath2 = parseXml(TESTDATA_BASE + "xpath2.xml"); - Transform tr = transformParser.parseTransform(xpath2.getDocumentElement()); - Transformation trXpath2 = factory.createTransformation(tr); - Transformation trXpath2Equ = factory.createTransformation(tr); - - Document xpath2Diff = parseXml(TESTDATA_BASE + "xpath2Different.xml"); - tr = transformParser.parseTransform(xpath2Diff.getDocumentElement()); - Transformation trXpath2Diff = factory.createTransformation(tr); - - assertTrue(trXpath2.equals(trXpath2Equ)); - assertEquals(trXpath2.hashCode(), trXpath2Equ.hashCode()); - assertFalse(trXpath2.equals(trXpath2Diff)); - assertFalse(trXpath2.hashCode() == trXpath2Diff.hashCode()); - } - - public void testCreateTransformationList() throws Exception { - Document transforms = parseXml(TESTDATA_BASE + "transforms.xml"); - List trs = transformParser.parseTransforms(transforms.getDocumentElement()); - List transformationList = factory.createTransformationList(trs); - - assertEquals(3, transformationList.size()); - } - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvokerTest.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvokerTest.java deleted file mode 100644 index 28cd3805a..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvokerTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package test.at.gv.egovernment.moa.spss.server.invoke; - -import java.util.Collections; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import test.at.gv.egovernment.moa.spss.SPSSTestCase; - -import at.gv.egovernment.moa.util.DOMUtils; - -import at.gv.egovernment.moa.spss.api.xmlbind.CreateXMLSignatureRequestParser; -import at.gv.egovernment.moa.spss.api.xmlbind.CreateXMLSignatureResponseBuilder; -import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureRequest; -import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureResponse; -import at.gv.egovernment.moa.spss.server.invoke.XMLSignatureCreationInvoker; - -/** - * Mainly a smoke test for debugging the XMLSignatureCreationInvoker. - * - * @author Patrick Peck - * @version $Id$ - */ -public class XMLSignatureCreationInvokerTest extends SPSSTestCase { - private static final String TESTDATA_BASE = - TESTDATA_ROOT + "xml/CreateXMLSignature/"; - - public XMLSignatureCreationInvokerTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - setUpTransactionContext(); - setUpLoggingContext(); - setUpIaikConfiguration(); - setUpSSL(); - } - - public void testCreateXMLSignature() throws Exception { - try { - XMLSignatureCreationInvoker invoker = - XMLSignatureCreationInvoker.getInstance(); - CreateXMLSignatureRequestParser requestParser = - new CreateXMLSignatureRequestParser(); - Document doc = - SPSSTestCase.parseXmlValidating( - TESTDATA_BASE + "TestGeneratorCX2.004.Req.xml"); - CreateXMLSignatureRequest request = - requestParser.parse(doc.getDocumentElement()); - CreateXMLSignatureResponse response = - invoker.createXMLSignature(request, Collections.EMPTY_SET); - CreateXMLSignatureResponseBuilder responseBuilder = - new CreateXMLSignatureResponseBuilder(); - Element result = responseBuilder.build(response).getDocumentElement(); - - System.out.println(DOMUtils.serializeNode(result)); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - } - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvokerTest.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvokerTest.java deleted file mode 100644 index 56e3d541b..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvokerTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package test.at.gv.egovernment.moa.spss.server.invoke; - -import org.w3c.dom.Document; - -import test.at.gv.egovernment.moa.spss.SPSSTestCase; - -import at.gv.egovernment.moa.util.DOMUtils; - -import at.gv.egovernment.moa.spss.api.xmlbind.VerifyXMLSignatureRequestParser; -import at.gv.egovernment.moa.spss.api.xmlbind.VerifyXMLSignatureResponseBuilder; -import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureRequest; -import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse; -import at.gv.egovernment.moa.spss.server.invoke.XMLSignatureVerificationInvoker; - -/** - * Mainly a smoke test for debugging the XMLSignatureVerificationInvoker. - * - * @author Patrick Peck - * @version $Id$ - */ -public class XMLSignatureVerificationInvokerTest extends SPSSTestCase { - private static final String TESTDATA_BASE = - TESTDATA_ROOT + "xml/VerifyXMLSignature/"; - - public XMLSignatureVerificationInvokerTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - setUpTransactionContext(); - setUpLoggingContext(); - setUpIaikConfiguration(); - } - - public void testVerifyXMLSignature() throws Exception { - try { - XMLSignatureVerificationInvoker invoker = - XMLSignatureVerificationInvoker.getInstance(); - VerifyXMLSignatureRequestParser requestParser = - new VerifyXMLSignatureRequestParser(); - VerifyXMLSignatureResponseBuilder responseBuilder = - new VerifyXMLSignatureResponseBuilder(); - Document doc = - SPSSTestCase.parseXmlValidating( - TESTDATA_BASE + "TestGeneratorVX.201.Req.xml"); - - VerifyXMLSignatureRequest request = - requestParser.parse(doc.getDocumentElement()); - VerifyXMLSignatureResponse response; - - response = invoker.verifyXMLSignature(request); - System.out.println( - DOMUtils.serializeNode(responseBuilder.build(response))); - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - } - - -} diff --git a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/tools/CertToolTest.java b/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/tools/CertToolTest.java deleted file mode 100644 index b46c20086..000000000 --- a/spss/server/serverlib/src/test/java/at/gv/egovernment/moa/spss/server/tools/CertToolTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package test.at.gv.egovernment.moa.spss.server.tools; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -import at.gv.egovernment.moa.spss.server.tools.CertTool; - -import test.at.gv.egovernment.moa.MOATestCase; - -/** - * Tests for the CertTool. - * - * @author Patrick Peck - * @version $Id$ - */ -public class CertToolTest extends MOATestCase { - - private static final String EXPECTED_RESULT = - "SubjectDN (RFC2253):" - + " CN=Patrick Peck,OU=MOA Team,O=BRZ,L=Vienna,ST=Vienna,C=AT\r\n" - + "IssuerDN (RFC2253) :" - + " CN=Patrick Peck,OU=MOA Team,O=BRZ,L=Vienna,ST=Vienna,C=AT\r\n" - + "Serial Number :" - + " 1047548672\r\n"; - private CertTool certTool; - - /** - * Constructor for CertToolTest. - * @param name - */ - public CertToolTest(String name) { - super(name); - } - - protected void setUp() { - certTool = new CertTool(); - } - - public void testPrintCertInfo() { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(bos); - String result; - - certTool.printCertInfo(TESTDATA_ROOT + "security/server.cer", ps); - result = new String(bos.toByteArray()); - System.out.println(result); - assertEquals(EXPECTED_RESULT, result); - } - -} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/AllTests.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/AllTests.java new file mode 100644 index 000000000..c670b5e55 --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/AllTests.java @@ -0,0 +1,40 @@ +package test.at.gv.egovernment.moa.spss; + +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; + +import junit.awtui.TestRunner; +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * Test suite for all unit tests. + * + * @author Patrick Peck + * @version $Id$ + */ +public class AllTests { + + public static Test suite() { + TestSuite suite = new TestSuite(); + + suite.addTestSuite(test.at.gv.egovernment.moa.spss.server.config.AllTests.class); + suite.addTestSuite(ConfigurationDataImplTest.class); + suite.addTestSuite(IaikConfiguratorTest.class); + suite.addTest( + test.at.gv.egovernment.moa.spss.server.invoke.AllTests.suite()); + suite.addTest(test.at.gv.egovernment.moa.spss.api.xmlbind.AllTests.suite()); + suite.addTestSuite(CertToolTest.class); + + return suite; + } + + public static void main(String[] args) { + try { + TestRunner.run(AllTests.class); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/SPSSTestCase.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/SPSSTestCase.java new file mode 100644 index 000000000..a585e30a0 --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/SPSSTestCase.java @@ -0,0 +1,82 @@ +package test.at.gv.egovernment.moa.spss; + +import java.security.Security; + +import test.at.gv.egovernment.moa.MOATestCase; + +import at.gv.egovernment.moa.logging.Logger; +import at.gv.egovernment.moa.logging.LoggingContext; +import at.gv.egovernment.moa.logging.LoggingContextManager; +import at.gv.egovernment.moa.util.MessageProvider; + +import at.gv.egovernment.moa.spss.server.config.ConfigurationProvider; +import at.gv.egovernment.moa.spss.server.iaik.config.IaikConfigurator; +import at.gv.egovernment.moa.spss.server.transaction.TransactionContext; +import at.gv.egovernment.moa.spss.server.transaction.TransactionContextManager; + +/** + * Base class for MOA test cases. + * + * Provides some utility functions. + * + * @author Patrick Peck + * @version $Id$ + */ +public class SPSSTestCase extends MOATestCase { + + protected static final String TESTDATA_ROOT = "data/test/"; + + /** + * Constructor for MOATestCase. + * @param arg0 + */ + public SPSSTestCase(String name) { + super(name); + } + + /** + * Set up a transaction context with a test configuration. + */ + protected void setUpTransactionContext() throws Exception { + System.setProperty( + ConfigurationProvider.CONFIG_PROPERTY_NAME, + "data/test/conf/moa-spss/MOA-SPSSConfiguration.xml"); + ConfigurationProvider config = ConfigurationProvider.getInstance(); + TransactionContext context = new TransactionContext("test", null, config); + TransactionContextManager.getInstance().setTransactionContext(context); + } + + protected void setUpLoggingContext() throws Exception { + LoggingContext context = new LoggingContext("test"); + LoggingContextManager.getInstance().setLoggingContext(context); + } + + /** + * Configure the IAIK modules with the current configuration. + * + * A TransactionContext must have been set up before. + */ + protected void setUpIaikConfiguration() throws Exception { + TransactionContext context = + TransactionContextManager.getInstance().getTransactionContext(); + ClassLoader cl = getClass().getClassLoader(); + MessageProvider msg = MessageProvider.getInstance(); + + try { + cl.loadClass("javax.security.cert.Certificate"); // from jcert.jar + } catch (ClassNotFoundException e) { + Logger.warn(msg.getMessage("init.03", null), e); + } + + new IaikConfigurator().configure(context.getConfiguration()); + } + + protected void setUpSSL() throws Exception { + //System.setProperty("javax.net.debug", "all"); + Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); + System.setProperty( + "java.protocol.handler.pkgs", + "com.sun.net.ssl.internal.www.protocol"); + } + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/AllTests.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/AllTests.java new file mode 100644 index 000000000..28f79729e --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/AllTests.java @@ -0,0 +1,24 @@ +package test.at.gv.egovernment.moa.spss.api.xmlbind; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * Runs all tests in this package. + * + * @author Patrick Peck + * @version $Id$ + */ +public class AllTests { + public static Test suite() { + TestSuite suite = new TestSuite(); + + suite.addTestSuite(CreateXMLSignatureRequestParserTest.class); + suite.addTestSuite(TransformParserTest.class); + suite.addTestSuite(VerifyCMSSignatureRequestParserTest.class); + suite.addTestSuite(VerifyXMLSignatureRequestParserTest.class); + + return suite; + } + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParserTest.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParserTest.java new file mode 100644 index 000000000..7ce705b01 --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParserTest.java @@ -0,0 +1,71 @@ +package test.at.gv.egovernment.moa.spss.api.xmlbind; + +import org.w3c.dom.Element; + +import test.at.gv.egovernment.moa.spss.SPSSTestCase; + +import at.gv.egovernment.moa.spss.api.xmlbind.CreateXMLSignatureRequestParser; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureEnvironmentProfileExplicit; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfoProfileExplicit; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureRequest; +import at.gv.egovernment.moa.spss.api.xmlsign.DataObjectInfo; +import at.gv.egovernment.moa.spss.api.xmlsign.SingleSignatureInfo; + +/** + * Test the CreateXMLSignatureRequestParser. + * + * @author Patrick Peck + * @version $Id$ + */ +public class CreateXMLSignatureRequestParserTest extends SPSSTestCase { + private static final String TESTDATA_BASE = + TESTDATA_ROOT + "xml/CreateXMLSignature/"; + + private CreateXMLSignatureRequestParser requestParser; + + public CreateXMLSignatureRequestParserTest(String name) { + super(name); + } + + protected void setUp() throws Exception { + requestParser = new CreateXMLSignatureRequestParser(); + } + + public void testParse() throws Exception { + Element requestElem = + parseXml(TESTDATA_BASE + "TestGeneratorCX2.001.Req.xml") + .getDocumentElement(); + CreateXMLSignatureRequest request = requestParser.parse(requestElem); + SingleSignatureInfo sigInfo; + DataObjectInfo dataObjInfo; + CreateTransformsInfoProfileExplicit transProfile; + CreateSignatureEnvironmentProfileExplicit envProfile; + + assertNotNull(request); + assertEquals("PKCS12RSAKey1", request.getKeyIdentifier()); + assertEquals(1, request.getSingleSignatureInfos().size()); + + sigInfo = (SingleSignatureInfo) request.getSingleSignatureInfos().get(0); + assertEquals(1, sigInfo.getDataObjectInfos().size()); + assertFalse(sigInfo.isSecurityLayerConform()); + + dataObjInfo = (DataObjectInfo) sigInfo.getDataObjectInfos().get(0); + assertNotNull(dataObjInfo.getDataObject()); + + transProfile = + (CreateTransformsInfoProfileExplicit) dataObjInfo + .getCreateTransformsInfoProfile(); + assertNotNull( + transProfile.getCreateTransformsInfo().getFinalDataMetaInfo()); + + envProfile = + (CreateSignatureEnvironmentProfileExplicit) sigInfo + .getCreateSignatureInfo() + .getCreateSignatureEnvironmentProfile(); + assertEquals( + "//data:Document", + envProfile.getCreateSignatureLocation().getXPathExpression()); + assertEquals(0, envProfile.getCreateSignatureLocation().getIndex()); + } + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/TransformParserTest.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/TransformParserTest.java new file mode 100644 index 000000000..f580f86bc --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/TransformParserTest.java @@ -0,0 +1,113 @@ +package test.at.gv.egovernment.moa.spss.api.xmlbind; + +import java.util.List; + +import org.w3c.dom.Element; + +import test.at.gv.egovernment.moa.spss.SPSSTestCase; + +import at.gv.egovernment.moa.spss.api.common.CanonicalizationTransform; +import at.gv.egovernment.moa.spss.api.common.EnvelopedSignatureTransform; +import at.gv.egovernment.moa.spss.api.common.ExclusiveCanonicalizationTransform; +import at.gv.egovernment.moa.spss.api.common.XPathFilter2Transform; +import at.gv.egovernment.moa.spss.api.common.XPathTransform; +import at.gv.egovernment.moa.spss.api.common.XSLTTransform; +import at.gv.egovernment.moa.spss.api.xmlbind.TransformParser; + +/** + * Test the TransformParser. + * + * @author Patrick Peck + * @version $Id$ + */ +public class TransformParserTest extends SPSSTestCase { + private static String TESTDATA_BASE = TESTDATA_ROOT + "xml/dsigTransform/"; + + private TransformParser transformParser; + + public TransformParserTest(String name) { + super(name); + } + + protected void setUp() { + transformParser = new TransformParser(); + } + + public void testParseTransforms() throws Exception { + Element transformsElem = + parseXml(TESTDATA_BASE + "transforms.xml").getDocumentElement(); + List transforms = transformParser.parseTransforms(transformsElem); + + assertNotNull(transforms); + assertEquals(3, transforms.size()); + + } + + public void testParseCanonicalizationTransform() throws Exception { + Element transformElem = + parseXml(TESTDATA_BASE + "canonicalization.xml").getDocumentElement(); + CanonicalizationTransform transform = + (CanonicalizationTransform) transformParser.parseTransform(transformElem); + + assertNotNull(transform); + assertEquals( + CanonicalizationTransform.CANONICAL_XML, + transform.getAlgorithmURI()); + } + + public void testParseExclCanonicalizationTransform() throws Exception { + Element transformElem = + parseXml(TESTDATA_BASE + "exclusiveCanonicalization.xml") + .getDocumentElement(); + ExclusiveCanonicalizationTransform transform = + (ExclusiveCanonicalizationTransform) transformParser.parseTransform( + transformElem); + + assertNotNull(transform); + assertEquals( + ExclusiveCanonicalizationTransform.EXCLUSIVE_CANONICAL_XML, + transform.getAlgorithmURI()); + assertEquals(3, transform.getInclusiveNamespacePrefixes().size()); + } + + public void testParseEnvelopedTransform() throws Exception { + Element transformElem = + parseXml(TESTDATA_BASE + "enveloped.xml").getDocumentElement(); + EnvelopedSignatureTransform transform = + (EnvelopedSignatureTransform) transformParser.parseTransform( + transformElem); + + assertNotNull(transform); + } + + public void testParseXPathTransform() throws Exception { + Element transformElem = + parseXml(TESTDATA_BASE + "xpath.xml").getDocumentElement(); + XPathTransform transform = + (XPathTransform) transformParser.parseTransform(transformElem); + + assertNotNull(transform); + assertEquals("//ToBeSigned/Data", transform.getXPathExpression()); + assertEquals(1, transform.getNamespaceDeclarations().size()); + } + + public void testParseXPathFilter2Transform() throws Exception { + Element transformElem = + parseXml(TESTDATA_BASE + "xpath2.xml").getDocumentElement(); + XPathFilter2Transform transform = + (XPathFilter2Transform) transformParser.parseTransform(transformElem); + + assertNotNull(transform); + assertEquals(3, transform.getFilters().size()); + } + + public void testParseXSLTTransform() throws Exception { + Element transformElem = + parseXml(TESTDATA_BASE + "xslt.xml").getDocumentElement(); + XSLTTransform transform = + (XSLTTransform) transformParser.parseTransform(transformElem); + + assertNotNull(transform); + } + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParserTest.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParserTest.java new file mode 100644 index 000000000..4be7667eb --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParserTest.java @@ -0,0 +1,61 @@ +package test.at.gv.egovernment.moa.spss.api.xmlbind; + +import org.w3c.dom.Element; + +import at.gv.egovernment.moa.util.DateTimeUtils; + +import test.at.gv.egovernment.moa.spss.SPSSTestCase; + +import at.gv.egovernment.moa.spss.api.cmsverify.CMSContentExcplicit; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureRequest; +import at.gv.egovernment.moa.spss.api.common.MetaInfo; +import at.gv.egovernment.moa.spss.api.xmlbind.VerifyCMSSignatureRequestParser; + +/** + * Test the VerifyCMSSignatureRequestParserTest. + * + * @author Patrick Peck + * @version $Id$ + */ +public class VerifyCMSSignatureRequestParserTest extends SPSSTestCase { + private static String TESTDATA_BASE = + TESTDATA_ROOT + "xml/VerifyCMSSignature/"; + + private VerifyCMSSignatureRequestParser requestParser; + + public VerifyCMSSignatureRequestParserTest(String name) { + super(name); + } + + protected void setUp() throws Exception { + requestParser = new VerifyCMSSignatureRequestParser(); + } + + public void testParse() throws Exception { + Element requestElem = + parseXml(TESTDATA_BASE + "TestGeneratorVC0.001.Req.xml") + .getDocumentElement(); + VerifyCMSSignatureRequest request = requestParser.parse(requestElem); + MetaInfo metaInfo; + CMSContentExcplicit content; + + assertNotNull(request); + assertEquals(1, request.getSignatories()[0]); + assertEquals( + DateTimeUtils.parseDateTime("2003-04-04T09:30:47-05:00"), + request.getDateTime()); + assertNotNull(request.getCMSSignature()); + assertNotNull(request.getDataObject()); + assertEquals("TrustProfile1", request.getTrustProfileId()); + + metaInfo = request.getDataObject().getMetaInfo(); + assertNotNull(metaInfo); + assertEquals("text/plain", metaInfo.getMimeType()); + assertEquals("http://10.16.46.109/TestDatenGenerator/resources/testDaten.txt", metaInfo.getDescription()); + + content = (CMSContentExcplicit) request.getDataObject().getContent(); + assertNotNull(content.getBinaryContent()); + + } + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParserTest.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParserTest.java new file mode 100644 index 000000000..3b8e8b00e --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParserTest.java @@ -0,0 +1,81 @@ +package test.at.gv.egovernment.moa.spss.api.xmlbind; + +import org.w3c.dom.Element; + +import test.at.gv.egovernment.moa.spss.SPSSTestCase; + +import at.gv.egovernment.moa.util.DateTimeUtils; + +import at.gv.egovernment.moa.spss.api.xmlbind.VerifyXMLSignatureRequestParser; +import at.gv.egovernment.moa.spss.api.xmlverify.ReferenceInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.SignatureManifestCheckParams; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureInfo; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureLocation; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyTransformsInfoProfileExplicit; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureRequest; + +/** + * Test the VerifyXMLSignatureRequestParserTest. + * + * @author Patrick Peck + * @version $Id$ + */ +public class VerifyXMLSignatureRequestParserTest extends SPSSTestCase { + private static String TESTDATA_BASE = + TESTDATA_ROOT + "xml/VerifyXMLSignature/"; + + private VerifyXMLSignatureRequestParser parser; + + public VerifyXMLSignatureRequestParserTest(String name) { + super(name); + } + + protected void setUp() throws Exception { + parser = new VerifyXMLSignatureRequestParser(); + } + + public void testParse() throws Exception { + Element requestElem = + parseXml(TESTDATA_BASE + "TestGeneratorVX.201.Req.xml") + .getDocumentElement(); + VerifyXMLSignatureRequest request = parser.parse(requestElem); + VerifySignatureInfo verifySignatureInfo; + VerifySignatureLocation verifyLocation; + SignatureManifestCheckParams checkParams; + ReferenceInfo refInfo; + VerifyTransformsInfoProfileExplicit transformsProfile; + + assertNotNull(request); + assertEquals( + DateTimeUtils.parseDateTime("2003-04-01T12:53:57+01:00"), + request.getDateTime()); + assertFalse(request.getReturnHashInputData()); + assertEquals("TrustProfile1", request.getTrustProfileId()); + + verifySignatureInfo = request.getSignatureInfo(); + assertNotNull(verifySignatureInfo); + assertNotNull(verifySignatureInfo.getVerifySignatureEnvironment()); + + verifyLocation = verifySignatureInfo.getVerifySignatureLocation(); + assertNotNull(verifyLocation); + assertEquals("//dsig:Signature", verifyLocation.getXPathExpression()); + assertEquals(3, verifyLocation.getNamespaceDeclarations().size()); + + checkParams = request.getSignatureManifestCheckParams(); + assertNotNull(checkParams); + assertEquals(true, checkParams.getReturnReferenceInputData()); + assertEquals(1, checkParams.getReferenceInfos().size()); + + refInfo = (ReferenceInfo) checkParams.getReferenceInfos().get(0); + assertEquals(1, refInfo.getVerifyTransformsInfoProfiles().size()); + + transformsProfile = + (VerifyTransformsInfoProfileExplicit) refInfo + .getVerifyTransformsInfoProfiles() + .get(0); + assertEquals(1, transformsProfile.getTransforms().size()); + assertEquals(1, transformsProfile.getTransformParameters().size()); + + } + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/AllTests.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/AllTests.java new file mode 100644 index 000000000..131f38c19 --- /dev/null +++ b/spss/server/serverlib/src/test/java/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/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest1.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest1.java new file mode 100644 index 000000000..474a387ad --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest1.java @@ -0,0 +1,377 @@ +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.getMessage()); + } + } + + /** + * 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()); + + Iterator dpIt = dps.iterator(); + while (dpIt.hasNext()) + { + CRLDistributionPoint currentDP = (CRLDistributionPoint)dpIt.next(); + if ("http://crl.myca.org".equals(currentDP.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, currentDP.getReasonCodes()); + } + else if ("http://crl.myotherca.org".equals(currentDP.getUri())) + { + int reasonCodes = + iaik.asn1.structures.DistributionPoint.aACompromise | + iaik.asn1.structures.DistributionPoint.affiliationChanged; + assertEquals(reasonCodes, currentDP.getReasonCodes()); + } + else fail("Invalid CRL DP URI found: " + currentDP.getUri()); + } + + 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/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest2.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest2.java new file mode 100644 index 000000000..adf02809b --- /dev/null +++ b/spss/server/serverlib/src/test/java/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.getMessage()); + } + } + + + /** + * 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/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest3.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ConfigurationProviderTest3.java new file mode 100644 index 000000000..7da2165cb --- /dev/null +++ b/spss/server/serverlib/src/test/java/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.getMessage()); + } + } + + /** + * 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); + } +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/iaik/config/ConfigurationDataImplTest.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/iaik/config/ConfigurationDataImplTest.java new file mode 100644 index 000000000..be1090e4a --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/iaik/config/ConfigurationDataImplTest.java @@ -0,0 +1,149 @@ +package test.at.gv.egovernment.moa.spss.server.iaik.config; + +import java.io.FileInputStream; +import java.security.KeyStore; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.util.Collection; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import test.at.gv.egovernment.moa.spss.SPSSTestCase; + +import iaik.asn1.structures.DistributionPoint; +import iaik.pki.PKIConfiguration; +import iaik.pki.pathvalidation.ChainingModes; +import iaik.pki.pathvalidation.ValidationConfiguration; +import iaik.pki.revocation.CRLDistributionPoint; +import iaik.pki.revocation.RevocationConfiguration; +import iaik.pki.store.certstore.CertStoreConfiguration; +import iaik.pki.store.certstore.CertStoreTypes; +import iaik.pki.store.revocation.archive.ArchiveConfiguration; +import iaik.pki.store.revocation.archive.db.DataBaseArchiveParameter; +import iaik.server.ConfigurationData; +import iaik.server.modules.keys.HardwareKeyModuleConfiguration; +import iaik.server.modules.keys.SoftwareKeyModuleConfiguration; + +import at.gv.egovernment.moa.spss.server.iaik.config.ConfigurationDataImpl; +import at.gv.egovernment.moa.spss.server.transaction.TransactionContext; +import at.gv.egovernment.moa.spss.server.transaction.TransactionContextManager; + +/** + * Tests the ConfigurationDataImpl. + * + * @author Patrick Peck + * @version $Id$ + */ +public class ConfigurationDataImplTest extends SPSSTestCase { + + private ConfigurationData config; + private X509Certificate iaikCert; + + public ConfigurationDataImplTest(String name) { + super(name); + } + + protected void setUp() throws Exception { + TransactionContext context; + + setUpTransactionContext(); + context = TransactionContextManager.getInstance().getTransactionContext(); + + config = new ConfigurationDataImpl(context.getConfiguration()); + + KeyStore ks = KeyStore.getInstance("JKS", "SUN"); + ks.load( + new FileInputStream(TESTDATA_ROOT + "security/server.keystore"), + "changeit".toCharArray()); + + CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); + Collection certs = + certFactory.generateCertificates( + new FileInputStream( + TESTDATA_ROOT + + "conf/moa-spss/trustprofiles/TrustProfile1/IAIKRoot.cer")); + iaikCert = (X509Certificate) certs.toArray()[0]; + + } + + public void testGetPKIConfiguration() { + PKIConfiguration pkiConfig = config.getPKIConfiguration(); + ArchiveConfiguration archiveConfig = pkiConfig.getArchiveConfiguration(); + CertStoreConfiguration certStoreConfig = + pkiConfig.getCertStoreConfiguration(); + RevocationConfiguration revocationConfig = + pkiConfig.getRevocationConfiguration(); + ValidationConfiguration validationConfig = + pkiConfig.getValidationConfiguration(); + DataBaseArchiveParameter archiveParam; + Set distributionPoints; + Iterator iter; + boolean found; + + // test archive parameters + archiveParam = + (DataBaseArchiveParameter) archiveConfig.getArchiveParameters(); + assertEquals( + archiveParam.getJDBCUrl(), + "jdbc:postgresql://10.16.46.108/moa?user=moa&password=moatest"); + + // test cert store configuration + assertEquals(1, certStoreConfig.getParameters().length); + assertEquals( + CertStoreTypes.DIRECTORY, + certStoreConfig.getParameters()[0].getType()); + + // test revocation configuration + distributionPoints = + revocationConfig.getAlternativeDistributionPoints(iaikCert, null, new Date()); + assertEquals(3, distributionPoints.size()); + found = false; + for (iter = distributionPoints.iterator(); iter.hasNext();) { + CRLDistributionPoint dp = (CRLDistributionPoint) iter.next(); + if (dp.getUri().equals("http://www.iaik.at/testCA/iaik_test_sig.crl")) { + found = + dp.getReasonCodes() + == (DistributionPoint.keyCompromise + | DistributionPoint.affiliationChanged); + } + } + assertTrue(found); + + // test validation configuration + assertEquals( + ChainingModes.PKIX_MODE, + validationConfig.getChainingMode(iaikCert)); + } + + /* + public void testGetCryptoModuleConfigurations() { + List cryptoConfigs = config.getCryptoModuleConfigurations(); + HardwareCryptoModuleConfiguration moduleConfig; + + assertEquals(2, cryptoConfigs.size()); + moduleConfig = (HardwareCryptoModuleConfiguration) cryptoConfigs.get(0); + assertEquals("Module1", moduleConfig.getModuleName()); + assertEquals("Slot1", moduleConfig.getSlotID()); + assertEquals("PIN1", new String(moduleConfig.getUserPIN())); + } + */ + + public void testGetKeyModuleConfigurations() { + List keyConfigs = config.getKeyModuleConfigurations(); + HardwareKeyModuleConfiguration hwKey; + SoftwareKeyModuleConfiguration swKey; + + assertEquals(7, keyConfigs.size()); + hwKey = (HardwareKeyModuleConfiguration) keyConfigs.get(0); + assertEquals("cryptoki.dll", hwKey.getModuleName()); + assertEquals("0", hwKey.getSlotID()); + assertEquals("0000", new String(hwKey.getUserPIN())); + swKey = (SoftwareKeyModuleConfiguration) keyConfigs.get(1); + assertEquals( + "buergerkarte", + new String(swKey.getKeyStoreAuthenticationData())); + } + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/iaik/config/IaikConfiguratorTest.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/iaik/config/IaikConfiguratorTest.java new file mode 100644 index 000000000..3b403dc19 --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/iaik/config/IaikConfiguratorTest.java @@ -0,0 +1,36 @@ +package test.at.gv.egovernment.moa.spss.server.iaik.config; + +import test.at.gv.egovernment.moa.spss.SPSSTestCase; + +import at.gv.egovernment.moa.spss.server.iaik.config.IaikConfigurator; +import at.gv.egovernment.moa.spss.server.transaction.TransactionContext; +import at.gv.egovernment.moa.spss.server.transaction.TransactionContextManager; + +/** + * Tests the IaikConfigurator. + * + * @author Patrick Peck + * @version $Id$ + */ +public class IaikConfiguratorTest extends SPSSTestCase { + + public IaikConfiguratorTest(String name) { + super(name); + } + + /** + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUpTransactionContext(); + } + + public void testConfigure() throws Exception { + IaikConfigurator configurator = new IaikConfigurator(); + TransactionContext context = + TransactionContextManager.getInstance().getTransactionContext(); + + configurator.configure(context.getConfiguration()); + } + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/AllTests.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/AllTests.java new file mode 100644 index 000000000..65fa2bf72 --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/AllTests.java @@ -0,0 +1,25 @@ +package test.at.gv.egovernment.moa.spss.server.invoke; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * Runs all tests in this package. + * + * @author Patrick Peck + * @version $Id$ + */ +public class AllTests { + public static Test suite() { + TestSuite suite = new TestSuite(); + + suite.addTestSuite(DataObjectFactoryTest.class); + suite.addTestSuite(TransformationFactoryTest.class); + suite.addTestSuite(XMLSignatureCreationInvokerTest.class); + suite.addTestSuite(CMSSignatureVerificationInvokerTest.class); + suite.addTestSuite(XMLSignatureVerificationInvokerTest.class); + + return suite; + } + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/CMSSignatureVerificationInvokerTest.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/CMSSignatureVerificationInvokerTest.java new file mode 100644 index 000000000..3024730f4 --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/CMSSignatureVerificationInvokerTest.java @@ -0,0 +1,63 @@ +package test.at.gv.egovernment.moa.spss.server.invoke; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import test.at.gv.egovernment.moa.spss.SPSSTestCase; + +import at.gv.egovernment.moa.util.DOMUtils; + +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureRequest; +import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponse; +import at.gv.egovernment.moa.spss.api.xmlbind.VerifyCMSSignatureRequestParser; +import at.gv.egovernment.moa.spss.api.xmlbind.VerifyCMSSignatureResponseBuilder; +import at.gv.egovernment.moa.spss.server.invoke.CMSSignatureVerificationInvoker; + +/** + * Mainly a smoke test for debugging the CMSSignatureVerificationInvoker. + * + * @author Patrick Peck + * @version $Id$ + */ +public class CMSSignatureVerificationInvokerTest extends SPSSTestCase { + private static final String TESTDATA_BASE = + TESTDATA_ROOT + "xml/VerifyCMSSignature/"; + + /** + * Constructor for CMSSignatureVerificationInvokerTest. + * @param name + */ + public CMSSignatureVerificationInvokerTest(String name) { + super(name); + } + + protected void setUp() throws Exception { + setUpTransactionContext(); + setUpLoggingContext(); + setUpIaikConfiguration(); + } + + public void testVerifyCMSSignature() throws Exception { + try { + CMSSignatureVerificationInvoker invoker = + CMSSignatureVerificationInvoker.getInstance(); + VerifyCMSSignatureRequestParser requestParser = + new VerifyCMSSignatureRequestParser(); + Document doc = + SPSSTestCase.parseXmlValidating( + TESTDATA_BASE + "TestGeneratorVC0.001.Req.xml"); + VerifyCMSSignatureRequest request = + requestParser.parse(doc.getDocumentElement()); + VerifyCMSSignatureResponse response = invoker.verifyCMSSignature(request); + VerifyCMSSignatureResponseBuilder responseBuilder = + new VerifyCMSSignatureResponseBuilder(); + Element result = responseBuilder.build(response).getDocumentElement(); + + System.out.println(DOMUtils.serializeNode(result)); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactoryTest.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactoryTest.java new file mode 100644 index 000000000..7de2add33 --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactoryTest.java @@ -0,0 +1,180 @@ +package test.at.gv.egovernment.moa.spss.server.invoke; + +import java.io.InputStream; +import java.security.Security; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import test.at.gv.egovernment.moa.spss.SPSSTestCase; + +import iaik.server.modules.xml.BinaryDataObject; +import iaik.server.modules.xml.DataObject; +import iaik.server.modules.xml.XMLDataObject; + +import at.gv.egovernment.moa.util.Base64Utils; + +import at.gv.egovernment.moa.spss.MOAException; +import at.gv.egovernment.moa.spss.api.SPSSFactory; +import at.gv.egovernment.moa.spss.api.common.Content; +import at.gv.egovernment.moa.spss.server.iaik.xml.ByteArrayDataObjectImpl; +import at.gv.egovernment.moa.spss.server.iaik.xml.ByteStreamDataObjectImpl; +import at.gv.egovernment.moa.spss.server.iaik.xml.XMLDataObjectImpl; +import at.gv.egovernment.moa.spss.server.iaik.xml.XMLNodeListDataObjectImpl; +import at.gv.egovernment.moa.spss.server.invoke.DataObjectFactory; + +/** + * Test cases for the DataObjectFactory class. + * + * @author Patrick Peck + * @version $Id$ + */ +public class DataObjectFactoryTest extends SPSSTestCase { + + private static final String HTTP_BINARY_CONTENT_URL = "http://www.google.com"; + private static final String HTTP_XML_CONTENT_URL = + "http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"; + private static final String HTTPS_BINARY_CONTENT_URL = + "https://businessnet.ba-ca.com"; + private static final String HTTPS_UNTRUSTED_URL = + "https://heribert.anecon.com"; + private static final String HTTP_UNKNOWN_HOST_URL = "http://uurjmjmruuw.com"; + private static final String MALFORMED_URL = "//hsld///ddd"; + private static final String FILE_BINARY_CONTENT_URL = "file:/C:/boot.ini"; + private static final String XML_CONTENT = + "" + + " " + + " " + + ""; + private static final String BASE64_CONTENT = "U3Zlbg=="; + + private SPSSFactory spssFactory = SPSSFactory.getInstance(); + private DataObjectFactory factory; + + /** + * Constructor for DataObjectFactoryTest. + * @param name + */ + public DataObjectFactoryTest(String name) { + super(name); + } + + protected void setUp() throws Exception { + factory = DataObjectFactory.getInstance(); + + // set up SSL + Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); + System.setProperty( + "java.protocol.handler.pkgs", + "com.sun.net.ssl.internal.www.protocol"); + /* + System.setProperty( + "javax.net.ssl.keyStore", + "data/test/security/client.keystore"); + System.setProperty("javax.net.ssl.keyStorePassword", "changeit"); + System.setProperty( + "javax.net.ssl.trustStore", + "data/test/security/client.keystore"); + System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); + */ + } + + public void testCreateFromURIWithBinaryHttp() throws Exception { + DataObject dataObject = + factory.createFromURI(HTTP_BINARY_CONTENT_URL, false); + + assertNotNull(dataObject); + assertTrue(dataObject instanceof ByteStreamDataObjectImpl); + assertNotNull(((BinaryDataObject) dataObject).getInputStream()); + } + + public void testCreateFromURIWithXmlHttp() throws Exception { + DataObject dataObject = factory.createFromURI(HTTP_XML_CONTENT_URL, false); + Element element; + + assertNotNull(dataObject); + assertTrue(dataObject instanceof XMLDataObjectImpl); + element = ((XMLDataObject) dataObject).getElement(); + assertNotNull(element); + assertEquals("schema", element.getTagName()); + } + + public void testCreateFromURIWithMalformedURI() throws Exception { + try { + factory.createFromURI(MALFORMED_URL, false); + fail(); + } catch (MOAException e) { + } + } + + public void testCreateFromURIWithNonExistingHttpURL() throws Exception { + try { + factory.createFromURI(HTTP_UNKNOWN_HOST_URL, false); + fail(); + } catch (MOAException e) { + } + } + + public void testCreateFromURIWithHttps() throws Exception { + DataObject dataObject = + factory.createFromURI(HTTPS_BINARY_CONTENT_URL, false); + assertNotNull(dataObject); + assertTrue(dataObject instanceof BinaryDataObject); + } + + public void testCreateFromURIWithUntrustedHttps() throws Exception { + try { + factory.createFromURI(HTTPS_UNTRUSTED_URL, false); + fail(); + } catch (MOAException e) { + + } + } + + public void testCreateFromURIWithFile() throws Exception { + try { + factory.createFromURI(FILE_BINARY_CONTENT_URL, false); + fail(); + } catch (MOAException e) { + } + } + + public void testCreateFromContentOptionalRefTypeWithXmlContent() + throws Exception { + Document doc = parseXmlString(XML_CONTENT); + Content content = + spssFactory.createContent( + doc.getDocumentElement().getChildNodes(), + "http://data"); + DataObject dataObject = + factory.createFromContentOptionalRefType( + content, + null, + null, + true, + false, + true, + false); + + assertTrue(dataObject instanceof XMLNodeListDataObjectImpl); + } + + public void testCreateFromContentOptionalRefTypeWithBase64Content() + throws Exception { + InputStream is = Base64Utils.decodeToStream(BASE64_CONTENT, true); + Content content = spssFactory.createContent(is, "http://data"); + DataObject dataObject = + factory.createFromContentOptionalRefType( + content, + null, + null, + false, + false, + true, + false); + + assertNotNull(dataObject); + assertTrue(dataObject instanceof ByteArrayDataObjectImpl); + } + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/TransformationFactoryTest.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/TransformationFactoryTest.java new file mode 100644 index 000000000..13a80cbf1 --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/TransformationFactoryTest.java @@ -0,0 +1,201 @@ +package test.at.gv.egovernment.moa.spss.server.invoke; + +import java.util.List; +import java.util.Map; + +import org.w3c.dom.Document; + +import test.at.gv.egovernment.moa.spss.SPSSTestCase; + +import iaik.ixsil.init.IXSILInit; +import iaik.ixsil.util.URI; +import iaik.server.modules.xml.Base64Transformation; +import iaik.server.modules.xml.Canonicalization; +import iaik.server.modules.xml.EnvelopedSignatureTransformation; +import iaik.server.modules.xml.Transformation; +import iaik.server.modules.xml.XPath2Transformation; +import iaik.server.modules.xml.XPathTransformation; +import iaik.server.modules.xml.XSLTTransformation; + +import at.gv.egovernment.moa.util.Constants; + +import at.gv.egovernment.moa.spss.MOAApplicationException; +import at.gv.egovernment.moa.spss.api.common.Transform; +import at.gv.egovernment.moa.spss.api.xmlbind.TransformParser; +import at.gv.egovernment.moa.spss.server.invoke.TransformationFactory; + +/** + * Test cases for the TransformationFactory class. + * + * @author Patrick Peck + * @version $Id$ + */ +public class TransformationFactoryTest extends SPSSTestCase { + + private static final String TESTDATA_BASE = + TESTDATA_ROOT + "xml/dsigTransform/"; + private TransformationFactory factory = TransformationFactory.getInstance(); + private TransformParser transformParser = new TransformParser(); + + /** + * Constructor for TransformationFactoryTest. + * @param name + */ + public TransformationFactoryTest(String name) { + super(name); + } + + protected void setUp() throws Exception { + IXSILInit.init(new URI("init/properties/init.properties")); + //IXSILInit.init(new URI("file:data/deploy/ixsil/init/properties/init.properties")); + + } + + public void testCreateCanonicalization() throws Exception { + Document transform = parseXml(TESTDATA_BASE + "canonicalization.xml"); + Transform tr = + transformParser.parseTransform(transform.getDocumentElement()); + Transformation t = factory.createTransformation(tr); + + assertTrue(t instanceof Canonicalization); + assertEquals( + "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", + t.getAlgorithmURI()); + } + + public void testCreateCanonicalizationWithComments() throws Exception { + Document transform = + parseXml(TESTDATA_BASE + "canonicalizationWithComments.xml"); + Transform tr = + transformParser.parseTransform(transform.getDocumentElement()); + Transformation t = factory.createTransformation(tr); + + assertTrue(t instanceof Canonicalization); + assertEquals( + "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments", + t.getAlgorithmURI()); + } + + public void testCreateBase64Decode() throws Exception { + Document transform = parseXml(TESTDATA_BASE + "base64.xml"); + Transform tr = + transformParser.parseTransform(transform.getDocumentElement()); + Transformation t = factory.createTransformation(tr); + assertTrue(t instanceof Base64Transformation); + } + + public void testCreateEnvelopedSignature() throws Exception { + Document transform = parseXml(TESTDATA_BASE + "enveloped.xml"); + Transform tr = + transformParser.parseTransform(transform.getDocumentElement()); + Transformation t = factory.createTransformation(tr); + assertTrue(t instanceof EnvelopedSignatureTransformation); + } + + public void testXPathTransformation() throws Exception { + Document transform = parseXml(TESTDATA_BASE + "xpath.xml"); + Transform tr = + transformParser.parseTransform(transform.getDocumentElement()); + Transformation t = factory.createTransformation(tr); + Map nsDecls; + + assertTrue(t instanceof XPathTransformation); + nsDecls = ((XPathTransformation) t).getNamespaceDeclarations(); + assertEquals(1, nsDecls.size()); + assertEquals(Constants.DSIG_NS_URI, nsDecls.get("dsig")); + } + + public void testCreateXPath2Transformation() throws Exception { + Document transform = parseXml(TESTDATA_BASE + "xpath2.xml"); + Transform tr = + transformParser.parseTransform(transform.getDocumentElement()); + Transformation t = factory.createTransformation(tr); + assertTrue(t instanceof XPath2Transformation); + } + + public void testCreateXSLTTransformation() throws Exception { + Document transform = parseXml(TESTDATA_BASE + "xslt.xml"); + Transform tr = + transformParser.parseTransform(transform.getDocumentElement()); + XSLTTransformation t = + (XSLTTransformation) factory.createTransformation(tr); + assertNotNull(t.getStylesheetElement()); + } + + public void testCreateWithIllegalAlgorithm() throws Exception { + try { + Document transform = parseXml(TESTDATA_BASE + "illegalAlgorithm.xml"); + Transform tr = + transformParser.parseTransform(transform.getDocumentElement()); + factory.createTransformation(tr); + fail(); + } catch (MOAApplicationException e) { + } + } + + public void testEqualsXslt() throws Exception { + Document xslt = parseXml(TESTDATA_BASE + "xslt.xml"); + Transform tr = transformParser.parseTransform(xslt.getDocumentElement()); + Transformation trXslt = factory.createTransformation(tr); + + Document xsltEqu = parseXml(TESTDATA_BASE + "xsltEqual.xml"); + tr = transformParser.parseTransform(xsltEqu.getDocumentElement()); + Transformation trXsltEqu = factory.createTransformation(tr); + + Document xsltDiff = parseXml(TESTDATA_BASE + "xsltDifferent.xml"); + tr = transformParser.parseTransform(xsltDiff.getDocumentElement()); + Transformation trXsltDiff = factory.createTransformation(tr); + + Document canonicalization = + parseXml(TESTDATA_BASE + "canonicalization.xml"); + + assertTrue(trXslt.equals(trXsltEqu)); + assertFalse(trXslt.equals(trXsltDiff)); + assertFalse(trXsltEqu.equals(trXsltDiff)); + assertEquals(trXslt.hashCode(), trXsltEqu.hashCode()); + assertFalse(trXslt.hashCode() == trXsltDiff.hashCode()); + assertFalse(trXsltEqu.hashCode() == trXsltDiff.hashCode()); + assertFalse(trXslt.equals(canonicalization)); + } + + public void testEqualsXPath() throws Exception { + Document xpath = parseXml(TESTDATA_BASE + "xpath.xml"); + Transform tr = transformParser.parseTransform(xpath.getDocumentElement()); + Transformation trXpath = factory.createTransformation(tr); + Transformation trXpathEqu = factory.createTransformation(tr); + + Document xpathDiff = parseXml(TESTDATA_BASE + "xpathDifferent.xml"); + tr = transformParser.parseTransform(xpathDiff.getDocumentElement()); + Transformation trXpathDiff = factory.createTransformation(tr); + + assertTrue(trXpath.equals(trXpathEqu)); + assertEquals(trXpath.hashCode(), trXpathEqu.hashCode()); + assertFalse(trXpath.equals(trXpathDiff)); + assertFalse(trXpath.hashCode() == trXpathDiff.hashCode()); + } + + public void testEqualsXPath2() throws Exception { + Document xpath2 = parseXml(TESTDATA_BASE + "xpath2.xml"); + Transform tr = transformParser.parseTransform(xpath2.getDocumentElement()); + Transformation trXpath2 = factory.createTransformation(tr); + Transformation trXpath2Equ = factory.createTransformation(tr); + + Document xpath2Diff = parseXml(TESTDATA_BASE + "xpath2Different.xml"); + tr = transformParser.parseTransform(xpath2Diff.getDocumentElement()); + Transformation trXpath2Diff = factory.createTransformation(tr); + + assertTrue(trXpath2.equals(trXpath2Equ)); + assertEquals(trXpath2.hashCode(), trXpath2Equ.hashCode()); + assertFalse(trXpath2.equals(trXpath2Diff)); + assertFalse(trXpath2.hashCode() == trXpath2Diff.hashCode()); + } + + public void testCreateTransformationList() throws Exception { + Document transforms = parseXml(TESTDATA_BASE + "transforms.xml"); + List trs = transformParser.parseTransforms(transforms.getDocumentElement()); + List transformationList = factory.createTransformationList(trs); + + assertEquals(3, transformationList.size()); + } + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvokerTest.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvokerTest.java new file mode 100644 index 000000000..28cd3805a --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvokerTest.java @@ -0,0 +1,63 @@ +package test.at.gv.egovernment.moa.spss.server.invoke; + +import java.util.Collections; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import test.at.gv.egovernment.moa.spss.SPSSTestCase; + +import at.gv.egovernment.moa.util.DOMUtils; + +import at.gv.egovernment.moa.spss.api.xmlbind.CreateXMLSignatureRequestParser; +import at.gv.egovernment.moa.spss.api.xmlbind.CreateXMLSignatureResponseBuilder; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureRequest; +import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureResponse; +import at.gv.egovernment.moa.spss.server.invoke.XMLSignatureCreationInvoker; + +/** + * Mainly a smoke test for debugging the XMLSignatureCreationInvoker. + * + * @author Patrick Peck + * @version $Id$ + */ +public class XMLSignatureCreationInvokerTest extends SPSSTestCase { + private static final String TESTDATA_BASE = + TESTDATA_ROOT + "xml/CreateXMLSignature/"; + + public XMLSignatureCreationInvokerTest(String name) { + super(name); + } + + protected void setUp() throws Exception { + setUpTransactionContext(); + setUpLoggingContext(); + setUpIaikConfiguration(); + setUpSSL(); + } + + public void testCreateXMLSignature() throws Exception { + try { + XMLSignatureCreationInvoker invoker = + XMLSignatureCreationInvoker.getInstance(); + CreateXMLSignatureRequestParser requestParser = + new CreateXMLSignatureRequestParser(); + Document doc = + SPSSTestCase.parseXmlValidating( + TESTDATA_BASE + "TestGeneratorCX2.004.Req.xml"); + CreateXMLSignatureRequest request = + requestParser.parse(doc.getDocumentElement()); + CreateXMLSignatureResponse response = + invoker.createXMLSignature(request, Collections.EMPTY_SET); + CreateXMLSignatureResponseBuilder responseBuilder = + new CreateXMLSignatureResponseBuilder(); + Element result = responseBuilder.build(response).getDocumentElement(); + + System.out.println(DOMUtils.serializeNode(result)); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvokerTest.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvokerTest.java new file mode 100644 index 000000000..56e3d541b --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvokerTest.java @@ -0,0 +1,61 @@ +package test.at.gv.egovernment.moa.spss.server.invoke; + +import org.w3c.dom.Document; + +import test.at.gv.egovernment.moa.spss.SPSSTestCase; + +import at.gv.egovernment.moa.util.DOMUtils; + +import at.gv.egovernment.moa.spss.api.xmlbind.VerifyXMLSignatureRequestParser; +import at.gv.egovernment.moa.spss.api.xmlbind.VerifyXMLSignatureResponseBuilder; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureRequest; +import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse; +import at.gv.egovernment.moa.spss.server.invoke.XMLSignatureVerificationInvoker; + +/** + * Mainly a smoke test for debugging the XMLSignatureVerificationInvoker. + * + * @author Patrick Peck + * @version $Id$ + */ +public class XMLSignatureVerificationInvokerTest extends SPSSTestCase { + private static final String TESTDATA_BASE = + TESTDATA_ROOT + "xml/VerifyXMLSignature/"; + + public XMLSignatureVerificationInvokerTest(String name) { + super(name); + } + + protected void setUp() throws Exception { + setUpTransactionContext(); + setUpLoggingContext(); + setUpIaikConfiguration(); + } + + public void testVerifyXMLSignature() throws Exception { + try { + XMLSignatureVerificationInvoker invoker = + XMLSignatureVerificationInvoker.getInstance(); + VerifyXMLSignatureRequestParser requestParser = + new VerifyXMLSignatureRequestParser(); + VerifyXMLSignatureResponseBuilder responseBuilder = + new VerifyXMLSignatureResponseBuilder(); + Document doc = + SPSSTestCase.parseXmlValidating( + TESTDATA_BASE + "TestGeneratorVX.201.Req.xml"); + + VerifyXMLSignatureRequest request = + requestParser.parse(doc.getDocumentElement()); + VerifyXMLSignatureResponse response; + + response = invoker.verifyXMLSignature(request); + System.out.println( + DOMUtils.serializeNode(responseBuilder.build(response))); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + +} diff --git a/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/tools/CertToolTest.java b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/tools/CertToolTest.java new file mode 100644 index 000000000..ac6e8c3e0 --- /dev/null +++ b/spss/server/serverlib/src/test/java/test/at/gv/egovernment/moa/spss/server/tools/CertToolTest.java @@ -0,0 +1,49 @@ +package test.at.gv.egovernment.moa.spss.server.tools; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +import at.gv.egovernment.moa.spss.server.tools.CertTool; +import test.at.gv.egovernment.moa.MOATestCase; + +/** + * Tests for the CertTool. + * + * @author Patrick Peck + * @version $Id$ + */ +public class CertToolTest extends MOATestCase { + + private static final String EXPECTED_RESULT = + "SubjectDN (RFC2253):" + + " CN=Patrick Peck,OU=MOA Team,O=BRZ,L=Vienna,ST=Vienna,C=AT\r\n" + + "IssuerDN (RFC2253) :" + + " CN=Patrick Peck,OU=MOA Team,O=BRZ,L=Vienna,ST=Vienna,C=AT\r\n" + + "Serial Number :" + + " 1047548672\r\n"; + private CertTool certTool; + + /** + * Constructor for CertToolTest. + * @param name + */ + public CertToolTest(String name) { + super(name); + } + + protected void setUp() { + certTool = new CertTool(); + } + + public void testPrintCertInfo() { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(bos); + String result; + + certTool.printCertInfo(TESTDATA_ROOT + "security/server.cer", ps); + result = new String(bos.toByteArray()); + System.out.println(result); + assertEquals(EXPECTED_RESULT, result); + } + +} diff --git a/spss/server/serverws/pom.xml b/spss/server/serverws/pom.xml index 88b3345d6..aed4e8cc1 100644 --- a/spss/server/serverws/pom.xml +++ b/spss/server/serverws/pom.xml @@ -57,7 +57,7 @@ MOA.spss.server moa-spss-lib - ${pom.version} + MOA diff --git a/spss/server/serverws/tools/ConfigurationMapper.xsl b/spss/server/serverws/tools/ConfigurationMapper.xsl deleted file mode 100644 index fd47cbf84..000000000 --- a/spss/server/serverws/tools/ConfigurationMapper.xsl +++ /dev/null @@ -1,343 +0,0 @@ - - - - - - - - MOA SPSS 1.3 Configuration File created by MOA SPSS Configuration Mapper - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - http://www.w3.org/TR/2001/REC-xml-c14n-20010315 - - - - - - - - http://www.w3.org/2000/09/xmldsig#sha1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - pkix - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CRL - OCSP - - - - - - - - - - - - - - 365 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - all - - - unused - - - keyCompromise - - - cACompromise - - - affiliationChanged - - - superseded - - - cessationOfOperation - - - certificateHold - - - privilegeWithdrawn - - - aACompromise - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spss/server/tools/pom.xml b/spss/server/tools/pom.xml index 3a3cde79c..191ba234f 100644 --- a/spss/server/tools/pom.xml +++ b/spss/server/tools/pom.xml @@ -1,38 +1,56 @@ - - - MOA.spss - moa-spss - 1.4.x - + + + MOA.spss + moa-spss + 1.4.x + - 4.0.0 - MOA.spss.server - moa-spss-tools - jar - 1.4.2 - MOA SP/SS Tools + 4.0.0 + MOA.spss.server + moa-spss-tools + jar + 1.4.2 + MOA SP/SS Tools - - ${basedir}/../../../buildhelper - + + ${basedir}/../../../buildhelper + - - - MOA.spss.server - moa-spss-lib - ${pom.version} - - - iaik.prod - iaik_jce_full - compile - - - iaik.prod - iaik_ecc - compile - - + + + + iaik.prod + iaik_moa + + + iaik.prod + iaik_jce_full + compile + + + iaik.prod + iaik_ecc + compile + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + false + + + + + diff --git a/spss/server/tools/run/certtool.bat b/spss/server/tools/run/certtool.bat new file mode 100644 index 000000000..ae55bc4a5 --- /dev/null +++ b/spss/server/tools/run/certtool.bat @@ -0,0 +1,25 @@ +@echo off + +rem +rem Script to invoke the CertTool class +rem +rem Author: Patrick Peck +rem Version: $Id: certtool.bat,v 1.6 2003/05/08 11:46:29 peck Exp $ +rem + + +if %OS%=="Windows_NT" @setlocal + +set CERTTOOL=at.gv.egovernment.moa.spss.server.tools.CertTool +set TOOLSPATH=%~p0 +set CLASSPATH=%TOOLSPATH%tools.jar;%TOOLSPATH%iaik_moa.jar;%TOOLSPATH%iaik_jce_full.jar;%TOOLSPATH%iaik_ecc.jar;%TOOLSPATH%log4j.jar + +if "%JAVA_HOME%"=="" goto noJavaHome +%JAVA_HOME%\bin\java.exe -classpath %CLASSPATH% %CERTTOOL% %1 %2 %3 %4 %5 %6 %7 %8 %9 +goto end + +:noJavaHome +echo error: JAVA_HOME not defined + +:end +if %OS%=="Windows_NT" @endlocal \ No newline at end of file diff --git a/spss/server/tools/run/certtool.sh b/spss/server/tools/run/certtool.sh new file mode 100644 index 000000000..721eff4d8 --- /dev/null +++ b/spss/server/tools/run/certtool.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# +# Script to invoke the CertTool class +# +# Author:Patrick Peck +# Version: $Id: certtool.sh,v 1.9 2003/06/23 16:01:27 peck Exp $ +# + + +if [ -z "$JAVA_HOME" ]; then + echo "error: JAVA_HOME not defined"; + exit; +fi + +CERTOOL=at.gv.egovernment.moa.spss.server.tools.CertTool +TOOLSPATH=`dirname $PWD/$0` +CLASSPATH=$TOOLSPATH/tools.jar:$TOOLSPATH/iaik_moa.jar:$TOOLSPATH/iaik_jce_full.jar:$TOOLSPATH/iaik_ecc.jar:$TOOLSPATH/log4j.jar + +$JAVA_HOME/bin/java -classpath $CLASSPATH $CERTOOL $* diff --git a/spss/server/tools/run/configtool.bat b/spss/server/tools/run/configtool.bat new file mode 100644 index 000000000..868df11f0 --- /dev/null +++ b/spss/server/tools/run/configtool.bat @@ -0,0 +1,25 @@ +@echo off + +rem +rem Script to invoke the ConfigTool class +rem +rem Author: Gregor Karlinger +rem Version: $Id: $ +rem + + +if %OS%=="Windows_NT" @setlocal + +set CONFIGTOOL=at.gv.egovernment.moa.spss.server.tools.ConfigTool +set TOOLSPATH=%~p0 +set CLASSPATH=%TOOLSPATH%tools.jar;%TOOLSPATH%xalan.jar; + +if "%JAVA_HOME%"=="" goto noJavaHome +%JAVA_HOME%\bin\java.exe -classpath %CLASSPATH% %CONFIGTOOL% %1 %2 %3 %4 %5 %6 %7 %8 %9 +goto end + +:noJavaHome +echo error: JAVA_HOME not defined + +:end +if %OS%=="Windows_NT" @endlocal \ No newline at end of file diff --git a/spss/server/tools/run/configtool.sh b/spss/server/tools/run/configtool.sh new file mode 100644 index 000000000..f7f29bae1 --- /dev/null +++ b/spss/server/tools/run/configtool.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# +# Script to invoke the ConfigTool class +# +# Author: Gregor Karlinger +# Version: $Id: $ +# + + +if [ -z "$JAVA_HOME" ]; then + echo "error: JAVA_HOME not defined"; + exit; +fi + +CONFIGTOOL=at.gv.egovernment.moa.spss.server.tools.ConfigTool +TOOLSPATH=`dirname $PWD/$0` +CLASSPATH=$TOOLSPATH/tools.jar:$TOOLSPATH/xalan.jar + +$JAVA_HOME/bin/java -classpath $CLASSPATH $CONFIGTOOL $* diff --git a/spss/server/tools/src/main/resources/tools/ConfigurationMapper.xsl b/spss/server/tools/src/main/resources/tools/ConfigurationMapper.xsl new file mode 100644 index 000000000..fd47cbf84 --- /dev/null +++ b/spss/server/tools/src/main/resources/tools/ConfigurationMapper.xsl @@ -0,0 +1,343 @@ + + + + + + + + MOA SPSS 1.3 Configuration File created by MOA SPSS Configuration Mapper + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://www.w3.org/TR/2001/REC-xml-c14n-20010315 + + + + + + + + http://www.w3.org/2000/09/xmldsig#sha1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pkix + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CRL + OCSP + + + + + + + + + + + + + + 365 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + all + + + unused + + + keyCompromise + + + cACompromise + + + affiliationChanged + + + superseded + + + cessationOfOperation + + + certificateHold + + + privilegeWithdrawn + + + aACompromise + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spss/server/tools/src/main/resources/tools/certtool.bat b/spss/server/tools/src/main/resources/tools/certtool.bat deleted file mode 100644 index ae55bc4a5..000000000 --- a/spss/server/tools/src/main/resources/tools/certtool.bat +++ /dev/null @@ -1,25 +0,0 @@ -@echo off - -rem -rem Script to invoke the CertTool class -rem -rem Author: Patrick Peck -rem Version: $Id: certtool.bat,v 1.6 2003/05/08 11:46:29 peck Exp $ -rem - - -if %OS%=="Windows_NT" @setlocal - -set CERTTOOL=at.gv.egovernment.moa.spss.server.tools.CertTool -set TOOLSPATH=%~p0 -set CLASSPATH=%TOOLSPATH%tools.jar;%TOOLSPATH%iaik_moa.jar;%TOOLSPATH%iaik_jce_full.jar;%TOOLSPATH%iaik_ecc.jar;%TOOLSPATH%log4j.jar - -if "%JAVA_HOME%"=="" goto noJavaHome -%JAVA_HOME%\bin\java.exe -classpath %CLASSPATH% %CERTTOOL% %1 %2 %3 %4 %5 %6 %7 %8 %9 -goto end - -:noJavaHome -echo error: JAVA_HOME not defined - -:end -if %OS%=="Windows_NT" @endlocal \ No newline at end of file diff --git a/spss/server/tools/src/main/resources/tools/certtool.sh b/spss/server/tools/src/main/resources/tools/certtool.sh deleted file mode 100644 index 721eff4d8..000000000 --- a/spss/server/tools/src/main/resources/tools/certtool.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -# -# Script to invoke the CertTool class -# -# Author:Patrick Peck -# Version: $Id: certtool.sh,v 1.9 2003/06/23 16:01:27 peck Exp $ -# - - -if [ -z "$JAVA_HOME" ]; then - echo "error: JAVA_HOME not defined"; - exit; -fi - -CERTOOL=at.gv.egovernment.moa.spss.server.tools.CertTool -TOOLSPATH=`dirname $PWD/$0` -CLASSPATH=$TOOLSPATH/tools.jar:$TOOLSPATH/iaik_moa.jar:$TOOLSPATH/iaik_jce_full.jar:$TOOLSPATH/iaik_ecc.jar:$TOOLSPATH/log4j.jar - -$JAVA_HOME/bin/java -classpath $CLASSPATH $CERTOOL $* diff --git a/spss/server/tools/src/main/resources/tools/configtool.bat b/spss/server/tools/src/main/resources/tools/configtool.bat deleted file mode 100644 index 868df11f0..000000000 --- a/spss/server/tools/src/main/resources/tools/configtool.bat +++ /dev/null @@ -1,25 +0,0 @@ -@echo off - -rem -rem Script to invoke the ConfigTool class -rem -rem Author: Gregor Karlinger -rem Version: $Id: $ -rem - - -if %OS%=="Windows_NT" @setlocal - -set CONFIGTOOL=at.gv.egovernment.moa.spss.server.tools.ConfigTool -set TOOLSPATH=%~p0 -set CLASSPATH=%TOOLSPATH%tools.jar;%TOOLSPATH%xalan.jar; - -if "%JAVA_HOME%"=="" goto noJavaHome -%JAVA_HOME%\bin\java.exe -classpath %CLASSPATH% %CONFIGTOOL% %1 %2 %3 %4 %5 %6 %7 %8 %9 -goto end - -:noJavaHome -echo error: JAVA_HOME not defined - -:end -if %OS%=="Windows_NT" @endlocal \ No newline at end of file diff --git a/spss/server/tools/src/main/resources/tools/configtool.sh b/spss/server/tools/src/main/resources/tools/configtool.sh deleted file mode 100644 index f7f29bae1..000000000 --- a/spss/server/tools/src/main/resources/tools/configtool.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -# -# Script to invoke the ConfigTool class -# -# Author: Gregor Karlinger -# Version: $Id: $ -# - - -if [ -z "$JAVA_HOME" ]; then - echo "error: JAVA_HOME not defined"; - exit; -fi - -CONFIGTOOL=at.gv.egovernment.moa.spss.server.tools.ConfigTool -TOOLSPATH=`dirname $PWD/$0` -CLASSPATH=$TOOLSPATH/tools.jar:$TOOLSPATH/xalan.jar - -$JAVA_HOME/bin/java -classpath $CLASSPATH $CONFIGTOOL $* -- cgit v1.2.3