diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt index 3f23635b..d34ddeb8 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt @@ -148,7 +148,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg protected open fun signPayload(headerSegmentNumber: Int, bank: BankData, customer: CustomerData, date: Int, time: Int, payloadSegments: List): List { - val controlReference = Math.abs(ThreadLocalRandom.current().nextInt()).toString() + val controlReference = createControlReference() val signatureHeader = PinTanSignaturkopf( headerSegmentNumber, @@ -168,6 +168,10 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg return listOf(signatureHeader, *payloadSegments.toTypedArray(), signatureEnding) } + protected open fun createControlReference(): String { + return Math.abs(ThreadLocalRandom.current().nextInt()).toString() + } + private fun encryptPayload(bank: BankData, customer: CustomerData, date: Int, time: Int, payload: List): List { diff --git a/fints4javaLib/src/test/kotlin/net/dankito/fints/messages/MessageBuilderTest.kt b/fints4javaLib/src/test/kotlin/net/dankito/fints/messages/MessageBuilderTest.kt index 7e1bd9a6..7caf8018 100644 --- a/fints4javaLib/src/test/kotlin/net/dankito/fints/messages/MessageBuilderTest.kt +++ b/fints4javaLib/src/test/kotlin/net/dankito/fints/messages/MessageBuilderTest.kt @@ -10,7 +10,7 @@ import java.util.* class MessageBuilderTest : FinTsTestBase() { - private val underTest = MessageBuilder(utils = object : FinTsUtils() { + private val underTest = object : MessageBuilder(utils = object : FinTsUtils() { override fun formatDate(date: Date): String { return Date.toString() } @@ -18,7 +18,13 @@ class MessageBuilderTest : FinTsTestBase() { override fun formatTime(time: Date): String { return Time.toString() } - }) + }) { + + override fun createControlReference(): String { + return ControlReference + } + + } @Test