From de8b2d5bd905c7742ac15c0a06bba25b986e8bc2 Mon Sep 17 00:00:00 2001 From: dankito Date: Sat, 16 May 2020 20:03:32 +0200 Subject: [PATCH] Implemented removing account transactions from response for message log --- .../main/kotlin/net/dankito/fints/FinTsClient.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt index d8f8980e..b0ba1c3c 100644 --- a/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -52,6 +52,10 @@ open class FinTsClient @JvmOverloads constructor( companion object { const val NinetyDaysAgoMilliseconds = 90 * 24 * 60 * 60 * 1000L + val FindAccountTransactionsStartRegex = Regex("^HIKAZ:\\d:\\d:\\d\\+@\\d+@", RegexOption.MULTILINE) + val FindAccountTransactionsEndRegex = Regex("^-'", RegexOption.MULTILINE) + + private val log = LoggerFactory.getLogger(FinTsClient::class.java) } @@ -676,9 +680,17 @@ open class FinTsClient @JvmOverloads constructor( } } - // TODO: remove account transactions + return removeAccountTransactions(prettyPrintMessageWithoutSensitiveData) + } - return prettyPrintMessageWithoutSensitiveData + protected open fun removeAccountTransactions(message: String): String { + FindAccountTransactionsStartRegex.find(message)?.let { startMatchResult -> + FindAccountTransactionsEndRegex.find(message, startMatchResult.range.endInclusive)?.let { endMatchResult -> + return message.replaceRange(IntRange(startMatchResult.range.endInclusive, endMatchResult.range.start), "") + } + } + + return message } protected fun prettyPrintHbciMessage(message: String): String {