Added action for which TAN is required and bank to TanChallenge

This commit is contained in:
dankito 2024-08-18 16:41:05 +02:00
parent 9a7844ae74
commit ae77d67707
7 changed files with 40 additions and 8 deletions

View File

@ -377,7 +377,7 @@ open class FinTsJobExecutor(
// on all platforms run on Dispatchers.Main, but on iOS skip this (or wrap in withContext(Dispatchers.IO) )
// val enteredTanResult = GlobalScope.async {
val tanChallenge = createTanChallenge(tanResponse, bank)
val tanChallenge = createTanChallenge(tanResponse, modelMapper.mapToActionRequiringTan(context.type), bank)
context.callback.enterTan(tanChallenge)
@ -395,7 +395,7 @@ open class FinTsJobExecutor(
return handleEnterTanResult(context, enteredTanResult, tanResponse, response)
}
protected open fun createTanChallenge(tanResponse: TanResponse, bank: BankData): TanChallenge {
protected open fun createTanChallenge(tanResponse: TanResponse, forAction: ActionRequiringTan, bank: BankData): TanChallenge {
// TODO: is this true for all tan methods?
val messageToShowToUser = tanResponse.challenge ?: ""
val challenge = tanResponse.challengeHHD_UC ?: ""
@ -405,13 +405,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
messageToShowToUser, challenge, tanMethod, tanResponse.tanMediaIdentifier)
forAction, bank, messageToShowToUser, challenge, tanMethod, tanResponse.tanMediaIdentifier)
TanMethodType.ChipTanQrCode, TanMethodType.ChipTanPhotoTanMatrixCode,
TanMethodType.QrCode, TanMethodType.photoTan ->
ImageTanChallenge(TanImageDecoder().decodeChallenge(challenge), messageToShowToUser, challenge, tanMethod, tanResponse.tanMediaIdentifier)
ImageTanChallenge(TanImageDecoder().decodeChallenge(challenge), forAction, bank, messageToShowToUser, challenge, tanMethod, tanResponse.tanMediaIdentifier)
else -> TanChallenge(messageToShowToUser, challenge, tanMethod, tanResponse.tanMediaIdentifier)
else -> TanChallenge(forAction, bank, messageToShowToUser, challenge, tanMethod, tanResponse.tanMediaIdentifier)
}
}

View File

@ -0,0 +1,15 @@
package net.dankito.banking.fints.model
enum class ActionRequiringTan {
GetAnonymousBankInfo,
GetTanMedia,
ChangeTanMedium,
GetAccountInfo,
GetTransactions,
TransferMoney
}

View File

@ -5,11 +5,13 @@ import net.dankito.banking.fints.tan.FlickerCode
open class FlickerCodeTanChallenge(
val flickerCode: FlickerCode,
forAction: ActionRequiringTan,
bank: BankData,
messageToShowToUser: String,
challenge: String,
tanMethod: TanMethod,
tanMediaIdentifier: String?
) : TanChallenge(messageToShowToUser, challenge, tanMethod, tanMediaIdentifier) {
) : TanChallenge(forAction, bank, messageToShowToUser, challenge, tanMethod, tanMediaIdentifier) {
override fun toString(): String {
return "$tanMethod (medium: $tanMediaIdentifier) $flickerCode: $messageToShowToUser"

View File

@ -5,11 +5,13 @@ import net.dankito.banking.fints.tan.TanImage
open class ImageTanChallenge(
val image: TanImage,
forAction: ActionRequiringTan,
bank: BankData,
messageToShowToUser: String,
challenge: String,
tanMethod: TanMethod,
tanMediaIdentifier: String?
) : TanChallenge(messageToShowToUser, challenge, tanMethod, tanMediaIdentifier) {
) : TanChallenge(forAction, bank, messageToShowToUser, challenge, tanMethod, tanMediaIdentifier) {
override fun toString(): String {
return "$tanMethod (medium: $tanMediaIdentifier) $image: $messageToShowToUser"

View File

@ -5,6 +5,8 @@ import net.dankito.banking.fints.response.client.FinTsClientResponse
open class TanChallenge(
val forAction: ActionRequiringTan,
val bank: BankData,
val messageToShowToUser: String,
val challenge: String,
val tanMethod: TanMethod,

View File

@ -330,4 +330,15 @@ open class ModelMapper(
return accountInfo.accountType
}
fun mapToActionRequiringTan(type: JobContextType): ActionRequiringTan = when(type) {
JobContextType.AnonymousBankInfo -> ActionRequiringTan.GetAnonymousBankInfo
JobContextType.GetTanMedia -> ActionRequiringTan.GetTanMedia
JobContextType.ChangeTanMedium -> ActionRequiringTan.ChangeTanMedium
JobContextType.GetAccountInfo -> ActionRequiringTan.GetAccountInfo
// TODO: may split actions and create two JobContexts, one for GetAccountInfo and one for GetTransactions
JobContextType.AddAccount -> ActionRequiringTan.GetTransactions
JobContextType.GetTransactions -> ActionRequiringTan.GetTransactions
JobContextType.TransferMoney -> ActionRequiringTan.TransferMoney
}
}

View File

@ -84,7 +84,7 @@ class NativeApp {
private fun enterTan(tanChallenge: TanChallenge) {
println("A TAN is required:")
println("A TAN is required for ${tanChallenge.forAction}:")
println(tanChallenge.messageToShowToUser)
println()