commit a881a80f62e943fd5638b0d9ece83a3952cbae2c
parent 6c9267d83ebf10e2063f882e30a1fbcd0e5524a9
Author: ms <ms@taler.net>
Date: Wed, 28 Jul 2021 13:55:25 +0200
Respond 500 when bank rotates keys.
Diffstat:
3 files changed, 19 insertions(+), 14 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
@@ -81,7 +81,6 @@ suspend fun doEbicsDownloadTransaction(
val initDownloadRequestStr = createEbicsRequestForDownloadInitialization(subscriberDetails, orderType, orderParams)
val payloadChunks = LinkedList<String>()
val initResponseStr = client.postToBank(subscriberDetails.ebicsUrl, initDownloadRequestStr)
-
val initResponse = parseAndValidateEbicsResponse(subscriberDetails, initResponseStr)
when (initResponse.technicalReturnCode) {
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
@@ -391,7 +391,6 @@ fun formatHex(ba: ByteArray): String {
}
class EbicsBankConnectionProtocol: BankConnectionProtocol {
-
override suspend fun fetchTransactions(
fetchSpec: FetchSpecJson,
client: HttpClient,
@@ -478,13 +477,18 @@ class EbicsBankConnectionProtocol: BankConnectionProtocol {
}
}
}
- for (spec in specs) {
- try {
- fetchEbicsC5x(spec.orderType, client, bankConnectionId, spec.orderParams, subscriberDetails)
- } catch (e: Exception) {
- logger.warn("Ingestion failed for $spec")
- }
- }
+ /* Not handling errors here because
+ sub-calls should throw and get caught by
+ global handlers.
+ */
+ for (spec in specs)
+ fetchEbicsC5x(
+ spec.orderType,
+ client,
+ bankConnectionId,
+ spec.orderParams,
+ subscriberDetails
+ )
}
override suspend fun submitPaymentInitiation(httpClient: HttpClient, paymentInitiationId: Long) {
diff --git a/util/src/main/kotlin/Ebics.kt b/util/src/main/kotlin/Ebics.kt
@@ -440,19 +440,21 @@ fun parseAndValidateEbicsResponse(
} catch (e: Exception) {
throw EbicsProtocolError(
HttpStatusCode.InternalServerError,
- "Invalid XML (as EbicsResponse) received from bank: $responseStr"
+ "Invalid XML (as EbicsResponse) received from bank"
)
}
-
if (!XMLUtil.verifyEbicsDocument(
responseDocument,
subscriberDetails.bankAuthPub ?: throw EbicsProtocolError(
- HttpStatusCode.BadRequest,
- "Invalid subscriber state: bankAuthPub missing, please send HPB first"
+ HttpStatusCode.InternalServerError,
+ "Bank's signature verification failed"
)
)
) {
- throw EbicsProtocolError(HttpStatusCode.InternalServerError, "Bank's signature validation failed")
+ throw EbicsProtocolError(
+ HttpStatusCode.InternalServerError,
+ "Bank's signature verification failed"
+ )
}
val resp = try {
XMLUtil.convertStringToJaxb<EbicsResponse>(responseStr)