libeufin

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

commit ff960f0b7d662df5c7cff890ceabfdae61c8c1e3
parent e5cadfc7f1a985ef7cb989fe38846485d4eb8df5
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Tue, 12 Nov 2019 14:34:57 +0100

cannot use wrapper elements

Diffstat:
Mnexus/src/main/kotlin/Main.kt | 16+++++++++++++++-
Msandbox/src/test/kotlin/XmlUtilTest.kt | 15++++++++-------
2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/nexus/src/main/kotlin/Main.kt b/nexus/src/main/kotlin/Main.kt @@ -55,6 +55,7 @@ import javax.xml.bind.JAXBElement import org.w3c.dom.Document import java.security.SecureRandom import java.util.* +import java.util.zip.InflaterInputStream import javax.xml.datatype.DatatypeFactory import javax.xml.datatype.XMLGregorianCalendar @@ -108,7 +109,7 @@ fun chunkString(input: String): String { } -fun expectId(param: String?) : Int { +fun expectId(param: String?): Int { try { return param!!.toInt() @@ -330,6 +331,19 @@ fun main() { throw EbicsError(response.value.body.returnCode.value) } + // extract payload + + val er = CryptoUtil.EncryptionResult( + response.value.body.dataTransfer!!.dataEncryptionInfo!!.transactionKey, + (response.value.body.dataTransfer!!.dataEncryptionInfo as EbicsTypes.DataEncryptionInfo) + .encryptionPubKeyDigest.value, + Base64.getDecoder().decode(response.value.body.dataTransfer!!.orderData.value) + ) + + val dataCompr = CryptoUtil.decryptEbicsE002(er, CryptoUtil.loadRsaPrivateKey(encPrivBlob)) + val data = EbicsOrderUtil.decodeOrderDataXml<HTDResponseOrderData>(dataCompr) + logger.debug("HTD payload is: ${XMLUtil.convertJaxbToString(data)}") + val ackRequestDoc = transaction { val subscriber = EbicsSubscriberEntity.findById(id) ?: throw SubscriberNotFoundError(HttpStatusCode.NotFound) diff --git a/sandbox/src/test/kotlin/XmlUtilTest.kt b/sandbox/src/test/kotlin/XmlUtilTest.kt @@ -5,6 +5,7 @@ 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.EbicsTypes import tech.libeufin.schema.ebics_h004.HTDResponseOrderData import java.rmi.UnmarshalException import java.security.KeyPairGenerator @@ -15,7 +16,9 @@ class XmlUtilTest { @Test fun deserializeConsecutiveLists() { - XMLUtil.convertStringToJaxb<HTDResponseOrderData>(""" + + // NOTE: this needs wrapping elements to be parsed into a JAXB object. + val tmp = XMLUtil.convertStringToJaxb<HTDResponseOrderData>(""" <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <HTDResponseOrderData xmlns="urn:org:ebics:H004"> <PartnerInfo> @@ -25,7 +28,6 @@ class XmlUtilTest { <BankInfo> <HostID>host01</HostID> </BankInfo> - <dogs> <AccountInfo Currency="EUR" Description="ACCT" ID="acctid1"> <AccountNumber international="true">DE21500105174751659277</AccountNumber> <BankCode international="true">INGDDEFFXXX</BankCode> @@ -36,8 +38,6 @@ class XmlUtilTest { <BankCode international="true">GENODEM1GLS</BankCode> <AccountHolder>Mina Musterfrau</AccountHolder> </AccountInfo> - </dogs> - <cats> <OrderInfo> <OrderType>C53</OrderType> <TransferType>Download</TransferType> @@ -53,9 +53,7 @@ class XmlUtilTest { <TransferType>Upload</TransferType> <Description>foo</Description> </OrderInfo> - </cats> </PartnerInfo> - <UserInfo> <UserID Status="5">USER1</UserID> <Name>Some User</Name> @@ -63,7 +61,10 @@ class XmlUtilTest { <OrderTypes>C54 C53 C52 CCC</OrderTypes> </Permission> </UserInfo> - </HTDResponseOrderData>""".trimIndent()) + </HTDResponseOrderData>""".trimIndent() + ) + + logger.debug(tmp.value.partnerInfo.orderInfoList[0].description) } @Test