From 0f151a8f4f556ce6dba883af6962d2ca15c2c44f Mon Sep 17 00:00:00 2001 From: dankito Date: Fri, 23 Aug 2024 23:27:58 +0200 Subject: [PATCH] Extracted jobsRequiringTan --- .../banking/fints/messages/MessageBuilder.kt | 3 +-- .../net/codinux/banking/fints/model/BankData.kt | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/messages/MessageBuilder.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/messages/MessageBuilder.kt index 98fb19cf..13dec500 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/messages/MessageBuilder.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/messages/MessageBuilder.kt @@ -536,8 +536,7 @@ open class MessageBuilder(protected val utils: FinTsUtils = FinTsUtils()) { } protected open fun isTanRequiredForJob(context: JobContext, segmentId: CustomerSegmentId): Boolean { - return context.bank.pinInfo?.jobTanConfiguration?.first { it.segmentId == segmentId.id }?.tanRequired - ?: false // TODO: actually in this case it's not allowed to execute job via PIN/TAN at all + return context.bank.doesJobRequireTan(segmentId) } protected open fun getSepaUrnFor(segmentId: CustomerSegmentId, bank: BankData, sepaDataFormat: String): String? { diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/BankData.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/BankData.kt index f1176c66..58f6fb41 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/BankData.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/model/BankData.kt @@ -4,6 +4,7 @@ import net.codinux.banking.fints.messages.datenelemente.abgeleiteteformate.Laend import net.codinux.banking.fints.messages.datenelemente.implementierte.* import net.codinux.banking.fints.messages.datenelemente.implementierte.signatur.Sicherheitsfunktion import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMedium +import net.codinux.banking.fints.messages.segmente.id.ISegmentId import net.codinux.banking.fints.response.segments.ChangeTanMediaParameters import net.codinux.banking.fints.response.segments.JobParameters import net.codinux.banking.fints.response.segments.PinInfo @@ -30,7 +31,6 @@ open class BankData( open var tanMedia: List = listOf(), open var selectedTanMedium: TanMedium? = null, open var changeTanMediumParameters: ChangeTanMediaParameters? = null, - open var pinInfo: PinInfo? = null, open var supportedLanguages: List = listOf(), open var selectedLanguage: Dialogsprache = Dialogsprache.Default, @@ -82,6 +82,21 @@ open class BankData( } + open var jobsRequiringTan: Set = emptySet() + protected set + + open var pinInfo: PinInfo? = null + set(value) { + field = value + // TODO: in case of null: actually in this case it's not allowed to execute job via PIN/TAN at all + jobsRequiringTan = value?.jobTanConfiguration.orEmpty().filter { it.tanRequired }.map { it.segmentId }.toSet() + } + + open fun doesJobRequireTan(segmentId: ISegmentId): Boolean = doesJobRequireTan(segmentId.id) + + open fun doesJobRequireTan(segmentId: String): Boolean = + jobsRequiringTan.contains(segmentId) + /** * Some banks use a special bank code for online banking that doesn't match bank's bank code, e. g. Hypo Vereinsbank */