When adding a new account selecting now a default TAN procedure, could remove FinTsClientCallback.askUserForTanProcedure() therefore

This commit is contained in:
dankl 2020-01-01 20:59:15 +01:00 committed by dankito
parent 0c6f563385
commit ce6f548ceb
6 changed files with 25 additions and 44 deletions

View File

@ -15,7 +15,10 @@ import net.dankito.banking.fints4java.android.ui.dialogs.EnterAtcDialog
import net.dankito.banking.fints4java.android.ui.dialogs.EnterTanDialog
import net.dankito.fints.FinTsClientCallback
import net.dankito.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium
import net.dankito.fints.model.*
import net.dankito.fints.model.CustomerData
import net.dankito.fints.model.EnterTanGeneratorAtcResult
import net.dankito.fints.model.EnterTanResult
import net.dankito.fints.model.TanChallenge
import java.util.concurrent.CountDownLatch
import java.util.concurrent.atomic.AtomicReference
@ -26,11 +29,6 @@ class MainActivity : AppCompatActivity() {
val presenter = MainWindowPresenter(Base64ServiceAndroid(), object : FinTsClientCallback {
override fun askUserForTanProcedure(supportedTanProcedures: List<TanProcedure>): TanProcedure? {
// TODO: show dialog and ask user
return supportedTanProcedures.first()
}
override fun enterTan(customer: CustomerData, tanChallenge: TanChallenge): EnterTanResult {
return getTanFromUserOffUiThread(customer, tanChallenge)
}

View File

@ -22,6 +22,12 @@ open class fints4javaModelMapper {
account.bankAccounts = mapBankAccounts(account, customer.accounts)
account.supportedTanProcedures = mapTanProcedures(customer.supportedTanProcedures)
if (customer.isTanProcedureSelected) {
account.selectedTanProcedure = findMappedTanProcedure(account, customer.selectedTanProcedure)
}
else {
account.selectedTanProcedure = null
}
account.tanMedia = mapTanMediums(customer.tanMedia)
return account
@ -90,6 +96,10 @@ open class fints4javaModelMapper {
}
}
protected open fun findMappedTanProcedure(account: Account, tanProcedure: net.dankito.fints.model.TanProcedure): TanProcedure? {
return account.supportedTanProcedures.firstOrNull { it.bankInternalProcedureCode == tanProcedure.securityFunction.code }
}
open fun mapTanMediums(tanMediums: List<net.dankito.fints.messages.datenelemente.implementierte.tan.TanMedium>): List<TanMedium> {
return tanMediums.map { mapTanMedium(it) }

View File

@ -136,15 +136,6 @@ open class FinTsClient @JvmOverloads constructor(
}
// do not ask user for tan at this stage
var didOverwriteUserUnselectedTanProcedure = false
if (customer.isTanProcedureSelected == false && customer.supportedTanProcedures.isNotEmpty()) {
didOverwriteUserUnselectedTanProcedure = true
customer.selectedTanProcedure = customer.supportedTanProcedures.first()
}
val synchronizeCustomerResponse = synchronizeCustomerSystemId(bank, customer)
getTanMediaList(bank, customer, TanMedienArtVersion.Alle, TanMediumKlasse.AlleMedien)
@ -152,11 +143,6 @@ open class FinTsClient @JvmOverloads constructor(
// also check if retrieving account transactions of last 90 days without tan is supported (and thereby may retrieve first account transactions)
val transactionsOfLast90DaysResponse = tryGetTransactionsOfLast90DaysWithoutTan(bank, customer, false)
if (didOverwriteUserUnselectedTanProcedure) {
customer.resetSelectedTanProcedure()
}
return AddAccountResponse(synchronizeCustomerResponse.toResponse(), bank, customer,
transactionsOfLast90DaysResponse.isSuccessful,
transactionsOfLast90DaysResponse.bookedTransactions,
@ -509,8 +495,6 @@ open class FinTsClient @JvmOverloads constructor(
protected open fun ensureBasicBankDataRetrieved(bank: BankData, customer: CustomerData): Response {
if (bank.supportedTanProcedures.isEmpty() || bank.supportedJobs.isEmpty()) {
bank.resetBpdVersion()
val getBankInfoResponse = getBankAndCustomerInfoForNewUser(bank, customer)
if (getBankInfoResponse.isSuccessful == false || bank.supportedTanProcedures.isEmpty()
@ -533,11 +517,6 @@ open class FinTsClient @JvmOverloads constructor(
if (customer.supportedTanProcedures.isEmpty()) { // could not retrieve supported tan procedures for user
return Response(false, noTanProcedureSelected = true)
}
// we know user's supported tan procedure, now ask user which one to select
callback.askUserForTanProcedure(customer.supportedTanProcedures)?.let {
customer.selectedTanProcedure = it
}
}
return Response(customer.isTanProcedureSelected, noTanProcedureSelected = !!!customer.isTanProcedureSelected)
@ -810,6 +789,13 @@ open class FinTsClient @JvmOverloads constructor(
if (response.supportedTanProceduresForUser.isNotEmpty()) {
customer.supportedTanProcedures = response.supportedTanProceduresForUser.mapNotNull { findTanProcedure(it, bank) }
if (customer.isTanProcedureSelected == false) {
(customer.supportedTanProcedures.firstOrNull { it.displayName.contains("manuell", true) == false }
?: customer.supportedTanProcedures.firstOrNull())?.let {
customer.selectedTanProcedure = it
}
}
}
}

View File

@ -1,13 +1,14 @@
package net.dankito.fints
import net.dankito.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium
import net.dankito.fints.model.*
import net.dankito.fints.model.CustomerData
import net.dankito.fints.model.EnterTanGeneratorAtcResult
import net.dankito.fints.model.EnterTanResult
import net.dankito.fints.model.TanChallenge
interface FinTsClientCallback {
fun askUserForTanProcedure(supportedTanProcedures: List<TanProcedure>): TanProcedure?
fun enterTan(customer: CustomerData, tanChallenge: TanChallenge): EnterTanResult
/**

View File

@ -33,13 +33,6 @@ public class JavaShowcase {
customer.setSelectedTanProcedure(new TanProcedure("", Sicherheitsfunktion.PIN_TAN_911, TanProcedureType.ChipTanOptisch));
FinTsClientCallback callback = new FinTsClientCallback() {
@Nullable
@Override
public TanProcedure askUserForTanProcedure(@NotNull List<? extends TanProcedure> supportedTanProcedures) {
// TODO: if entering TAN is required select your tan procedure here
return supportedTanProcedures.get(0);
}
@Nullable
@Override
public EnterTanResult enterTan(@NotNull CustomerData customer, @NotNull TanChallenge tanChallenge) {

View File

@ -30,13 +30,6 @@ class FinTsClientTest {
private val callback = object : FinTsClientCallback {
override fun askUserForTanProcedure(supportedTanProcedures: List<TanProcedure>): TanProcedure? {
didAskUserForTanProcedure.set(true)
// TODO: if entering TAN is required select your tan procedure here
return supportedTanProcedures.first()
}
override fun enterTan(customer: CustomerData, tanChallenge: TanChallenge): EnterTanResult {
didAskUserToEnterTan.set(true)