Added tanExpiredCallback, so that UI can react to when TAN expired
This commit is contained in:
parent
20f06387c5
commit
42bf002626
|
@ -392,7 +392,7 @@ open class FinTsJobExecutor(
|
||||||
// most TANs a valid 5 - 15 minutes. So terminate wait process after that time
|
// most TANs a valid 5 - 15 minutes. So terminate wait process after that time
|
||||||
(tanChallenge.tanExpirationTime == null && now > tanChallenge.challengeCreationTimestamp.plusMinutes(15))) {
|
(tanChallenge.tanExpirationTime == null && now > tanChallenge.challengeCreationTimestamp.plusMinutes(15))) {
|
||||||
if (tanChallenge.isEnteringTanDone == false) {
|
if (tanChallenge.isEnteringTanDone == false) {
|
||||||
tanChallenge.userDidNotEnterTan()
|
tanChallenge.tanExpired()
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
|
@ -478,6 +478,8 @@ open class FinTsJobExecutor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tanChallenge.tanExpired()
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import net.codinux.banking.fints.extensions.nowExt
|
||||||
import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMedium
|
import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMedium
|
||||||
import net.codinux.banking.fints.response.BankResponse
|
import net.codinux.banking.fints.response.BankResponse
|
||||||
import net.codinux.banking.fints.response.client.FinTsClientResponse
|
import net.codinux.banking.fints.response.client.FinTsClientResponse
|
||||||
|
import net.codinux.log.Log
|
||||||
|
|
||||||
|
|
||||||
open class TanChallenge(
|
open class TanChallenge(
|
||||||
|
@ -30,6 +31,8 @@ open class TanChallenge(
|
||||||
open val isEnteringTanDone: Boolean
|
open val isEnteringTanDone: Boolean
|
||||||
get() = enterTanResult != null
|
get() = enterTanResult != null
|
||||||
|
|
||||||
|
private val tanExpiredCallbacks = mutableListOf<() -> Unit>()
|
||||||
|
|
||||||
private val userApprovedDecoupledTanCallbacks = mutableListOf<() -> Unit>()
|
private val userApprovedDecoupledTanCallbacks = mutableListOf<() -> Unit>()
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +43,13 @@ open class TanChallenge(
|
||||||
internal fun userApprovedDecoupledTan(responseAfterApprovingDecoupledTan: BankResponse) {
|
internal fun userApprovedDecoupledTan(responseAfterApprovingDecoupledTan: BankResponse) {
|
||||||
this.enterTanResult = EnterTanResult(null, true, responseAfterApprovingDecoupledTan)
|
this.enterTanResult = EnterTanResult(null, true, responseAfterApprovingDecoupledTan)
|
||||||
|
|
||||||
userApprovedDecoupledTanCallbacks.forEach { it.invoke() }
|
userApprovedDecoupledTanCallbacks.forEach {
|
||||||
|
try {
|
||||||
|
it.invoke()
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
Log.error(e) { "Could not call userApprovedDecoupledTanCallback" }
|
||||||
|
}
|
||||||
|
}
|
||||||
clearUserApprovedDecoupledTanCallbacks()
|
clearUserApprovedDecoupledTanCallbacks()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +59,20 @@ open class TanChallenge(
|
||||||
this.enterTanResult = EnterTanResult(null)
|
this.enterTanResult = EnterTanResult(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun tanExpired() {
|
||||||
|
tanExpiredCallbacks.forEach {
|
||||||
|
try {
|
||||||
|
it.invoke()
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
Log.error(e) { "Could not call tanExpiredCallback" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clearTanExpiredCallbacks()
|
||||||
|
|
||||||
|
userDidNotEnterTan()
|
||||||
|
}
|
||||||
|
|
||||||
fun userAsksToChangeTanMethod(changeTanMethodTo: TanMethod) {
|
fun userAsksToChangeTanMethod(changeTanMethodTo: TanMethod) {
|
||||||
clearUserApprovedDecoupledTanCallbacks()
|
clearUserApprovedDecoupledTanCallbacks()
|
||||||
|
|
||||||
|
@ -63,6 +86,16 @@ open class TanChallenge(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun addTanExpiredCallback(callback: () -> Unit) {
|
||||||
|
if (isEnteringTanDone == false) {
|
||||||
|
this.tanExpiredCallbacks.add(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected open fun clearTanExpiredCallbacks() {
|
||||||
|
tanExpiredCallbacks.clear()
|
||||||
|
}
|
||||||
|
|
||||||
fun addUserApprovedDecoupledTanCallback(callback: () -> Unit) {
|
fun addUserApprovedDecoupledTanCallback(callback: () -> Unit) {
|
||||||
if (isEnteringTanDone == false) {
|
if (isEnteringTanDone == false) {
|
||||||
this.userApprovedDecoupledTanCallbacks.add(callback)
|
this.userApprovedDecoupledTanCallbacks.add(callback)
|
||||||
|
|
Loading…
Reference in New Issue