summaryrefslogtreecommitdiff
path: root/eaaf_modules/eaaf_module_moa-sig/src/test/java/at
diff options
context:
space:
mode:
authorThomas <>2021-03-16 16:28:35 +0100
committerThomas <>2021-03-16 16:28:35 +0100
commit70004e7814f01e866a9a13a6ff51337e260fcad9 (patch)
tree06ab4bf0b307d28438526ed82e2f0969d40e8d97 /eaaf_modules/eaaf_module_moa-sig/src/test/java/at
parent7864448fd040b26b5921cfc63afa68ef2cb90c03 (diff)
downloadEAAF-Components-70004e7814f01e866a9a13a6ff51337e260fcad9.tar.gz
EAAF-Components-70004e7814f01e866a9a13a6ff51337e260fcad9.tar.bz2
EAAF-Components-70004e7814f01e866a9a13a6ff51337e260fcad9.zip
some small updates in moa-spss module
Diffstat (limited to 'eaaf_modules/eaaf_module_moa-sig/src/test/java/at')
-rw-r--r--eaaf_modules/eaaf_module_moa-sig/src/test/java/at/gv/egiz/eaaf/modules/sigverify/moasig/test/verify/SignatureVerificationServiceTest.java96
-rw-r--r--eaaf_modules/eaaf_module_moa-sig/src/test/java/at/gv/egiz/eaaf/modules/sigverify/moasig/test/verify/SignatureVerificationServiceZuseConfigTest.java82
2 files changed, 178 insertions, 0 deletions
diff --git a/eaaf_modules/eaaf_module_moa-sig/src/test/java/at/gv/egiz/eaaf/modules/sigverify/moasig/test/verify/SignatureVerificationServiceTest.java b/eaaf_modules/eaaf_module_moa-sig/src/test/java/at/gv/egiz/eaaf/modules/sigverify/moasig/test/verify/SignatureVerificationServiceTest.java
new file mode 100644
index 00000000..5066d220
--- /dev/null
+++ b/eaaf_modules/eaaf_module_moa-sig/src/test/java/at/gv/egiz/eaaf/modules/sigverify/moasig/test/verify/SignatureVerificationServiceTest.java
@@ -0,0 +1,96 @@
+package at.gv.egiz.eaaf.modules.sigverify.moasig.test.verify;
+
+import static org.junit.Assert.assertThrows;
+
+import java.io.IOException;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import at.gv.egiz.eaaf.modules.sigverify.moasig.api.ISignatureVerificationService;
+import at.gv.egiz.eaaf.modules.sigverify.moasig.api.data.IXmlSignatureVerificationResponse;
+import at.gv.egiz.eaaf.modules.sigverify.moasig.exceptions.MoaSigServiceException;
+import at.gv.egovernment.moa.spss.server.config.ConfigurationException;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/moa-sig-service.beans.xml")
+@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
+public class SignatureVerificationServiceTest {
+
+ @Autowired ISignatureVerificationService service;
+
+ /**
+ * jUnit class initializer.
+ *
+ * @throws IOException In case of an error
+ * @throws ConfigurationException In case of an error
+ */
+ @BeforeClass
+ public static void moaSpssInitialize() throws IOException, ConfigurationException {
+ log.info("Loading Java security providers.");
+ final String current = new java.io.File(".").getCanonicalPath();
+ System.setProperty("moa.spss.server.configuration",
+ current + "/src/test/resources/config/moaspss_config/MOASPSSConfiguration.xml");
+
+ }
+
+ /**
+ * Reset MOA-SPSS configuration.
+ */
+ @AfterClass
+ public static void removeMoaSpssConfig() {
+ System.setProperty("moa.spss.server.configuration", "");
+
+ }
+
+ @Test
+ public void unknownTrustProfile() throws IOException {
+ // load signature
+ byte[] signature = IOUtils.resourceToByteArray("/data/xml/zuse_sig_1.xml");
+
+ // start verification
+ MoaSigServiceException exception = assertThrows(MoaSigServiceException.class,
+ () -> service.verifyXmlSignature(signature, "notexist"));
+
+ // verify state
+ Assert.assertEquals("wrong exception", "service.moasig.03", exception.getErrorId());
+
+ }
+
+ @Test
+ public void simpleSignaturVerificationTest() throws MoaSigServiceException, IOException {
+ // load signature
+ byte[] signature = IOUtils.resourceToByteArray("/data/xml/zuse_sig_1.xml");
+
+ //start verification
+ IXmlSignatureVerificationResponse result =
+ service.verifyXmlSignature(signature, "MOAIDBuergerkarteAuthentisierungsDaten");
+
+ //verify result
+ Assert.assertEquals("sig. checkCode", 0, result.getSignatureCheckCode());
+ Assert.assertEquals("cert. checkCode", 1, result.getCertificateCheckCode());
+ Assert.assertEquals("XML manifest. checkCode", 0, result.getXmlDsigManifestCheckCode());
+ Assert.assertEquals("manifest. checkCode", 0, result.getSignatureManifestCheckCode());
+
+ Assert.assertNotNull("X509Cert", result.getX509Certificate());
+ Assert.assertNotNull("X509Cert encoded", result.getX509CertificateEncoded());
+
+ Assert.assertFalse("PubAuthority flag", result.isPublicAuthority());
+ Assert.assertNull("PubAuthorityIdentifer", result.getPublicAuthorityCode());
+
+ Assert.assertFalse("qcCert flag", result.isQualifiedCertificate());
+
+ }
+
+}
diff --git a/eaaf_modules/eaaf_module_moa-sig/src/test/java/at/gv/egiz/eaaf/modules/sigverify/moasig/test/verify/SignatureVerificationServiceZuseConfigTest.java b/eaaf_modules/eaaf_module_moa-sig/src/test/java/at/gv/egiz/eaaf/modules/sigverify/moasig/test/verify/SignatureVerificationServiceZuseConfigTest.java
new file mode 100644
index 00000000..909c37dc
--- /dev/null
+++ b/eaaf_modules/eaaf_module_moa-sig/src/test/java/at/gv/egiz/eaaf/modules/sigverify/moasig/test/verify/SignatureVerificationServiceZuseConfigTest.java
@@ -0,0 +1,82 @@
+package at.gv.egiz.eaaf.modules.sigverify.moasig.test.verify;
+
+import java.io.IOException;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import at.gv.egiz.eaaf.modules.sigverify.moasig.api.ISignatureVerificationService;
+import at.gv.egiz.eaaf.modules.sigverify.moasig.api.data.IXmlSignatureVerificationResponse;
+import at.gv.egiz.eaaf.modules.sigverify.moasig.exceptions.MoaSigServiceException;
+import at.gv.egovernment.moa.spss.server.config.ConfigurationException;
+import lombok.extern.slf4j.Slf4j;
+
+@Ignore
+@Slf4j
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/moa-sig-service.beans.xml")
+@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
+public class SignatureVerificationServiceZuseConfigTest {
+
+ @Autowired ISignatureVerificationService service;
+
+ /**
+ * jUnit class initializer.
+ *
+ * @throws IOException In case of an error
+ * @throws ConfigurationException In case of an error
+ */
+ @BeforeClass
+ public static void moaSpssInitialize() throws IOException, ConfigurationException {
+ log.info("Loading Java security providers.");
+ final String current = new java.io.File(".").getCanonicalPath();
+ System.setProperty("moa.spss.server.configuration",
+ current + "/src/test/resources/config/moaspss_config/MOASPSSConfiguration_zuse.xml");
+
+ }
+
+ /**
+ * Reset MOA-SPSS configuration.
+ */
+ @AfterClass
+ public static void removeMoaSpssConfig() {
+ System.setProperty("moa.spss.server.configuration", "");
+
+ }
+
+ @Test
+ public void simpleSignaturVerificationTest() throws IOException, MoaSigServiceException {
+ // load signature
+ byte[] signature = IOUtils.resourceToByteArray("/data/xml/zuse_sig_1.xml");
+
+ //start verification
+ IXmlSignatureVerificationResponse result =
+ service.verifyXmlSignature(signature, "default-trustprofile");
+
+ //verify result
+ Assert.assertEquals("sig. checkCode", 0, result.getSignatureCheckCode());
+ Assert.assertEquals("cert. checkCode", 1, result.getCertificateCheckCode());
+ Assert.assertEquals("XML manifest. checkCode", 0, result.getXmlDsigManifestCheckCode());
+ Assert.assertEquals("manifest. checkCode", 0, result.getSignatureManifestCheckCode());
+
+ Assert.assertNotNull("X509Cert", result.getX509Certificate());
+ Assert.assertNotNull("X509Cert encoded", result.getX509CertificateEncoded());
+
+ Assert.assertFalse("PubAuthority flag", result.isPublicAuthority());
+ Assert.assertNull("PubAuthorityIdentifer", result.getPublicAuthorityCode());
+
+ Assert.assertFalse("qcCert flag", result.isQualifiedCertificate());
+
+ }
+
+}