Implemented sending tan in Signaturabschluss (BenutzerdefinitereSignatur

This commit is contained in:
dankl 2019-10-25 23:55:04 +02:00 committed by dankito
parent a13fa0dcea
commit 733a262628
4 changed files with 20 additions and 9 deletions

View File

@ -154,10 +154,16 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
open fun createSignedMessage(bank: BankData, customer: CustomerData, dialogData: DialogData,
payloadSegments: List<Segment>): String {
return createSignedMessage(bank, customer, dialogData, null, payloadSegments)
}
open fun createSignedMessage(bank: BankData, customer: CustomerData, dialogData: DialogData,
tan: String? = null, payloadSegments: List<Segment>): String {
val date = utils.formatDateTodayAsInt()
val time = utils.formatTimeNowAsInt()
val signedPayload = signPayload(2, bank, customer, date, time, payloadSegments)
val signedPayload = signPayload(2, bank, customer, date, time, tan, payloadSegments)
val encryptedPayload = encryptPayload(bank, customer, date, time, signedPayload)
@ -181,7 +187,8 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
protected open fun signPayload(headerSegmentNumber: Int, bank: BankData, customer: CustomerData, date: Int, time: Int,
payloadSegments: List<Segment>): List<Segment> {
tan: String? = null, payloadSegments: List<Segment>): List<Segment> {
val controlReference = createControlReference()
val signatureHeader = PinTanSignaturkopf(
@ -196,7 +203,8 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
val signatureEnding = Signaturabschluss(
generator.getNextSegmentNumber(),
controlReference,
customer.pin
customer.pin,
tan
)
return listOf(signatureHeader, *payloadSegments.toTypedArray(), signatureEnding)

View File

@ -4,4 +4,5 @@ import net.dankito.fints.messages.Existenzstatus
import net.dankito.fints.messages.datenelemente.basisformate.AlphanumerischesDatenelement
open class PinOrTan(pinOrTan: String) : AlphanumerischesDatenelement(pinOrTan, Existenzstatus.Mandatory)
open class PinOrTan(pinOrTan: String?, existenzstatus: Existenzstatus)
: AlphanumerischesDatenelement(pinOrTan, existenzstatus, 99)

View File

@ -30,7 +30,8 @@ import net.dankito.fints.messages.datenelementgruppen.Datenelementgruppe
* des Sicherheitsverfahrens HBCI darf die DEG nicht belegt werden. Ihr Inhalt wird
* in diesem Fall ignoriert.
*/
open class BenutzerdefinierteSignatur(pinOrTan: String)
open class BenutzerdefinierteSignatur @JvmOverloads constructor(pin: String, tan: String? = null)
: Datenelementgruppe(listOf(
PinOrTan(pinOrTan)
PinOrTan(pin, Existenzstatus.Mandatory),
PinOrTan(tan, Existenzstatus.Optional)
), Existenzstatus.Mandatory)

View File

@ -12,14 +12,15 @@ import net.dankito.fints.messages.segmente.id.MessageSegmentId
* Der Signaturabschluss stellt die Verbindung mit dem dazugehörigen Signaturkopf
* her und enthält als "Validierungsresultat" die elektronische Signatur.
*/
open class Signaturabschluss(
open class Signaturabschluss @JvmOverloads constructor(
segmentNumber: Int,
securityControlReference: String,
pinOrTan: String
pin: String,
tan: String? = null
)
: Segment(listOf(
Segmentkopf(MessageSegmentId.SignatureEnding, 2, segmentNumber),
Sicherheitskontrollreferenz(securityControlReference), // has to be the same as in Signaturkopf
NotAllowedDatenelement(), // only used for HBCI, not allowed for PIN/TAN
BenutzerdefinierteSignatur(pinOrTan)
BenutzerdefinierteSignatur(pin, tan)
))