Added SimpleFinTsClientCallback and NoOpFinTsClientCallback

This commit is contained in:
dankito 2020-04-28 18:40:18 +02:00
parent 3e853da70c
commit 56972da14d
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package net.dankito.fints.callback
import net.dankito.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium
import net.dankito.fints.model.*
open class NoOpFinTsClientCallback : FinTsClientCallback {
override fun askUserForTanProcedure(supportedTanProcedures: List<TanProcedure>,
suggestedTanProcedure: TanProcedure?): TanProcedure? {
return suggestedTanProcedure
}
override fun enterTan(customer: CustomerData, tanChallenge: TanChallenge): EnterTanResult {
return EnterTanResult.userDidNotEnterTan()
}
override fun enterTanGeneratorAtc(customer: CustomerData, tanMedium: TanGeneratorTanMedium): EnterTanGeneratorAtcResult {
return EnterTanGeneratorAtcResult.userDidNotEnterTan()
}
}

View File

@ -0,0 +1,27 @@
package net.dankito.fints.callback
import net.dankito.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium
import net.dankito.fints.model.*
open class SimpleFinTsClientCallback(
protected val enterTan: ((customer: CustomerData, tanChallenge: TanChallenge) -> EnterTanResult)? = null,
protected val enterTanGeneratorAtc: ((customer: CustomerData, tanMedium: TanGeneratorTanMedium) -> EnterTanGeneratorAtcResult)? = null,
protected val askUserForTanProcedure: ((supportedTanProcedures: List<TanProcedure>, suggestedTanProcedure: TanProcedure?) -> TanProcedure?)? = null
) : FinTsClientCallback {
override fun askUserForTanProcedure(supportedTanProcedures: List<TanProcedure>,
suggestedTanProcedure: TanProcedure?): TanProcedure? {
return askUserForTanProcedure?.invoke(supportedTanProcedures, suggestedTanProcedure) ?: suggestedTanProcedure
}
override fun enterTan(customer: CustomerData, tanChallenge: TanChallenge): EnterTanResult {
return enterTan?.invoke(customer, tanChallenge) ?: EnterTanResult.userDidNotEnterTan()
}
override fun enterTanGeneratorAtc(customer: CustomerData, tanMedium: TanGeneratorTanMedium): EnterTanGeneratorAtcResult {
return enterTanGeneratorAtc?.invoke(customer, tanMedium) ?: EnterTanGeneratorAtcResult.userDidNotEnterTan()
}
}