aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke
diff options
context:
space:
mode:
Diffstat (limited to 'moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke')
-rw-r--r--moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/AllTests.java49
-rw-r--r--moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/CMSSignatureVerificationInvokerTest.java87
-rw-r--r--moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactoryTest.java204
-rw-r--r--moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/TransformationFactoryTest.java220
-rw-r--r--moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvokerTest.java87
-rw-r--r--moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvokerTest.java85
6 files changed, 732 insertions, 0 deletions
diff --git a/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/AllTests.java b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/AllTests.java
new file mode 100644
index 0000000..dc15679
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/AllTests.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-SPSS has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+
+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/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/CMSSignatureVerificationInvokerTest.java b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/CMSSignatureVerificationInvokerTest.java
new file mode 100644
index 0000000..0db5dbc
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/CMSSignatureVerificationInvokerTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-SPSS has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+
+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/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactoryTest.java b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactoryTest.java
new file mode 100644
index 0000000..602393c
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactoryTest.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-SPSS has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+
+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 <code>DataObjectFactory</code> 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 =
+ "<XMLContent>"
+ + " <User name=\"test1\"/>"
+ + " <USer name=\"test2\"/>"
+ + "</XMLContent>";
+ 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/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/TransformationFactoryTest.java b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/TransformationFactoryTest.java
new file mode 100644
index 0000000..52f8038
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/TransformationFactoryTest.java
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-SPSS has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+
+package test.at.gv.egovernment.moa.spss.server.invoke;
+
+import java.util.List;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+
+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;
+import at.gv.egovernment.moa.util.Constants;
+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 test.at.gv.egovernment.moa.spss.SPSSTestCase;
+
+/**
+ * Test cases for the <code>TransformationFactory</code> 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/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvokerTest.java b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvokerTest.java
new file mode 100644
index 0000000..8b3e6b0
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvokerTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-SPSS has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+
+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/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvokerTest.java b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvokerTest.java
new file mode 100644
index 0000000..7ea63e2
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvokerTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2003 Federal Chancellery Austria
+ * MOA-SPSS has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+
+
+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();
+ }
+ }
+
+
+}