commit 595ac0dae5911538c2e35fcc6bc5a1fdfd6b024d
parent ff4bc650534e094190ab8adac77375d5488a0f8b
Author: MS <ms@taler.net>
Date: Thu, 23 Jul 2020 12:46:02 +0200
fix document
Diffstat:
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
@@ -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
@@ -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
@@ -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
}
}