diff options
author | Thomas <> | 2023-08-02 07:28:37 +0200 |
---|---|---|
committer | Thomas <> | 2023-08-02 07:28:37 +0200 |
commit | 309e5bc0c5b73946f45951aca65d8b9af33b2e82 (patch) | |
tree | 43268e5e2ed41faac9d399475b4c2d9a6fe940b0 /eaaf_modules | |
parent | e0f7b2c41f66038dc6438b3cc6da14a1422ccf43 (diff) | |
download | EAAF-Components-309e5bc0c5b73946f45951aca65d8b9af33b2e82.tar.gz EAAF-Components-309e5bc0c5b73946f45951aca65d8b9af33b2e82.tar.bz2 EAAF-Components-309e5bc0c5b73946f45951aca65d8b9af33b2e82.zip |
test(moa-sig): add PAdES verification
Diffstat (limited to 'eaaf_modules')
2 files changed, 65 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 index 71c4b1af..dda647d3 100644 --- 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 @@ -13,7 +13,9 @@ import java.util.List; import org.apache.commons.io.IOUtils; import org.junit.AfterClass; import org.junit.Assert; +import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.LoggerFactory; @@ -69,6 +71,16 @@ public class SignatureVerificationServiceTest { } + /** + * Test initializer. + */ + @Before + public void before() { + ((Logger) LoggerFactory.getLogger("iaik.server")).setLevel(Level.INFO); + ((Logger) LoggerFactory.getLogger("iaik.pki")).setLevel(Level.INFO); + + } + @Test public void unknownTrustProfile() throws IOException { // load signature @@ -197,6 +209,59 @@ public class SignatureVerificationServiceTest { assertEquals("coversFullDoc 2", CoversFullDocument.YES, result.get(1).getSignatureCoversFullDocument()); } + + @Ignore + @Test + public void padesAmtssignatur() throws IOException, MoaSigServiceException { + ((Logger) LoggerFactory.getLogger("iaik.server")).setLevel(Level.DEBUG); + ((Logger) LoggerFactory.getLogger("iaik.pki")).setLevel(Level.DEBUG); + + // load signature + byte[] signature = IOUtils.resourceToByteArray( + "/data/pades/TestAmtssignatur_Sign.pdf"); + + List<IPdfSignatureVerificationResponse> result = + service.verifyPdfSignature(signature, "MOAIDBuergerkarteAuthentisierungsDaten", true); + + assertNotNull("result", result); + assertFalse("result is empty", result.isEmpty()); + assertEquals("missing signature", 1, result.size()); + + assertEquals("sigCheckCode", 0, result.get(0).getSignatureCheckCode()); + assertEquals("certCheckCode", 0, result.get(0).getCertificateCheckCode()); + + assertNotNull("sigAlg 1", result.get(0).getSignatureAlgorithmIdentifier()); + assertNotNull("formCheck 1", result.get(0).getExtendedCertificateValidation()); + assertFalse("ext. certCheck 1", result.get(0).getFormValidationResults().isEmpty()); + assertEquals("coversFullDoc 1", CoversFullDocument.NO, result.get(0).getSignatureCoversFullDocument()); + + // valid ext. cert result + assertEquals("ext. cert. check code", 2, + result.get(0).getExtendedCertificateValidation().getMajorResult().getCode()); + assertEquals("ext. cert. check info", "INDETERMINATE", + result.get(0).getExtendedCertificateValidation().getMajorResult().getInfo()); + assertEquals("ext. cert. check code", 24, + result.get(0).getExtendedCertificateValidation().getMinorResult().getCode()); + assertEquals("ext. cert. check info", "ERROR", + result.get(0).getExtendedCertificateValidation().getMinorResult().getInfo()); + + // validate form-check result + assertEquals("ext. formcheck size", 4, result.get(0).getFormValidationResults().size()); + assertEquals("wrong PAdES-B Code", 0, result.get(0).getFormValidationResults().stream() + .filter(el -> el.getInfo().equals("B-B")) + .findFirst() + .get().getCode()); + + result.get(0).getFormValidationResults().stream() + .filter(el -> !el.getInfo().equals("B-B")) + .forEach(el -> assertEquals("wrong form check-code", 2, el.getCode())); + + assertNotNull("SigAlg 2", result.get(1).getSignatureAlgorithmIdentifier()); + assertNotNull("formCheck 2", result.get(1).getExtendedCertificateValidation()); + assertFalse("ext. certCheck 2", result.get(1).getFormValidationResults().isEmpty()); + assertEquals("coversFullDoc 2", CoversFullDocument.YES, result.get(1).getSignatureCoversFullDocument()); + + } } diff --git a/eaaf_modules/eaaf_module_moa-sig/src/test/resources/data/pades/TestAmtssignatur_Sign.pdf b/eaaf_modules/eaaf_module_moa-sig/src/test/resources/data/pades/TestAmtssignatur_Sign.pdf Binary files differnew file mode 100644 index 00000000..bdc6fe34 --- /dev/null +++ b/eaaf_modules/eaaf_module_moa-sig/src/test/resources/data/pades/TestAmtssignatur_Sign.pdf |