From 65d983a5e7519113f2f7ec288593b660a16734ad Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 26 Sep 2024 14:20:12 +0200 Subject: [PATCH] Added a check to determine HHD version --- .../net/codinux/banking/fints/FinTsJobExecutor.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt index 7c134570..0cfb0f11 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt @@ -444,7 +444,7 @@ Log.info { "Terminating waiting for TAN input" } // TODO: remove again return when (tanMethod.type) { TanMethodType.ChipTanFlickercode -> FlickerCodeTanChallenge( - FlickerCodeDecoder().decodeChallenge(challenge, tanMethod.hhdVersion ?: HHDVersion.HHD_1_4), // HHD 1.4 is currently the most used version + FlickerCodeDecoder().decodeChallenge(challenge, tanMethod.hhdVersion ?: getFallbackHhdVersion(challenge)), forAction, messageToShowToUser, challenge, tanMethod, tanResponse.tanMediaIdentifier, bank, account, tanResponse.tanExpirationTime) TanMethodType.ChipTanQrCode, TanMethodType.ChipTanPhotoTanMatrixCode, @@ -455,6 +455,14 @@ Log.info { "Terminating waiting for TAN input" } // TODO: remove again } } + protected open fun getFallbackHhdVersion(challenge: String): HHDVersion { + if (challenge.length <= 35) { // is this true in all circumstances? + return HHDVersion.HHD_1_3 + } + + return HHDVersion.HHD_1_4 // HHD 1.4 is currently the most used version + } + protected open suspend fun mayRetrieveAutomaticallyIfUserEnteredDecoupledTan(context: JobContext, tanChallenge: TanChallenge, tanResponse: TanResponse) { context.bank.selectedTanMethod.decoupledParameters?.let { decoupledTanMethodParameters -> if (decoupledTanMethodParameters.periodicStateRequestsAllowed) {