libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 0117c917e88bf2abb5827f4046b921f99b3910a2
parent aa9064ac730b0cb530e827f3244f77920114f155
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Tue, 19 Nov 2019 17:18:43 +0100

Add new (failing) test case.

sign_str = X002_sign(document)
sign_jaxb = convert(sign_str)
sign_doc = convert(sign_jaxb)
X002_verify(sign_doc) => FAIL!

Diffstat:
Anexus/src/main/kotlin/Containers.kt | 38++++++++++++++++++++++++++++++++++++++
Msandbox/src/main/python/libeufin-cli | 15+++++++++++++++
Msandbox/src/test/kotlin/XmlUtilTest.kt | 38++++++++++++++++++++++++++++++++++++++
3 files changed, 91 insertions(+), 0 deletions(-)

diff --git a/nexus/src/main/kotlin/Containers.kt b/nexus/src/main/kotlin/Containers.kt @@ -0,0 +1,37 @@ +package tech.libeufin.nexus + +import javax.crypto.SecretKey +import org.w3c.dom.Document + + +/** + * This class is a mere container that keeps data found + * in the database and that is further needed to sign / verify + * / make messages. And not all the values are needed all + * the time. + */ +data class EbicsContainer( + + // needed to verify responses + val bankAuthPubBlob: ByteArray? = null, + + val bankEncPubBlob: ByteArray? = null, + + // needed to send the message + val ebicsUrl: String? = null, + + // needed to craft further messages + val hostId: String? = null, + + // needed to encrypt order data during all the phases + val plainTransactionKey: SecretKey? = null, + + // needed to decrypt data coming from the bank + val customerEncPrivBlob: ByteArray? = null, + + // needed to sign documents + val customerAuthPrivBlob: ByteArray? = null, + + // signed document to send to the bank + var doc: Document? = null +) +\ No newline at end of file diff --git a/sandbox/src/main/python/libeufin-cli b/sandbox/src/main/python/libeufin-cli @@ -40,6 +40,21 @@ def ini(obj, customer_id): print(resp.content.decode("utf-8")) + + +@ebics.command(help="Give and get keys.") +@click.pass_context +@click.option( + "--customer-id", + help="numerical ID of the customer at the Nexus", + required=False, + default=1) +def prepare(ctx, customer_id): + ctx.invoke(ini) + ctx.invoke(hia) + ctx.invoke(sync) + + @ebics.command(help="send HTD message") @click.pass_context @click.option( diff --git a/sandbox/src/test/kotlin/XmlUtilTest.kt b/sandbox/src/test/kotlin/XmlUtilTest.kt @@ -1,10 +1,12 @@ package tech.libeufin.sandbox +import org.apache.xml.security.binding.xmldsig.SignatureType import org.junit.Test import org.junit.Assert.* import org.junit.rules.ExpectedException import org.xml.sax.SAXParseException import tech.libeufin.schema.ebics_h004.EbicsKeyManagementResponse +import tech.libeufin.schema.ebics_h004.EbicsResponse import tech.libeufin.schema.ebics_h004.EbicsTypes import tech.libeufin.schema.ebics_h004.HTDResponseOrderData import java.rmi.UnmarshalException @@ -112,6 +114,42 @@ class XmlUtilTest { } @Test + fun verifySigningWithConversion() { + + val pair = CryptoUtil.generateRsaKeyPair(2048) + + val response = EbicsResponse().apply { + version = "H004" + header = EbicsResponse.Header().apply { + _static = EbicsResponse.StaticHeaderType() + mutable = EbicsResponse.MutableHeaderType().apply { + this.reportText = "foo" + this.returnCode = "bar" + this.transactionPhase = EbicsTypes.TransactionPhaseType.INITIALISATION + } + } + authSignature = SignatureType() + body = EbicsResponse.Body().apply { + returnCode = EbicsResponse.ReturnCode().apply { + authenticate = true + value = "asdf" + } + } + } + + val signature = signEbicsResponseX002(response, pair.private) + val signatureJaxb = XMLUtil.convertStringToJaxb<EbicsResponse>(signature) + + assertTrue( + + XMLUtil.verifyEbicsDocument( + XMLUtil.convertJaxbToDocument(signatureJaxb.value), + pair.public + ) + ) + } + + @Test fun multiAuthSigningTest() { val doc = XMLUtil.parseStringIntoDom(""" <myMessage xmlns:ebics="urn:org:ebics:H004">