gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libeufin] branch master updated: fix HIA, plus add sample


From: gnunet
Subject: [GNUnet-SVN] [libeufin] branch master updated: fix HIA, plus add sample data.
Date: Wed, 23 Oct 2019 16:37:21 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 27893bb  fix HIA, plus add sample data.
27893bb is described below

commit 27893bb6edf97428696f153f60a0398174098184
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Oct 23 16:37:03 2019 +0200

    fix HIA, plus add sample data.
---
 sandbox/src/main/kotlin/DB.kt      |  4 ++--
 sandbox/src/main/kotlin/Main.kt    | 28 +++++++++++++++++-------
 sandbox/src/test/resources/HIA.xml | 45 +++++++++++++++++++++-----------------
 3 files changed, 47 insertions(+), 30 deletions(-)

diff --git a/sandbox/src/main/kotlin/DB.kt b/sandbox/src/main/kotlin/DB.kt
index 7c08880..3b5ec63 100644
--- a/sandbox/src/main/kotlin/DB.kt
+++ b/sandbox/src/main/kotlin/DB.kt
@@ -8,8 +8,8 @@ const val CUSTOMER_NAME_MAX_LENGTH = 20
 const val EBICS_USER_ID_MAX_LENGTH = 10
 const val EBICS_PARTNER_ID_MAX_LENGTH = 10
 const val EBICS_SYSTEM_ID_MAX_LENGTH = 10
-const val PUBLIC_KEY_MAX_MODULUS_LENGTH = 256 // FIXME review this value!
-const val PUBLIC_KEY_MAX_EXPONENT_LENGTH = 256 // FIXME review this value!
+const val PUBLIC_KEY_MAX_MODULUS_LENGTH = 2048 // FIXME review this value!
+const val PUBLIC_KEY_MAX_EXPONENT_LENGTH = 64 // FIXME review this value!
 const val PRIV_KEY_MAX_LENGTH = 512 // FIXME review this value!
 
 /**
diff --git a/sandbox/src/main/kotlin/Main.kt b/sandbox/src/main/kotlin/Main.kt
index ef42da3..0b0cc0e 100644
--- a/sandbox/src/main/kotlin/Main.kt
+++ b/sandbox/src/main/kotlin/Main.kt
@@ -277,7 +277,7 @@ private suspend fun ApplicationCall.ebicsweb() {
 
     val body: String = receiveText()
     logger.debug("Data received: $body")
-    
+
     val bodyDocument: Document? = xmlProcess.parseStringIntoDom(body)
 
     if (bodyDocument == null || (!xmlProcess.validateFromDom(bodyDocument))) {
@@ -398,7 +398,22 @@ private suspend fun ApplicationCall.ebicsweb() {
              * and at this point is valid and _never_ empty.
              */
             val inflater = InflaterInputStream(zkey.inputStream())
