Checking now all responses if a TAN is required and if if contains a continuation ID (Aufsetzpunkt)
This commit is contained in:
parent
3d54bed50d
commit
bfdb3833a6
|
@ -101,7 +101,7 @@ open class FinTsClient @JvmOverloads constructor(
|
|||
|
||||
val dialogEndRequestBody = messageBuilder.createAnonymousDialogEndMessage(dialogContext)
|
||||
|
||||
getAndHandleResponseForMessage(dialogEndRequestBody, dialogContext)
|
||||
getAndHandleResponseForMessage(dialogEndRequestBody, dialogContext) // TODO: really handle close dialog response?
|
||||
}
|
||||
|
||||
|
||||
|
@ -143,7 +143,7 @@ open class FinTsClient @JvmOverloads constructor(
|
|||
val dialogContext = DialogContext(bank, customer, product)
|
||||
val message = messageBuilder.createSynchronizeCustomerSystemIdMessage(dialogContext)
|
||||
|
||||
val response = getAndHandleResponseForMessage(message, dialogContext) // TODO: HKSYN also contains HKTAN -> get..ThatMayRequiresTan()
|
||||
val response = getAndHandleResponseForMessage(message, dialogContext)
|
||||
|
||||
if (response.successful) {
|
||||
updateBankData(bank, response)
|
||||
|
@ -293,7 +293,7 @@ open class FinTsClient @JvmOverloads constructor(
|
|||
|
||||
val message = messageBuilder.createGetTransactionsMessage(parameter, account, dialogContext)
|
||||
|
||||
val response = getAndHandleResponseForMessageThatMayRequiresTan(message, dialogContext)
|
||||
val response = getAndHandleResponseForMessage(message, dialogContext)
|
||||
|
||||
closeDialog(dialogContext)
|
||||
|
||||
|
@ -438,8 +438,7 @@ open class FinTsClient @JvmOverloads constructor(
|
|||
|
||||
val message = createMessage(dialogContext)
|
||||
|
||||
val response = if (messageMayRequiresTan) getAndHandleResponseForMessageThatMayRequiresTan(message, dialogContext)
|
||||
else getAndHandleResponseForMessage(message, dialogContext)
|
||||
val response = getAndHandleResponseForMessage(message, dialogContext)
|
||||
|
||||
closeDialog(dialogContext)
|
||||
|
||||
|
@ -470,7 +469,7 @@ open class FinTsClient @JvmOverloads constructor(
|
|||
|
||||
val message = messageBuilder.createInitDialogMessage(dialogContext, useStrongAuthentication)
|
||||
|
||||
val response = GetUserTanProceduresResponse(getAndHandleResponseForMessageThatMayRequiresTan(message, dialogContext))
|
||||
val response = GetUserTanProceduresResponse(getAndHandleResponseForMessage(message, dialogContext))
|
||||
dialogContext.response = response
|
||||
|
||||
if (response.successful) {
|
||||
|
@ -485,7 +484,7 @@ open class FinTsClient @JvmOverloads constructor(
|
|||
|
||||
val dialogEndRequestBody = messageBuilder.createDialogEndMessage(dialogContext)
|
||||
|
||||
getAndHandleResponseForMessage(dialogEndRequestBody, dialogContext)
|
||||
getAndHandleResponseForMessage(dialogEndRequestBody, dialogContext) // TODO: really handle close dialog response?
|
||||
}
|
||||
|
||||
|
||||
|
@ -534,8 +533,9 @@ open class FinTsClient @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
|
||||
protected open fun getAndHandleResponseForMessageThatMayRequiresTan(message: MessageBuilderResult, dialogContext: DialogContext): Response {
|
||||
val response = getAndHandleResponseForMessage(message, dialogContext)
|
||||
protected open fun getAndHandleResponseForMessage(message: MessageBuilderResult, dialogContext: DialogContext): Response {
|
||||
val response = if (message.createdMessage == null) Response(false, messageCreationError = message)
|
||||
else getAndHandleResponseForMessage(message.createdMessage, dialogContext)
|
||||
|
||||
val handledResponse = handleMayRequiredTan(response, dialogContext)
|
||||
|
||||
|
@ -551,30 +551,6 @@ open class FinTsClient @JvmOverloads constructor(
|
|||
return handledResponse
|
||||
}
|
||||
|
||||
protected open fun getFollowUpMessageForContinuationId(response: Response, continuationId: String, message: MessageBuilderResult,
|
||||
dialogContext: DialogContext): Response? {
|
||||
|
||||
messageBuilder.rebuildMessageWithContinuationId(message, continuationId, dialogContext)?.let { followUpMessage ->
|
||||
return getAndHandleResponseForMessageThatMayRequiresTan(followUpMessage, dialogContext)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
protected open fun getAndHandleResponseForMessageThatMayRequiresTan(message: String, dialogContext: DialogContext): Response {
|
||||
val response = getAndHandleResponseForMessage(message, dialogContext)
|
||||
|
||||
return handleMayRequiredTan(response, dialogContext)
|
||||
}
|
||||
|
||||
protected open fun getAndHandleResponseForMessage(message: MessageBuilderResult, dialogContext: DialogContext): Response {
|
||||
message.createdMessage?.let { requestBody ->
|
||||
return getAndHandleResponseForMessage(requestBody, dialogContext)
|
||||
}
|
||||
|
||||
return Response(false, messageCreationError = message)
|
||||
}
|
||||
|
||||
protected open fun getAndHandleResponseForMessage(requestBody: String, dialogContext: DialogContext): Response {
|
||||
addMessageLog(requestBody, MessageLogEntryType.Sent, dialogContext)
|
||||
|
||||
|
@ -627,6 +603,17 @@ open class FinTsClient @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
|
||||
protected open fun getFollowUpMessageForContinuationId(response: Response, continuationId: String, message: MessageBuilderResult,
|
||||
dialogContext: DialogContext): Response? {
|
||||
|
||||
messageBuilder.rebuildMessageWithContinuationId(message, continuationId, dialogContext)?.let { followUpMessage ->
|
||||
return getAndHandleResponseForMessage(followUpMessage, dialogContext)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
protected open fun addMessageLog(message: String, type: MessageLogEntryType, dialogContext: DialogContext) {
|
||||
val timeStamp = Date()
|
||||
val prettyPrintMessage = prettyPrintHbciMessage(message)
|
||||
|
@ -729,8 +716,7 @@ open class FinTsClient @JvmOverloads constructor(
|
|||
|
||||
val message = messageBuilder.createSendEnteredTanMessage(enteredTan, tanResponse, dialogContext)
|
||||
|
||||
// TODO: shouldn't we use MessageBuilderResult here as well?
|
||||
return getAndHandleResponseForMessageThatMayRequiresTan(message, dialogContext)
|
||||
return getAndHandleResponseForMessage(message, dialogContext)
|
||||
}
|
||||
|
||||
protected open fun handleUserAsksToChangeTanProcedureAndResendLastMessage(changeTanProcedureTo: TanProcedure, dialogContext: DialogContext): Response {
|
||||
|
@ -780,7 +766,7 @@ open class FinTsClient @JvmOverloads constructor(
|
|||
|
||||
val newMessage = messageBuilder.rebuildMessage(lastCreatedMessage, newDialogContext)
|
||||
|
||||
val response = getAndHandleResponseForMessageThatMayRequiresTan(newMessage, newDialogContext)
|
||||
val response = getAndHandleResponseForMessage(newMessage, newDialogContext)
|
||||
|
||||
closeDialog(newDialogContext)
|
||||
|
||||
|
|
|
@ -55,9 +55,9 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
))
|
||||
}
|
||||
|
||||
open fun createAnonymousDialogEndMessage(dialogContext: DialogContext): String {
|
||||
open fun createAnonymousDialogEndMessage(dialogContext: DialogContext): MessageBuilderResult {
|
||||
|
||||
return createMessage(dialogContext, listOf(
|
||||
return createUnsignedMessageBuilderResult(dialogContext, listOf(
|
||||
Dialogende(generator.resetSegmentNumber(1), dialogContext)
|
||||
))
|
||||
}
|
||||
|
@ -74,12 +74,12 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
segments.add(ZweiSchrittTanEinreichung(generator.getNextSegmentNumber(), TanProcess.TanProcess4, CustomerSegmentId.Identification))
|
||||
}
|
||||
|
||||
return createMessageBuilderResult(dialogContext, segments)
|
||||
return createSignedMessageBuilderResult(dialogContext, segments)
|
||||
}
|
||||
|
||||
open fun createSynchronizeCustomerSystemIdMessage(dialogContext: DialogContext): MessageBuilderResult {
|
||||
|
||||
return createMessageBuilderResult(dialogContext, listOf(
|
||||
return createSignedMessageBuilderResult(dialogContext, listOf(
|
||||
IdentifikationsSegment(generator.resetSegmentNumber(2), dialogContext),
|
||||
Verarbeitungsvorbereitung(generator.getNextSegmentNumber(), dialogContext),
|
||||
ZweiSchrittTanEinreichung(generator.getNextSegmentNumber(), TanProcess.TanProcess4, CustomerSegmentId.Identification),
|
||||
|
@ -87,9 +87,9 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
))
|
||||
}
|
||||
|
||||
open fun createDialogEndMessage(dialogContext: DialogContext): String {
|
||||
open fun createDialogEndMessage(dialogContext: DialogContext): MessageBuilderResult {
|
||||
|
||||
return createSignedMessage(dialogContext, listOf(
|
||||
return createSignedMessageBuilderResult(dialogContext, listOf(
|
||||
Dialogende(generator.resetSegmentNumber(2), dialogContext)
|
||||
))
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
|
||||
addTanSegmentIfRequired(CustomerSegmentId.AccountTransactionsMt940, dialogContext, segments)
|
||||
|
||||
return createMessageBuilderResult(dialogContext, segments)
|
||||
return createSignedMessageBuilderResult(dialogContext, segments)
|
||||
}
|
||||
|
||||
return result
|
||||
|
@ -136,7 +136,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
|
||||
addTanSegmentIfRequired(CustomerSegmentId.Balance, dialogContext, segments)
|
||||
|
||||
return createMessageBuilderResult(dialogContext, segments)
|
||||
return createSignedMessageBuilderResult(dialogContext, segments)
|
||||
}
|
||||
|
||||
return result
|
||||
|
@ -163,7 +163,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
generator.resetSegmentNumber(2), tanMediaKind, tanMediumClass)
|
||||
)
|
||||
|
||||
return createMessageBuilderResult(dialogContext, segments)
|
||||
return createSignedMessageBuilderResult(dialogContext, segments)
|
||||
}
|
||||
|
||||
return result
|
||||
|
@ -180,20 +180,22 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
dialogContext.bank, dialogContext.customer, newActiveTanMedium, tan, atc)
|
||||
)
|
||||
|
||||
return createMessageBuilderResult(dialogContext, segments)
|
||||
return createSignedMessageBuilderResult(dialogContext, segments)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
open fun createSendEnteredTanMessage(enteredTan: String, tanResponse: TanResponse, dialogContext: DialogContext): String {
|
||||
open fun createSendEnteredTanMessage(enteredTan: String, tanResponse: TanResponse, dialogContext: DialogContext): MessageBuilderResult {
|
||||
|
||||
val tanProcess = if (tanResponse.tanProcess == TanProcess.TanProcess1) TanProcess.TanProcess1 else TanProcess.TanProcess2
|
||||
|
||||
return createSignedMessage(dialogContext, enteredTan, listOf(
|
||||
val segments = listOf(
|
||||
ZweiSchrittTanEinreichung(generator.resetSegmentNumber(2), tanProcess, null,
|
||||
tanResponse.jobHashValue, tanResponse.jobReference, false, null, tanResponse.tanMediaIdentifier)
|
||||
))
|
||||
)
|
||||
|
||||
return createSignedMessageBuilderResult(createSignedMessage(dialogContext, enteredTan, segments), dialogContext, segments)
|
||||
}
|
||||
|
||||
|
||||
|
@ -211,7 +213,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
|
||||
addTanSegmentIfRequired(segmentId, dialogContext, segments)
|
||||
|
||||
return createMessageBuilderResult(dialogContext, segments)
|
||||
return createSignedMessageBuilderResult(dialogContext, segments)
|
||||
}
|
||||
|
||||
return result
|
||||
|
@ -264,11 +266,15 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
|
||||
dialogContext.increaseMessageNumber()
|
||||
|
||||
return createMessageBuilderResult(dialogContext, message.messageBodySegments)
|
||||
return createSignedMessageBuilderResult(dialogContext, message.messageBodySegments)
|
||||
}
|
||||
|
||||
protected open fun createMessageBuilderResult(dialogContext: DialogContext, segments: List<Segment>): MessageBuilderResult {
|
||||
val message = MessageBuilderResult(createSignedMessage(dialogContext, segments), segments)
|
||||
protected open fun createSignedMessageBuilderResult(dialogContext: DialogContext, segments: List<Segment>): MessageBuilderResult {
|
||||
return createSignedMessageBuilderResult(createSignedMessage(dialogContext, segments), dialogContext, segments)
|
||||
}
|
||||
|
||||
protected open fun createSignedMessageBuilderResult(createdMessage: String, dialogContext: DialogContext, segments: List<Segment>): MessageBuilderResult {
|
||||
val message = MessageBuilderResult(createdMessage, segments)
|
||||
|
||||
dialogContext.previousMessageInDialog = dialogContext.currentMessage
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import net.dankito.fints.FinTsClient
|
|||
import net.dankito.fints.banks.InMemoryBankFinder
|
||||
import net.dankito.fints.callback.NoOpFinTsClientCallback
|
||||
import net.dankito.fints.messages.MessageBuilder
|
||||
import net.dankito.fints.messages.MessageBuilderResult
|
||||
import net.dankito.fints.messages.Separators
|
||||
import net.dankito.fints.messages.datenelemente.implementierte.Dialogsprache
|
||||
import net.dankito.fints.model.*
|
||||
|
@ -44,8 +45,8 @@ class BanksFinTsDetailsRetriever {
|
|||
|
||||
private val finTsClient = object : FinTsClient(NoOpFinTsClientCallback(), Java8Base64Service()) {
|
||||
|
||||
fun getAndHandleResponseForMessagePublic(requestBody: String, dialogContext: DialogContext): Response {
|
||||
return getAndHandleResponseForMessage(requestBody, dialogContext)
|
||||
fun getAndHandleResponseForMessagePublic(message: MessageBuilderResult, dialogContext: DialogContext): Response {
|
||||
return getAndHandleResponseForMessage(message, dialogContext)
|
||||
}
|
||||
|
||||
fun updateBankDataPublic(bank: BankData, response: Response) {
|
||||
|
@ -110,7 +111,7 @@ class BanksFinTsDetailsRetriever {
|
|||
|
||||
private fun getAnonymousBankInfo(bank: BankData): Response {
|
||||
val dialogContext = DialogContext(bank, CustomerData.Anonymous, product)
|
||||
val requestBody = messageBuilder.createAnonymousDialogInitMessage(dialogContext).createdMessage ?: ""
|
||||
val requestBody = messageBuilder.createAnonymousDialogInitMessage(dialogContext)
|
||||
|
||||
val anonymousBankInfoResponse =
|
||||
finTsClient.getAndHandleResponseForMessagePublic(requestBody, dialogContext)
|
||||
|
|
|
@ -65,7 +65,7 @@ class MessageBuilderTest : FinTsTestBase() {
|
|||
val dialogContext = DialogContext(Bank, Customer, Product, null, dialogId)
|
||||
|
||||
// when
|
||||
val result = underTest.createAnonymousDialogEndMessage(dialogContext)
|
||||
val result = underTest.createAnonymousDialogEndMessage(dialogContext).createdMessage ?: ""
|
||||
|
||||
// then
|
||||
assertThat(normalizeBinaryData(result)).isEqualTo(normalizeBinaryData(
|
||||
|
@ -107,7 +107,7 @@ class MessageBuilderTest : FinTsTestBase() {
|
|||
val dialogContext = DialogContext(Bank, Customer, Product, null, dialogId)
|
||||
|
||||
// when
|
||||
val result = underTest.createDialogEndMessage(dialogContext)
|
||||
val result = underTest.createDialogEndMessage(dialogContext).createdMessage ?: ""
|
||||
|
||||
// then
|
||||
assertThat(normalizeBinaryData(result)).isEqualTo(normalizeBinaryData(
|
||||
|
|
Loading…
Reference in New Issue