Extracted jobsRequiringTan

This commit is contained in:
dankito 2024-08-23 23:27:58 +02:00
parent 33a86607df
commit 0f151a8f4f
2 changed files with 17 additions and 3 deletions

View File

@ -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? {

View File

@ -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<TanMedium> = listOf(),
open var selectedTanMedium: TanMedium? = null,
open var changeTanMediumParameters: ChangeTanMediaParameters? = null,
open var pinInfo: PinInfo? = null,
open var supportedLanguages: List<Dialogsprache> = listOf(),
open var selectedLanguage: Dialogsprache = Dialogsprache.Default,
@ -82,6 +82,21 @@ open class BankData(
}
open var jobsRequiringTan: Set<String> = 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
*/