From a589fc89e2884d92469d47de9d85d8566a774803 Mon Sep 17 00:00:00 2001 From: dankl Date: Thu, 2 Jan 2020 13:57:50 +0100 Subject: [PATCH] Added tanMediaIdentifier to TanChallenge; added toString() --- .../main/kotlin/net/dankito/fints/FinTsClient.kt | 13 ++++++++++--- .../kotlin/net/dankito/fints/model/TanChallenge.kt | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt index be990f04..984e3105 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -607,9 +607,7 @@ open class FinTsClient @JvmOverloads constructor( protected open fun handleMayRequiredTan(response: Response, bank: BankData, customer: CustomerData, dialogData: DialogData): Response { if (response.isStrongAuthenticationRequired) { response.tanResponse?.let { tanResponse -> - // TODO: is this true for all tan procedures? - val enteredTanResult = callback.enterTan(customer, TanChallenge(tanResponse.challenge ?: "", - tanResponse.challengeHHD_UC ?: "", customer.selectedTanProcedure)) + val enteredTanResult = callback.enterTan(customer, createTanChallenge(tanResponse, customer)) if (enteredTanResult.changeTanProcedureTo != null) { return handleUserAsksToChangeTanProcedureAndResendLastMessage(enteredTanResult.changeTanProcedureTo, @@ -640,6 +638,15 @@ open class FinTsClient @JvmOverloads constructor( return response } + protected open fun createTanChallenge(tanResponse: TanResponse, customer: CustomerData): TanChallenge { + // TODO: is this true for all tan procedures? + val messageToShowToUser = tanResponse.challenge ?: "" + val challenge = tanResponse.challengeHHD_UC ?: "" + val tanProcedure = customer.selectedTanProcedure + + return TanChallenge(messageToShowToUser, challenge, tanProcedure, tanResponse.tanMediaIdentifier) + } + protected open fun sendTanToBank(enteredTan: String, tanResponse: TanResponse, bank: BankData, customer: CustomerData, dialogData: DialogData): Response { diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/TanChallenge.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/TanChallenge.kt index e9886031..a507b83d 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/TanChallenge.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/TanChallenge.kt @@ -3,6 +3,13 @@ package net.dankito.fints.model open class TanChallenge( val messageToShowToUser: String, - val tanChallenge: String, - val tanProcedure: TanProcedure -) \ No newline at end of file + val challenge: String, + val tanProcedure: TanProcedure, + val tanMediaIdentifier: String? +) { + + override fun toString(): String { + return "$tanProcedure (medium: $tanMediaIdentifier): $messageToShowToUser" + } + +} \ No newline at end of file