Added action for which TAN is required and bank to TanChallenge
This commit is contained in:
parent
9a7844ae74
commit
ae77d67707
|
@ -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) )
|
// on all platforms run on Dispatchers.Main, but on iOS skip this (or wrap in withContext(Dispatchers.IO) )
|
||||||
// val enteredTanResult = GlobalScope.async {
|
// val enteredTanResult = GlobalScope.async {
|
||||||
val tanChallenge = createTanChallenge(tanResponse, bank)
|
val tanChallenge = createTanChallenge(tanResponse, modelMapper.mapToActionRequiringTan(context.type), bank)
|
||||||
|
|
||||||
context.callback.enterTan(tanChallenge)
|
context.callback.enterTan(tanChallenge)
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ open class FinTsJobExecutor(
|
||||||
return handleEnterTanResult(context, enteredTanResult, tanResponse, response)
|
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?
|
// TODO: is this true for all tan methods?
|
||||||
val messageToShowToUser = tanResponse.challenge ?: ""
|
val messageToShowToUser = tanResponse.challenge ?: ""
|
||||||
val challenge = tanResponse.challengeHHD_UC ?: ""
|
val challenge = tanResponse.challengeHHD_UC ?: ""
|
||||||
|
@ -405,13 +405,13 @@ open class FinTsJobExecutor(
|
||||||
TanMethodType.ChipTanFlickercode ->
|
TanMethodType.ChipTanFlickercode ->
|
||||||
FlickerCodeTanChallenge(
|
FlickerCodeTanChallenge(
|
||||||
FlickerCodeDecoder().decodeChallenge(challenge, tanMethod.hhdVersion ?: HHDVersion.HHD_1_4), // HHD 1.4 is currently the most used version
|
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.ChipTanQrCode, TanMethodType.ChipTanPhotoTanMatrixCode,
|
||||||
TanMethodType.QrCode, TanMethodType.photoTan ->
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package net.dankito.banking.fints.model
|
||||||
|
|
||||||
|
enum class ActionRequiringTan {
|
||||||
|
GetAnonymousBankInfo,
|
||||||
|
|
||||||
|
GetTanMedia,
|
||||||
|
|
||||||
|
ChangeTanMedium,
|
||||||
|
|
||||||
|
GetAccountInfo,
|
||||||
|
|
||||||
|
GetTransactions,
|
||||||
|
|
||||||
|
TransferMoney
|
||||||
|
}
|
|
@ -5,11 +5,13 @@ import net.dankito.banking.fints.tan.FlickerCode
|
||||||
|
|
||||||
open class FlickerCodeTanChallenge(
|
open class FlickerCodeTanChallenge(
|
||||||
val flickerCode: FlickerCode,
|
val flickerCode: FlickerCode,
|
||||||
|
forAction: ActionRequiringTan,
|
||||||
|
bank: BankData,
|
||||||
messageToShowToUser: String,
|
messageToShowToUser: String,
|
||||||
challenge: String,
|
challenge: String,
|
||||||
tanMethod: TanMethod,
|
tanMethod: TanMethod,
|
||||||
tanMediaIdentifier: String?
|
tanMediaIdentifier: String?
|
||||||
) : TanChallenge(messageToShowToUser, challenge, tanMethod, tanMediaIdentifier) {
|
) : TanChallenge(forAction, bank, messageToShowToUser, challenge, tanMethod, tanMediaIdentifier) {
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "$tanMethod (medium: $tanMediaIdentifier) $flickerCode: $messageToShowToUser"
|
return "$tanMethod (medium: $tanMediaIdentifier) $flickerCode: $messageToShowToUser"
|
||||||
|
|
|
@ -5,11 +5,13 @@ import net.dankito.banking.fints.tan.TanImage
|
||||||
|
|
||||||
open class ImageTanChallenge(
|
open class ImageTanChallenge(
|
||||||
val image: TanImage,
|
val image: TanImage,
|
||||||
|
forAction: ActionRequiringTan,
|
||||||
|
bank: BankData,
|
||||||
messageToShowToUser: String,
|
messageToShowToUser: String,
|
||||||
challenge: String,
|
challenge: String,
|
||||||
tanMethod: TanMethod,
|
tanMethod: TanMethod,
|
||||||
tanMediaIdentifier: String?
|
tanMediaIdentifier: String?
|
||||||
) : TanChallenge(messageToShowToUser, challenge, tanMethod, tanMediaIdentifier) {
|
) : TanChallenge(forAction, bank, messageToShowToUser, challenge, tanMethod, tanMediaIdentifier) {
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "$tanMethod (medium: $tanMediaIdentifier) $image: $messageToShowToUser"
|
return "$tanMethod (medium: $tanMediaIdentifier) $image: $messageToShowToUser"
|
||||||
|
|
|
@ -5,6 +5,8 @@ import net.dankito.banking.fints.response.client.FinTsClientResponse
|
||||||
|
|
||||||
|
|
||||||
open class TanChallenge(
|
open class TanChallenge(
|
||||||
|
val forAction: ActionRequiringTan,
|
||||||
|
val bank: BankData,
|
||||||
val messageToShowToUser: String,
|
val messageToShowToUser: String,
|
||||||
val challenge: String,
|
val challenge: String,
|
||||||
val tanMethod: TanMethod,
|
val tanMethod: TanMethod,
|
||||||
|
|
|
@ -330,4 +330,15 @@ open class ModelMapper(
|
||||||
return accountInfo.accountType
|
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
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -84,7 +84,7 @@ class NativeApp {
|
||||||
|
|
||||||
|
|
||||||
private fun enterTan(tanChallenge: TanChallenge) {
|
private fun enterTan(tanChallenge: TanChallenge) {
|
||||||
println("A TAN is required:")
|
println("A TAN is required for ${tanChallenge.forAction}:")
|
||||||
println(tanChallenge.messageToShowToUser)
|
println(tanChallenge.messageToShowToUser)
|
||||||
println()
|
println()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue