When adding a new account selecting now a default TAN procedure, could remove FinTsClientCallback.askUserForTanProcedure() therefore
This commit is contained in:
parent
0c6f563385
commit
ce6f548ceb
|
@ -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.banking.fints4java.android.ui.dialogs.EnterTanDialog
|
||||||
import net.dankito.fints.FinTsClientCallback
|
import net.dankito.fints.FinTsClientCallback
|
||||||
import net.dankito.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium
|
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.CountDownLatch
|
||||||
import java.util.concurrent.atomic.AtomicReference
|
import java.util.concurrent.atomic.AtomicReference
|
||||||
|
|
||||||
|
@ -26,11 +29,6 @@ class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
val presenter = MainWindowPresenter(Base64ServiceAndroid(), object : FinTsClientCallback {
|
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 {
|
override fun enterTan(customer: CustomerData, tanChallenge: TanChallenge): EnterTanResult {
|
||||||
return getTanFromUserOffUiThread(customer, tanChallenge)
|
return getTanFromUserOffUiThread(customer, tanChallenge)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,12 @@ open class fints4javaModelMapper {
|
||||||
|
|
||||||
account.bankAccounts = mapBankAccounts(account, customer.accounts)
|
account.bankAccounts = mapBankAccounts(account, customer.accounts)
|
||||||
account.supportedTanProcedures = mapTanProcedures(customer.supportedTanProcedures)
|
account.supportedTanProcedures = mapTanProcedures(customer.supportedTanProcedures)
|
||||||
|
if (customer.isTanProcedureSelected) {
|
||||||
|
account.selectedTanProcedure = findMappedTanProcedure(account, customer.selectedTanProcedure)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
account.selectedTanProcedure = null
|
||||||
|
}
|
||||||
account.tanMedia = mapTanMediums(customer.tanMedia)
|
account.tanMedia = mapTanMediums(customer.tanMedia)
|
||||||
|
|
||||||
return account
|
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> {
|
open fun mapTanMediums(tanMediums: List<net.dankito.fints.messages.datenelemente.implementierte.tan.TanMedium>): List<TanMedium> {
|
||||||
return tanMediums.map { mapTanMedium(it) }
|
return tanMediums.map { mapTanMedium(it) }
|
||||||
|
|
|
@ -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)
|
val synchronizeCustomerResponse = synchronizeCustomerSystemId(bank, customer)
|
||||||
|
|
||||||
getTanMediaList(bank, customer, TanMedienArtVersion.Alle, TanMediumKlasse.AlleMedien)
|
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)
|
// 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)
|
val transactionsOfLast90DaysResponse = tryGetTransactionsOfLast90DaysWithoutTan(bank, customer, false)
|
||||||
|
|
||||||
|
|
||||||
if (didOverwriteUserUnselectedTanProcedure) {
|
|
||||||
customer.resetSelectedTanProcedure()
|
|
||||||
}
|
|
||||||
|
|
||||||
return AddAccountResponse(synchronizeCustomerResponse.toResponse(), bank, customer,
|
return AddAccountResponse(synchronizeCustomerResponse.toResponse(), bank, customer,
|
||||||
transactionsOfLast90DaysResponse.isSuccessful,
|
transactionsOfLast90DaysResponse.isSuccessful,
|
||||||
transactionsOfLast90DaysResponse.bookedTransactions,
|
transactionsOfLast90DaysResponse.bookedTransactions,
|
||||||
|
@ -509,8 +495,6 @@ open class FinTsClient @JvmOverloads constructor(
|
||||||
|
|
||||||
protected open fun ensureBasicBankDataRetrieved(bank: BankData, customer: CustomerData): Response {
|
protected open fun ensureBasicBankDataRetrieved(bank: BankData, customer: CustomerData): Response {
|
||||||
if (bank.supportedTanProcedures.isEmpty() || bank.supportedJobs.isEmpty()) {
|
if (bank.supportedTanProcedures.isEmpty() || bank.supportedJobs.isEmpty()) {
|
||||||
bank.resetBpdVersion()
|
|
||||||
|
|
||||||
val getBankInfoResponse = getBankAndCustomerInfoForNewUser(bank, customer)
|
val getBankInfoResponse = getBankAndCustomerInfoForNewUser(bank, customer)
|
||||||
|
|
||||||
if (getBankInfoResponse.isSuccessful == false || bank.supportedTanProcedures.isEmpty()
|
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
|
if (customer.supportedTanProcedures.isEmpty()) { // could not retrieve supported tan procedures for user
|
||||||
return Response(false, noTanProcedureSelected = true)
|
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)
|
return Response(customer.isTanProcedureSelected, noTanProcedureSelected = !!!customer.isTanProcedureSelected)
|
||||||
|
@ -810,6 +789,13 @@ open class FinTsClient @JvmOverloads constructor(
|
||||||
|
|
||||||
if (response.supportedTanProceduresForUser.isNotEmpty()) {
|
if (response.supportedTanProceduresForUser.isNotEmpty()) {
|
||||||
customer.supportedTanProcedures = response.supportedTanProceduresForUser.mapNotNull { findTanProcedure(it, bank) }
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package net.dankito.fints
|
package net.dankito.fints
|
||||||
|
|
||||||
import net.dankito.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium
|
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 {
|
interface FinTsClientCallback {
|
||||||
|
|
||||||
fun askUserForTanProcedure(supportedTanProcedures: List<TanProcedure>): TanProcedure?
|
|
||||||
|
|
||||||
fun enterTan(customer: CustomerData, tanChallenge: TanChallenge): EnterTanResult
|
fun enterTan(customer: CustomerData, tanChallenge: TanChallenge): EnterTanResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,13 +33,6 @@ public class JavaShowcase {
|
||||||
customer.setSelectedTanProcedure(new TanProcedure("", Sicherheitsfunktion.PIN_TAN_911, TanProcedureType.ChipTanOptisch));
|
customer.setSelectedTanProcedure(new TanProcedure("", Sicherheitsfunktion.PIN_TAN_911, TanProcedureType.ChipTanOptisch));
|
||||||
|
|
||||||
FinTsClientCallback callback = new FinTsClientCallback() {
|
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
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public EnterTanResult enterTan(@NotNull CustomerData customer, @NotNull TanChallenge tanChallenge) {
|
public EnterTanResult enterTan(@NotNull CustomerData customer, @NotNull TanChallenge tanChallenge) {
|
||||||
|
|
|
@ -30,13 +30,6 @@ class FinTsClientTest {
|
||||||
|
|
||||||
private val callback = object : FinTsClientCallback {
|
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 {
|
override fun enterTan(customer: CustomerData, tanChallenge: TanChallenge): EnterTanResult {
|
||||||
didAskUserToEnterTan.set(true)
|
didAskUserToEnterTan.set(true)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue