Fixed that some banks encode SmsAbbuchungskontoErforderlich and as boolean values
This commit is contained in:
parent
f6c0805ea7
commit
1a0df93e0c
|
@ -367,8 +367,8 @@ open class ResponseParser @JvmOverloads constructor(
|
||||||
parseCodeEnum(procedureDataElements[11], TanZeitUndDialogbezug.values()),
|
parseCodeEnum(procedureDataElements[11], TanZeitUndDialogbezug.values()),
|
||||||
// for HITANS 4 and 5 here is another "TAN-Listennummer erforderlich" code element
|
// for HITANS 4 and 5 here is another "TAN-Listennummer erforderlich" code element
|
||||||
parseBoolean(procedureDataElements[12]),
|
parseBoolean(procedureDataElements[12]),
|
||||||
parseCodeEnum(procedureDataElements[13], SmsAbbuchungskontoErforderlich.values()),
|
tryToParseSmsAbbuchungskontoErforderlich(procedureDataElements[13]),
|
||||||
parseCodeEnum(procedureDataElements[14], AuftraggeberkontoErforderlich.values()),
|
tryToParseAuftraggeberkontoErforderlich(procedureDataElements[14]),
|
||||||
parseBoolean(procedureDataElements[15]),
|
parseBoolean(procedureDataElements[15]),
|
||||||
parseBoolean(procedureDataElements[16]),
|
parseBoolean(procedureDataElements[16]),
|
||||||
parseCodeEnum(procedureDataElements[17], Initialisierungsmodus.values()),
|
parseCodeEnum(procedureDataElements[17], Initialisierungsmodus.values()),
|
||||||
|
@ -386,6 +386,47 @@ open class ResponseParser @JvmOverloads constructor(
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected open fun tryToParseSmsAbbuchungskontoErforderlich(smsAbbuchungskontoErforderlichString: String): SmsAbbuchungskontoErforderlich {
|
||||||
|
try {
|
||||||
|
return parseCodeEnum(smsAbbuchungskontoErforderlichString, SmsAbbuchungskontoErforderlich.values())
|
||||||
|
} catch (e: Exception) {
|
||||||
|
log.error("Could not parse '$smsAbbuchungskontoErforderlichString' to SmsAbbuchungskontoErforderlich", e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bankhaus Neelmeyer and Oldenburgische Landesbank encode SmsAbbuchungskontoErforderlich with boolean values (with is wrong according to FinTS standard)
|
||||||
|
return tryToParseEnumAsBoolean(smsAbbuchungskontoErforderlichString,
|
||||||
|
SmsAbbuchungskontoErforderlich.SmsAbbuchungskontoMussAngegebenWerden,
|
||||||
|
SmsAbbuchungskontoErforderlich.SmsAbbuchungskontoDarfNichtAngegebenWerden)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected open fun tryToParseAuftraggeberkontoErforderlich(auftraggeberkontoErforderlichString: String): AuftraggeberkontoErforderlich {
|
||||||
|
try {
|
||||||
|
return parseCodeEnum(auftraggeberkontoErforderlichString, AuftraggeberkontoErforderlich.values())
|
||||||
|
} catch (e: Exception) {
|
||||||
|
log.error("Could not parse '$auftraggeberkontoErforderlichString' to AuftraggeberkontoErforderlich", e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bankhaus Neelmeyer and Oldenburgische Landesbank encode AuftraggeberkontoErforderlich with boolean values (with is wrong according to FinTS standard)
|
||||||
|
return tryToParseEnumAsBoolean(auftraggeberkontoErforderlichString,
|
||||||
|
AuftraggeberkontoErforderlich.AuftraggeberkontoMussAngegebenWerdenWennImGeschaeftsvorfallEnthalten,
|
||||||
|
AuftraggeberkontoErforderlich.AuftraggeberkontoDarfNichtAngegebenWerden)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected open fun <T : Enum<T>> tryToParseEnumAsBoolean(enumString: String, valueForTrue: T, valueForFalse: T): T {
|
||||||
|
try {
|
||||||
|
val bool = parseBoolean(enumString)
|
||||||
|
|
||||||
|
return if (bool) {
|
||||||
|
valueForTrue
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
valueForFalse
|
||||||
|
}
|
||||||
|
} catch (e: Exception) { }
|
||||||
|
|
||||||
|
return valueForFalse
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected open fun parseTanResponse(segment: String, dataElementGroups: List<String>): TanResponse {
|
protected open fun parseTanResponse(segment: String, dataElementGroups: List<String>): TanResponse {
|
||||||
val binaryJobHashValue = if (dataElementGroups.size > 2) parseStringToNullIfEmpty(dataElementGroups[2]) else null
|
val binaryJobHashValue = if (dataElementGroups.size > 2) parseStringToNullIfEmpty(dataElementGroups[2]) else null
|
||||||
|
|
|
@ -682,6 +682,30 @@ class ResponseParserTest : FinTsTestBase() {
|
||||||
?: run { Assert.fail("No segment of type TanInfo found in ${result.receivedSegments}") }
|
?: run { Assert.fail("No segment of type TanInfo found in ${result.receivedSegments}") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun parseTanInfo_SmsAbbuchungskontoErforderlichAnduftraggeberkontoErforderlichAreEncodedAsBoolean() {
|
||||||
|
|
||||||
|
// when
|
||||||
|
val result = underTest.parse("HITANS:56:6:3+1+1+1+N:N:0:901:2:CR#1:::SMS-TAN:6:1:SMS-TAN:256:J:2:J:J:N:N:N:01:1:N:1:904:2:CR#5 - 1.4:HHDOPT1:1.4:chipTAN comfort:6:1:chipTAN comfort:2048:N:1:N:0:0:N:N:01:0:N:1:905:2:CR#6 - 1.4:HHD:1.4:chipTAN comfort manuell:6:1:chipTAN comfort manuell:2048:N:1:N:0:0:N:N:01:0:N:0:906:2:CR#8 - MS1.0:::BV AppTAN:6:1:BV AppTAN:2048:N:1:N:0:0:N:N:01:0:N:0:907:2:CR#7:::PhotoTAN:7:1:PhotoTAN:2048:N:1:N:N:N:N:J:01:1:N:0'")
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertSuccessfullyParsedSegment(result, InstituteSegmentId.TanInfo, 56, 6, 3)
|
||||||
|
|
||||||
|
result.getFirstSegmentById<TanInfo>(InstituteSegmentId.TanInfo)?.let { segment ->
|
||||||
|
assertThat(segment.maxCountJobs).isEqualTo(1)
|
||||||
|
assertThat(segment.minimumCountSignatures).isEqualTo(1)
|
||||||
|
assertThat(segment.securityClass).isEqualTo(1)
|
||||||
|
assertThat(segment.tanProcedureParameters.oneStepProcedureAllowed).isFalse()
|
||||||
|
assertThat(segment.tanProcedureParameters.moreThanOneTanDependentJobPerMessageAllowed).isFalse()
|
||||||
|
assertThat(segment.tanProcedureParameters.jobHashValue).isEqualTo("0")
|
||||||
|
|
||||||
|
assertThat(segment.tanProcedureParameters.procedureParameters).hasSize(5)
|
||||||
|
assertThat(segment.tanProcedureParameters.procedureParameters).extracting("procedureName")
|
||||||
|
.containsExactlyInAnyOrder("SMS-TAN", "chipTAN comfort", "chipTAN comfort manuell", "BV AppTAN", "PhotoTAN")
|
||||||
|
}
|
||||||
|
?: run { Assert.fail("No segment of type TanInfo found in ${result.receivedSegments}") }
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun parseTanInfo7_NewAppBasedProcedure() {
|
fun parseTanInfo7_NewAppBasedProcedure() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue