[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 02/03: EBICS checks.
From: |
gnunet |
Subject: |
[libeufin] 02/03: EBICS checks. |
Date: |
Wed, 15 Feb 2023 15:07:40 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
commit 8a74c8241cb89984e044b4d6136a4dc0763773f3
Author: MS <ms@taler.net>
AuthorDate: Wed Feb 15 13:27:28 2023 +0100
EBICS checks.
Moving the check for a transaction ID after having
checked that the EBICS technical return code is EBICS_OK.
---
.../tech/libeufin/nexus/ebics/EbicsClient.kt | 24 +++++++++++++---------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt
index 59d5062b..71cced71 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt
@@ -105,12 +105,7 @@ suspend fun doEbicsDownloadTransaction(
val initResponseStr = client.postToBank(subscriberDetails.ebicsUrl,
initDownloadRequestStr)
val initResponse = parseAndValidateEbicsResponse(subscriberDetails,
initResponseStr)
- val transactionID =
- initResponse.transactionID ?: throw NexusError(
- HttpStatusCode.BadGateway,
- "Initial response must contain transaction ID, $orderType did not!"
- )
-
+ val transactionID: String? = initResponse.transactionID
// Checking for EBICS communication problems.
when (initResponse.technicalReturnCode) {
EbicsReturnCode.EBICS_OK -> {
@@ -125,13 +120,21 @@ suspend fun doEbicsDownloadTransaction(
throw EbicsProtocolError(
HttpStatusCode.UnprocessableEntity,
"Unexpected return code ${initResponse.technicalReturnCode}," +
- " for order type $orderType and transaction ID
$transactionID," +
+ " for order type $orderType and transaction ID:
$transactionID," +
" at init phase.",
initResponse.technicalReturnCode
)
}
}
-
+ /**
+ * At this point, the EBICS init phase went through,
+ * therefore the message should carry a transaction ID!
+ */
+ if (transactionID == null) throw NexusError(
+ HttpStatusCode.BadGateway,
+ "EBICS-correct init response should contain" +
+ " a transaction ID, $orderType did not!"
+ )
// Checking the 'bank technical' code.
when (initResponse.bankReturnCode) {
EbicsReturnCode.EBICS_OK -> {
@@ -145,7 +148,6 @@ suspend fun doEbicsDownloadTransaction(
return EbicsDownloadBankErrorResult(initResponse.bankReturnCode)
}
}
-
logger.debug("Bank acknowledges EBICS download initialization." +
" Transaction ID: $transactionID.")
val encryptionInfo = initResponse.dataEncryptionInfo
@@ -248,7 +250,9 @@ suspend fun doEbicsUploadTransaction(
orderParams: EbicsOrderParams
) {
if (subscriberDetails.bankEncPub == null) {
- throw NexusError(HttpStatusCode.BadRequest, "bank encryption key
unknown, request HPB first")
+ throw NexusError(HttpStatusCode.BadRequest,
+ "bank encryption key unknown, request HPB first"
+ )
}
val preparedUploadData = prepareUploadPayload(subscriberDetails, payload)
val req = createEbicsRequestForUploadInitialization(subscriberDetails,
orderType, orderParams, preparedUploadData)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.