-            var payload = ByteArray(1) {inflater.read().toByte()}
+
+            var payload = try {
+                ByteArray(1) {inflater.read().toByte()}
+            } catch (e: Exception) {
+                e.printStackTrace()
+                val response = KeyManagementResponse(
+                    returnCode = InvalidXmlHelper.getCode(),
+                    reportText = InvalidXmlHelper.getMessage("Badly compressed 
key")
+                )
+                respondText(
+                    contentType = ContentType.Application.Xml,
+                    status = HttpStatusCode.BadRequest
+                ) { xmlProcess.convertJaxbToString(response.get())!! }
+
+                return
+            }
 
             while (inflater.available() == 1) {
                 payload += inflater.read().toByte()
@@ -406,6 +421,7 @@ private suspend fun ApplicationCall.ebicsweb() {
 
             inflater.close()
 
+            logger.debug("Found payload: ${payload.toString(US_ASCII)}")
 
             when (bodyJaxb.value.header.static.orderDetails.orderType) {
 
@@ -468,7 +484,7 @@ private suspend fun ApplicationCall.ebicsweb() {
                             
keyObject.value.encryptionPubKeyInfo.pubKeyValue.rsaKeyValue.exponent
                         )
                     } catch (e: Exception) {
-                        logger.info("User gave bad at lease one invalid HIA 
key")
+                        logger.info("User gave at least one invalid HIA key")
                         e.printStackTrace()
                         val response = KeyManagementResponse(
                             returnCode = InvalidXmlHelper.getCode(),
@@ -483,8 +499,6 @@ private suspend fun ApplicationCall.ebicsweb() {
                         return
                     }
 
-                    // user exists and keys are good.
-
                     // put try-catch block here? (FIXME)
                     transaction {
                         ebicsSubscriber.authenticationKey = EbicsPublicKey.new 
{
@@ -521,12 +535,10 @@ private suspend fun ApplicationCall.ebicsweb() {
                 )
             )
 
-            val responseText: String? = 
xmlProcess.convertJaxbToString(hevResponse.get())
-
             respondText(
                 contentType = ContentType.Application.Xml,
                 status = HttpStatusCode.OK
-            ) { responseText.toString() }
+            ) { xmlProcess.convertJaxbToString(hevResponse.get())!! }
             return
         }
         else -> {
diff --git a/sandbox/src/test/resources/HIA.xml 
b/sandbox/src/test/resources/HIA.xml
index 024c5cc..0089a36 100644
--- a/sandbox/src/test/resources/HIA.xml
+++ b/sandbox/src/test/resources/HIA.xml
@@ -1,21 +1,26 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<ebics:ebicsUnsecuredRequest xmlns:ds="http://www.w3.org/2000/09/xmldsig#"; 
xmlns:ebics="urn:org:ebics:H004" xmlns="http://www.w3.org/2001/XMLSchema"; 
Version="H004" Revision="1">
-  <ebics:header authenticate="true">
-    <ebics:static>
-      <ebics:HostID>EBIXQUAL</ebics:HostID>
-      <ebics:PartnerID>EXCHANGE</ebics:PartnerID>
-      <ebics:UserID>TALER</ebics:UserID>
-      <ebics:OrderDetails>
-        <ebics:OrderType>HIA</ebics:OrderType>
-        <ebics:OrderAttribute>DZNNN</ebics:OrderAttribute>
-      </ebics:OrderDetails>
-      <ebics:SecurityMedium>0000</ebics:SecurityMedium>
-    </ebics:static>
-    <ebics:mutable/>
-  </ebics:header>
-  <ebics:body>
-    <ebics:DataTransfer>
-      
<ebics:OrderData>eJy9lsmSo0gWRff1FWnRSywTZxZhkVHGLASIeZB2zCAxiVHw9a2OjMiurIxadi/fu9evO+bvuPHy572uvsxpP5Rt8/0J+QaevqRN3CZlk39/msbs6+7pz9c/XtKojIfnvcxY6W1Kh1Hvk7TnwzH88ljfDM/J8P2pGMfuGYaXZfm2YN/aPodRAAAMaPjhSYYy/9fTu/st7RHfN88P2/N7OAD4T8PD/Uvgm+Ut0wYAebf9w5YIHGiqHRdpHT69vp+cmcYibcYyDsfHhxpTpKSr3GTth/6j44XVlL6+JMOzZTO/1FqbTNU0vDImw77Af2n8RxTuXds80l+ZQyHGV0GJiP1FzaeRvXG12BaUfsx1fuqYwTfVhGg76QzjdDWD0owyOb2LSqwsvRZSFgCHqItQ40zl1wrG1O68Uzj76ux21QKzmXGPUO0cMhcF6tnVM/jlWikrJ5ThnF+iA7Q6dt1z0
 [...]
-    </ebics:DataTransfer>
-  </ebics:body>
-</ebics:ebicsUnsecuredRequest>
+<ebicsUnsecuredRequest xmlns="urn:org:ebics:H004"
+                       xmlns:ds="http://www.w3.org/2000/09/xmldsig#";
+                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+                       xsi:schemaLocation="urn:org:ebics:H004 
ebics_keymgmt_request_H004.xsd"
+                       Version="H004"
+                       Revision="1">
+  <header authenticate="true">
+    <static>
+      <HostID>LIBEUFIN-SANDBOX</HostID>
+      <PartnerID>CUSTM001</PartnerID>
+      <UserID>u1</UserID>
+      <OrderDetails>
+      <OrderType>HIA</OrderType>
+      <OrderAttribute>DZNNN</OrderAttribute>
+      </OrderDetails>
+      <SecurityMedium>0000</SecurityMedium>
+    </static>
+    <mutable/>
+  </header>
+  <body>
+    <DataTransfer>
+      
<OrderData>eJzNlsmyo0YWhvf1FBW3l0SZZBY3VHIwCwESM0g7ZpCYxAxPb/mWh7ZdrlUvmhX8Z/gzyPNl5P7npSo/T0nXF0399Q35Cbz9fPi0P8qMmTzHpB8uXZx0fDAEn1+Jdf8e91/f8mFo32F4nuefZuynpstgFAAAAxp+5cR9kf3n7dPn7z0fLb6+jV39/qp6T8Ii6t+PAOA/yn9PXh3/YvpR9+FrAYD8sHbpi39ZLwL7mmpFeVIFX4q6H4I6St4Or157ZhzypB6KKBheP0UfQyVZ5TptDh9G+2+CG5RjcvjNeh/376bF/F3+FtCaeCzH/sCccjF6CEpIHO9qNg7sk6vEJqcu5+zCjy3Te4YaE00r3WCcLidQGGEqJ4uoRMrcaQFlAnAK2xDVb1T2KGFMbW87hbMe9m5XzjCb6kuIareAuStQx66uzs+PUlk5oQim7B6eoNW2qo4Ljxu4jbFWLM4M7n4geL2
 [...]
+    </DataTransfer>
+  </body>
+</ebicsUnsecuredRequest>

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]