gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: fix document


From: gnunet
Subject: [libeufin] branch master updated: fix document
Date: Thu, 23 Jul 2020 12:46:14 +0200

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

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 595ac0d  fix document
595ac0d is described below

commit 595ac0dae5911538c2e35fcc6bc5a1fdfd6b024d
Author: MS <ms@taler.net>
AuthorDate: Thu Jul 23 12:46:02 2020 +0200

    fix document
---
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  | 24 +++++++++-------------
 sandbox/src/test/kotlin/EbicsErrorTest.kt          |  4 ++++
 util/src/main/kotlin/ebics_h004/EbicsResponse.kt   |  3 +++
 3 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index dd55e6c..9140ddc 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -182,21 +182,17 @@ fun serverMain(dbName: String) {
 
             exception<EbicsRequestError> { cause ->
                 LOGGER.info("Client EBICS request was invalid")
-                /*val response = EbicsResponse().apply {
-                    this.version = "H004"
-                    this.revision = 1
-                    this.header = EbicsResponse.Header().apply {
-                        this.mutable = EbicsResponse.MutableHeaderType().apply 
{
-                            this.reportText = cause.errorText
-                            this.returnCode = cause.errorCode
-                        }
-                    }
-                }
-
-                 */
+                val resp = EbicsResponse.createForUploadWithError(
+                    cause.errorText,
+                    cause.errorCode,
+                    // assuming that the phase is always transfer,
+                    // as errors during initialization should have
+                    // already been caught by the chunking logic.
+                    EbicsTypes.TransactionPhaseType.TRANSFER
+                )
                 call.respondText(
-                    cause.localizedMessage,
-                    ContentType.Text.Plain,
+                    XMLUtil.convertJaxbToString(resp),
+                    ContentType.Application.Xml,
                     HttpStatusCode.OK
                 )
             }
diff --git a/sandbox/src/test/kotlin/EbicsErrorTest.kt 
b/sandbox/src/test/kotlin/EbicsErrorTest.kt
index 35cbb45..e0be736 100644
--- a/sandbox/src/test/kotlin/EbicsErrorTest.kt
+++ b/sandbox/src/test/kotlin/EbicsErrorTest.kt
@@ -1,5 +1,6 @@
 import org.apache.xml.security.binding.xmldsig.SignatureType
 import org.junit.Test
+import tech.libeufin.util.CryptoUtil
 import tech.libeufin.util.XMLUtil
 import tech.libeufin.util.ebics_h004.EbicsResponse
 import tech.libeufin.util.ebics_h004.EbicsTypes
@@ -8,11 +9,14 @@ class EbicsErrorTest {
 
     @Test
     fun makeEbicsErrorResponse() {
+        val pair = CryptoUtil.generateRsaKeyPair(2048)
         val resp = EbicsResponse.createForUploadWithError(
             "[EBICS_ERROR] abc",
             "012345",
             EbicsTypes.TransactionPhaseType.INITIALISATION
         )
+        val signedResp = XMLUtil.signEbicsResponse(resp, pair.private)
+        XMLUtil.validateFromString(signedResp)
         assert(resp.header.mutable.reportText == "[EBICS_ERROR] abc")
         assert(resp.header.mutable.returnCode == "012345")
         assert(resp.body.returnCode.value == "012345")
diff --git a/util/src/main/kotlin/ebics_h004/EbicsResponse.kt 
b/util/src/main/kotlin/ebics_h004/EbicsResponse.kt
index 1e1bbeb..d0a88ae 100644
--- a/util/src/main/kotlin/ebics_h004/EbicsResponse.kt
+++ b/util/src/main/kotlin/ebics_h004/EbicsResponse.kt
@@ -1,6 +1,7 @@
 package tech.libeufin.util.ebics_h004
 
 import org.apache.xml.security.binding.xmldsig.SignatureType
+import org.apache.xml.security.binding.xmldsig.SignedInfoType
 import tech.libeufin.util.CryptoUtil
 import tech.libeufin.util.XMLUtil
 import java.math.BigInteger
@@ -133,6 +134,7 @@ class EbicsResponse {
                 this.version = "H004"
                 this.revision = 1
                 this.header = EbicsResponse.Header().apply {
+                    this.authenticate = true
                     this.mutable = EbicsResponse.MutableHeaderType().apply {
                         this.reportText = errorText
                         this.returnCode = errorCode
@@ -143,6 +145,7 @@ class EbicsResponse {
                 this.authSignature = SignatureType()
                 this.body = EbicsResponse.Body().apply {
                     this.returnCode = EbicsResponse.ReturnCode().apply {
+                        this.authenticate = true
                         this.value = errorCode
                     }
                 }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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