Added enterTan(TanChallenge) to FinTsClientCallback to get tan from user
This commit is contained in:
parent
7670a912e8
commit
3afd257320
|
@ -4,10 +4,7 @@ import net.dankito.banking.fints4java.android.Base64ServiceAndroid
|
|||
import net.dankito.fints.FinTsClient
|
||||
import net.dankito.fints.FinTsClientCallback
|
||||
import net.dankito.fints.banks.BankFinder
|
||||
import net.dankito.fints.model.BankData
|
||||
import net.dankito.fints.model.BankInfo
|
||||
import net.dankito.fints.model.CustomerData
|
||||
import net.dankito.fints.model.TanProcedure
|
||||
import net.dankito.fints.model.*
|
||||
import net.dankito.fints.model.mapper.BankDataMapper
|
||||
import net.dankito.fints.response.client.FinTsClientResponse
|
||||
import net.dankito.fints.response.client.GetTransactionsResponse
|
||||
|
@ -24,6 +21,10 @@ open class MainWindowPresenter {
|
|||
return supportedTanProcedures.first()
|
||||
}
|
||||
|
||||
override fun enterTan(tanChallenge: TanChallenge): String? {
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected val finTsClient = FinTsClient(callback, Base64ServiceAndroid())
|
||||
|
|
|
@ -443,13 +443,29 @@ 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 ->
|
||||
response.tanRequiredButNotProvided = true // TODO: show to user and wait for feedback
|
||||
// TODO: is this true for all tan procedures?
|
||||
val enteredTan = callback.enterTan(TanChallenge(tanResponse.challenge ?: "",
|
||||
tanResponse.challengeHHD_UC ?: "", CustomerData.TanProcedureNotSelected)) // TODO: retrieve tan procedure
|
||||
|
||||
if (enteredTan == null) {
|
||||
// i tried to send a HKTAN with cancelJob = true but then i saw there are no tan procedures that support cancellation (at least not at my bank)
|
||||
// but it's not required anyway, tan times out after some time. Simply don't respond anything and close dialog
|
||||
response.tanRequiredButNotProvided = true
|
||||
}
|
||||
else {
|
||||
return sendTanToBank(enteredTan, tanResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
protected open fun sendTanToBank(enteredTan: String, tanResponse: TanResponse): Response {
|
||||
// TODO
|
||||
return Response(false)
|
||||
}
|
||||
|
||||
|
||||
protected open fun updateBankData(bank: BankData, response: Response) {
|
||||
response.getFirstSegmentById<BankParameters>(InstituteSegmentId.BankParameters)?.let { bankParameters ->
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.dankito.fints
|
||||
|
||||
import net.dankito.fints.model.TanChallenge
|
||||
import net.dankito.fints.model.TanProcedure
|
||||
|
||||
|
||||
|
@ -7,4 +8,6 @@ interface FinTsClientCallback {
|
|||
|
||||
fun askUserForTanProcedure(supportedTanProcedures: List<TanProcedure>): TanProcedure?
|
||||
|
||||
fun enterTan(tanChallenge: TanChallenge): String?
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package net.dankito.fints.model
|
||||
|
||||
|
||||
open class TanChallenge(
|
||||
val messageToShowToUser: String,
|
||||
val tanChallenge: String,
|
||||
val tanProcedure: TanProcedure
|
||||
)
|
|
@ -38,6 +38,13 @@ public class JavaShowcase {
|
|||
// TODO: if entering TAN is required select your tan procedure here
|
||||
return supportedTanProcedures.get(0);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String enterTan(@NotNull TanChallenge tanChallenge) {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
FinTsClient finTsClient = new FinTsClient(callback, new Java8Base64Service());
|
||||
|
|
|
@ -4,14 +4,12 @@ import net.dankito.fints.messages.datenelemente.abgeleiteteformate.Laenderkennze
|
|||
import net.dankito.fints.messages.datenelemente.implementierte.Dialogsprache
|
||||
import net.dankito.fints.messages.datenelemente.implementierte.KundensystemStatus
|
||||
import net.dankito.fints.messages.datenelemente.implementierte.KundensystemStatusWerte
|
||||
import net.dankito.fints.messages.datenelemente.implementierte.signatur.Sicherheitsfunktion
|
||||
import net.dankito.fints.model.*
|
||||
import net.dankito.fints.response.client.FinTsClientResponse
|
||||
import net.dankito.fints.util.Java8Base64Service
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
|
||||
@Ignore // not an automatic test, supply your settings below
|
||||
|
@ -24,6 +22,10 @@ class FinTsClientTest {
|
|||
return supportedTanProcedures.first()
|
||||
}
|
||||
|
||||
override fun enterTan(tanChallenge: TanChallenge): String? {
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,8 +42,7 @@ class FinTsClientTest {
|
|||
|
||||
// TODO: add your settings here:
|
||||
private val Bank = BankData("", Laenderkennzeichen.Germany, "", bic = "")
|
||||
private val Customer = CustomerData("", "", name = "", iban = "",
|
||||
selectedTanProcedure = TanProcedure("", Sicherheitsfunktion.PIN_TAN_911, TanProcedureType.ChipTan))
|
||||
private val Customer = CustomerData("", "", iban = "")
|
||||
|
||||
// transfer 1 cent to yourself. Transferring money to oneself also doesn't require to enter a TAN according to PSD2
|
||||
private val BankTransferData = BankTransferData(Customer.name, Customer.iban!!, Bank.bic!!, 0.01.toBigDecimal(), "Give it to me baby")
|
||||
|
|
Loading…
Reference in New Issue