From c4f504dd0aef7efbbd70cf9c1caaed423114e60c Mon Sep 17 00:00:00 2001 From: dankito Date: Sun, 8 Sep 2024 22:40:05 +0200 Subject: [PATCH] Added tanExpirationTime to TanChallenge --- .../kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt | 8 ++++---- .../banking/fints/model/FlickerCodeTanChallenge.kt | 6 ++++-- .../net/codinux/banking/fints/model/ImageTanChallenge.kt | 6 ++++-- .../net/codinux/banking/fints/model/TanChallenge.kt | 7 +++++++ .../banking/fints/response/segments/TanResponse.kt | 8 +++++++- 5 files changed, 26 insertions(+), 9 deletions(-) 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 477f3062..9deeb625 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt @@ -388,7 +388,7 @@ open class FinTsJobExecutor( delay(500) // most TANs a valid 5 - 15 minutes. So terminate wait process after that time - if (Instant.nowExt() > tanChallenge.timestamp.plusMinutes(15)) { + if (Instant.nowExt() > tanChallenge.challengeCreationTimestamp.plusMinutes(15)) { if (tanChallenge.isEnteringTanDone == false) { tanChallenge.userDidNotEnterTan() } @@ -412,13 +412,13 @@ open class FinTsJobExecutor( TanMethodType.ChipTanFlickercode -> FlickerCodeTanChallenge( FlickerCodeDecoder().decodeChallenge(challenge, tanMethod.hhdVersion ?: HHDVersion.HHD_1_4), // HHD 1.4 is currently the most used version - forAction, messageToShowToUser, challenge, tanMethod, tanResponse.tanMediaIdentifier, bank, account) + forAction, messageToShowToUser, challenge, tanMethod, tanResponse.tanMediaIdentifier, bank, account, tanResponse.tanExpirationTime) TanMethodType.ChipTanQrCode, TanMethodType.ChipTanPhotoTanMatrixCode, TanMethodType.QrCode, TanMethodType.photoTan -> - ImageTanChallenge(TanImageDecoder().decodeChallenge(challenge), forAction, messageToShowToUser, challenge, tanMethod, tanResponse.tanMediaIdentifier, bank, account) + ImageTanChallenge(TanImageDecoder().decodeChallenge(challenge), forAction, messageToShowToUser, challenge, tanMethod, tanResponse.tanMediaIdentifier, bank, account, tanResponse.tanExpirationTime) - else -> TanChallenge(forAction, messageToShowToUser, challenge, tanMethod, tanResponse.tanMediaIdentifier, bank, account) + else -> TanChallenge(forAction, messageToShowToUser, challenge, tanMethod, tanResponse.tanMediaIdentifier, bank, account, tanResponse.tanExpirationTime) } } diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/FlickerCodeTanChallenge.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/FlickerCodeTanChallenge.kt index 21e2aee4..175ea7d9 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/FlickerCodeTanChallenge.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/FlickerCodeTanChallenge.kt @@ -1,5 +1,6 @@ package net.codinux.banking.fints.model +import kotlinx.datetime.LocalDateTime import net.codinux.banking.fints.tan.FlickerCode @@ -11,8 +12,9 @@ open class FlickerCodeTanChallenge( tanMethod: TanMethod, tanMediaIdentifier: String?, bank: BankData, - account: AccountData? = null -) : TanChallenge(forAction, messageToShowToUser, challenge, tanMethod, tanMediaIdentifier, bank, account) { + account: AccountData? = null, + tanExpirationTime: LocalDateTime? = null +) : TanChallenge(forAction, messageToShowToUser, challenge, tanMethod, tanMediaIdentifier, bank, account, tanExpirationTime) { override fun toString(): String { return "$tanMethod (medium: $tanMediaIdentifier) $flickerCode: $messageToShowToUser" diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/ImageTanChallenge.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/ImageTanChallenge.kt index 436e8438..6b646f25 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/ImageTanChallenge.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/ImageTanChallenge.kt @@ -1,5 +1,6 @@ package net.codinux.banking.fints.model +import kotlinx.datetime.LocalDateTime import net.codinux.banking.fints.tan.TanImage @@ -11,8 +12,9 @@ open class ImageTanChallenge( tanMethod: TanMethod, tanMediaIdentifier: String?, bank: BankData, - account: AccountData? = null -) : TanChallenge(forAction, messageToShowToUser, challenge, tanMethod, tanMediaIdentifier, bank, account) { + account: AccountData? = null, + tanExpirationTime: LocalDateTime? = null +) : TanChallenge(forAction, messageToShowToUser, challenge, tanMethod, tanMediaIdentifier, bank, account, tanExpirationTime) { override fun toString(): String { return "$tanMethod (medium: $tanMediaIdentifier) $image: $messageToShowToUser" diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/TanChallenge.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/TanChallenge.kt index 5e796219..19981f3d 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/TanChallenge.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/TanChallenge.kt @@ -1,6 +1,7 @@ package net.codinux.banking.fints.model import kotlinx.datetime.Instant +import kotlinx.datetime.LocalDateTime import net.codinux.banking.fints.extensions.nowExt import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMedium import net.codinux.banking.fints.response.BankResponse @@ -15,6 +16,12 @@ open class TanChallenge( val tanMediaIdentifier: String?, val bank: BankData, val account: AccountData? = null, + /** + * Datum und Uhrzeit, bis zu welchem Zeitpunkt eine TAN auf Basis der gesendeten Challenge gültig ist. Nach Ablauf der Gültigkeitsdauer wird die entsprechende TAN entwertet. + * + * In server's time zone, that is Europe/Berlin. + */ + val tanExpirationTime: LocalDateTime? = null, val challengeCreationTimestamp: Instant = Instant.nowExt() ) { diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/segments/TanResponse.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/segments/TanResponse.kt index 876a910b..13be5d9c 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/segments/TanResponse.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/response/segments/TanResponse.kt @@ -31,7 +31,13 @@ open class TanResponse( val challenge: String?, // M: bei TAN-Prozess=1, 3, 4. O: bei TAN-Prozess=2 val challengeHHD_UC: String?, - val validityDateTimeForChallenge: LocalDateTime?, + + /** + * Datum und Uhrzeit, bis zu welchem Zeitpunkt eine TAN auf Basis der gesendeten Challenge gültig ist. Nach Ablauf der Gültigkeitsdauer wird die entsprechende TAN entwertet. + * + * In server's time zone, that is Europe/Berlin. + */ + val tanExpirationTime: LocalDateTime?, val tanMediaIdentifier: String? = null, // M: bei TAN-Prozess=1, 3, 4 und „Anzahl unterstützter aktiver TAN-Medien“ nicht vorhanden. O: sonst segmentString: String