commit d39dc0a08537d31ccc6dbd2b8e59c4db4530c571
parent 5b660e16c3b0bcc70eb5e6447f82afba92bac79c
Author: MS <ms@taler.net>
Date: Thu, 23 Jul 2020 11:17:47 +0200
helper function to generate XML error responses
Diffstat:
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -932,7 +932,7 @@ private fun handleEbicsDownloadTransactionInitialization(requestContext: Request
"HKD" -> handleEbicsHkd(requestContext)
/* Temporarily handling C52/C53 with same logic */
"C53" -> handleEbicsC53(requestContext)
- "C52" -> handleEbicsC53(requestContext)
+ "C52" -> handleEbicsC53(requestContext) // why?
"TSD" -> handleEbicsTSD(requestContext)
"PTK" -> handleEbicsPTK(requestContext)
else -> throw EbicsInvalidXmlError()
diff --git a/util/src/main/kotlin/ebics_h004/EbicsResponse.kt b/util/src/main/kotlin/ebics_h004/EbicsResponse.kt
@@ -2,6 +2,7 @@ package tech.libeufin.util.ebics_h004
import org.apache.xml.security.binding.xmldsig.SignatureType
import tech.libeufin.util.CryptoUtil
+import tech.libeufin.util.XMLUtil
import java.math.BigInteger
import javax.xml.bind.annotation.*
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter
@@ -124,6 +125,31 @@ class EbicsResponse {
}
companion object {
+
+ fun createForUploadWithError(
+ errorText: String, errorCode: String, phase: EbicsTypes.TransactionPhaseType
+ ): EbicsResponse {
+ val resp = EbicsResponse().apply {
+ this.version = "H004"
+ this.revision = 1
+ this.header = EbicsResponse.Header().apply {
+ this.mutable = EbicsResponse.MutableHeaderType().apply {
+ this.reportText = errorText
+ this.returnCode = errorCode
+ this.transactionPhase = phase
+ }
+ _static = EbicsResponse.StaticHeaderType()
+ }
+ this.authSignature = SignatureType()
+ this.body = EbicsResponse.Body().apply {
+ this.returnCode = EbicsResponse.ReturnCode().apply {
+ this.value = errorCode
+ }
+ }
+ }
+ return resp
+ }
+
fun createForUploadInitializationPhase(transactionID: String, orderID: String): EbicsResponse {
return EbicsResponse().apply {
this.version = "H004"
@@ -182,7 +208,6 @@ class EbicsResponse {
}
}
-
fun createForUploadTransferPhase(
transactionID: String,
segmentNumber: Int,