Implemented parsing CommunicationInfo (HIKOM)
This commit is contained in:
parent
3afd257320
commit
def4e1f74e
|
@ -478,13 +478,18 @@ open class FinTsClient @JvmOverloads constructor(
|
||||||
bank.supportedLanguages = bankParameters.supportedLanguages
|
bank.supportedLanguages = bankParameters.supportedLanguages
|
||||||
|
|
||||||
// bank.bic = bankParameters. // TODO: where's the BIC?
|
// bank.bic = bankParameters. // TODO: where's the BIC?
|
||||||
// bank.finTs3ServerAddress = // TODO: parse HIKOM
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response.getFirstSegmentById<TanInfo>(InstituteSegmentId.TanInfo)?.let { tanInfo ->
|
response.getFirstSegmentById<TanInfo>(InstituteSegmentId.TanInfo)?.let { tanInfo ->
|
||||||
bank.supportedTanProcedures = mapToTanProcedures(tanInfo)
|
bank.supportedTanProcedures = mapToTanProcedures(tanInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response.getFirstSegmentById<CommunicationInfo>(InstituteSegmentId.CommunicationInfo)?.let { communicationInfo ->
|
||||||
|
communicationInfo.parameters.firstOrNull { it.type == Kommunikationsdienst.Https }?.address?.let { address ->
|
||||||
|
bank.finTs3ServerAddress = if (address.startsWith("https://", true)) address else "https://$address"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (response.supportedJobs.isNotEmpty()) {
|
if (response.supportedJobs.isNotEmpty()) {
|
||||||
bank.supportedJobs = response.supportedJobs
|
bank.supportedJobs = response.supportedJobs
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ enum class InstituteSegmentId(override val id: String) : ISegmentId {
|
||||||
|
|
||||||
SecurityMethods("HISHV"),
|
SecurityMethods("HISHV"),
|
||||||
|
|
||||||
|
CommunicationInfo("HIKOM"),
|
||||||
|
|
||||||
UserParameters("HIUPA"),
|
UserParameters("HIUPA"),
|
||||||
|
|
||||||
AccountInfo("HIUPD"),
|
AccountInfo("HIUPD"),
|
||||||
|
|
|
@ -83,6 +83,7 @@ open class ResponseParser @JvmOverloads constructor(
|
||||||
InstituteSegmentId.Synchronization.id -> parseSynchronization(segment, dataElementGroups)
|
InstituteSegmentId.Synchronization.id -> parseSynchronization(segment, dataElementGroups)
|
||||||
InstituteSegmentId.BankParameters.id -> parseBankParameters(segment, dataElementGroups)
|
InstituteSegmentId.BankParameters.id -> parseBankParameters(segment, dataElementGroups)
|
||||||
InstituteSegmentId.SecurityMethods.id -> parseSecurityMethods(segment, dataElementGroups)
|
InstituteSegmentId.SecurityMethods.id -> parseSecurityMethods(segment, dataElementGroups)
|
||||||
|
InstituteSegmentId.CommunicationInfo.id -> parseCommunicationInfo(segment, dataElementGroups)
|
||||||
|
|
||||||
InstituteSegmentId.UserParameters.id -> parseUserParameters(segment, dataElementGroups)
|
InstituteSegmentId.UserParameters.id -> parseUserParameters(segment, dataElementGroups)
|
||||||
InstituteSegmentId.AccountInfo.id -> parseAccountInfo(segment, dataElementGroups)
|
InstituteSegmentId.AccountInfo.id -> parseAccountInfo(segment, dataElementGroups)
|
||||||
|
@ -176,6 +177,25 @@ open class ResponseParser @JvmOverloads constructor(
|
||||||
return SecurityMethods(mixingAllowed, profiles, segment)
|
return SecurityMethods(mixingAllowed, profiles, segment)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected open fun parseCommunicationInfo(segment: String, dataElementGroups: List<String>): CommunicationInfo {
|
||||||
|
val bankDetails = parseBankDetails(dataElementGroups[1])
|
||||||
|
val defaultLanguage = parseLanguage(dataElementGroups[2])
|
||||||
|
val parameters = parseCommunicationParameters(dataElementGroups.subList(3, dataElementGroups.size))
|
||||||
|
|
||||||
|
return CommunicationInfo(bankDetails, defaultLanguage, parameters, segment)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected open fun parseCommunicationParameters(dataElementGroups: List<String>): List<CommunicationParameter> {
|
||||||
|
return dataElementGroups.map { dataElementGroup ->
|
||||||
|
val dataElements = getDataElements(dataElementGroup)
|
||||||
|
|
||||||
|
CommunicationParameter(
|
||||||
|
parseCodeEnum(dataElements[0], Kommunikationsdienst.values()),
|
||||||
|
dataElements[1]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected open fun parseUserParameters(segment: String, dataElementGroups: List<String>): UserParameters {
|
protected open fun parseUserParameters(segment: String, dataElementGroups: List<String>): UserParameters {
|
||||||
val customerId = parseString(dataElementGroups[1])
|
val customerId = parseString(dataElementGroups[1])
|
||||||
|
@ -388,9 +408,11 @@ open class ResponseParser @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun parseLanguages(dataElementsGroup: String): List<Dialogsprache> {
|
protected open fun parseLanguages(dataElementsGroup: String): List<Dialogsprache> {
|
||||||
val languageStrings = getDataElements(dataElementsGroup)
|
return getDataElements(dataElementsGroup).map { parseLanguage(it) }
|
||||||
|
}
|
||||||
|
|
||||||
return parseCodeEnum(languageStrings, Dialogsprache.values())
|
protected open fun parseLanguage(dataElementsGroup: String): Dialogsprache {
|
||||||
|
return parseCodeEnum(dataElementsGroup, Dialogsprache.values())
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun parseHbciVersions(dataElementsGroup: String): List<HbciVersion> {
|
protected open fun parseHbciVersions(dataElementsGroup: String): List<HbciVersion> {
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package net.dankito.fints.response.segments
|
||||||
|
|
||||||
|
import net.dankito.fints.messages.datenelemente.implementierte.Dialogsprache
|
||||||
|
import net.dankito.fints.messages.datenelementgruppen.implementierte.Kreditinstitutskennung
|
||||||
|
|
||||||
|
|
||||||
|
open class CommunicationInfo(
|
||||||
|
val bankInfo: Kreditinstitutskennung,
|
||||||
|
val defaultLanguage: Dialogsprache,
|
||||||
|
val parameters: List<CommunicationParameter>,
|
||||||
|
segmentString: String
|
||||||
|
)
|
||||||
|
: ReceivedSegment(segmentString)
|
|
@ -0,0 +1,31 @@
|
||||||
|
package net.dankito.fints.response.segments
|
||||||
|
|
||||||
|
|
||||||
|
open class CommunicationParameter(
|
||||||
|
val type: Kommunikationsdienst,
|
||||||
|
val address: String
|
||||||
|
) {
|
||||||
|
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (other !is CommunicationParameter) return false
|
||||||
|
|
||||||
|
if (type != other.type) return false
|
||||||
|
if (address != other.address) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = type.hashCode()
|
||||||
|
result = 31 * result + address.hashCode()
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return "$type $address"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package net.dankito.fints.response.segments
|
||||||
|
|
||||||
|
import net.dankito.fints.messages.datenelemente.implementierte.ICodeEnum
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unterstütztes Kommunikationsverfahren (Protokollstack).
|
||||||
|
Zur Zeit unterstützte Kommunikationsverfahren:
|
||||||
|
1: T-Online (mit FinTS V3.0 nicht mehr unterstützt)
|
||||||
|
2: TCP/IP (Protokollstack SLIP/PPP)
|
||||||
|
13: https (verwendet im Sicherheitsverfahren PIN/TAN)
|
||||||
|
|
||||||
|
*/
|
||||||
|
enum class Kommunikationsdienst(override val code: String) : ICodeEnum {
|
||||||
|
|
||||||
|
T_Online("1"),
|
||||||
|
|
||||||
|
TCP_IP("2"),
|
||||||
|
|
||||||
|
Https("3")
|
||||||
|
|
||||||
|
}
|
|
@ -14,7 +14,11 @@ abstract class FinTsTestBase {
|
||||||
companion object {
|
companion object {
|
||||||
const val BankCode = "12345678"
|
const val BankCode = "12345678"
|
||||||
|
|
||||||
val Bank = BankData(BankCode, Laenderkennzeichen.Germany, "")
|
val BankCountryCode = Laenderkennzeichen.Germany
|
||||||
|
|
||||||
|
val BankFinTsServerAddress = "banking.supi-dupi-bank.de/fints30"
|
||||||
|
|
||||||
|
val Bank = BankData(BankCode, BankCountryCode, "")
|
||||||
|
|
||||||
const val CustomerId = "0987654321"
|
const val CustomerId = "0987654321"
|
||||||
|
|
||||||
|
|
|
@ -322,6 +322,32 @@ class ResponseParserTest : FinTsTestBase() {
|
||||||
?: run { Assert.fail("No segment of type SecurityMethods found in ${result.receivedSegments}") }
|
?: run { Assert.fail("No segment of type SecurityMethods found in ${result.receivedSegments}") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun parseCommunicationInfo() {
|
||||||
|
|
||||||
|
// given
|
||||||
|
val language = Dialogsprache.German
|
||||||
|
|
||||||
|
// when
|
||||||
|
val result = underTest.parse("HIKOM:5:4:3+$BankCountryCode:$BankCode+1+3:$BankFinTsServerAddress+2:$BankFinTsServerAddress::MIM:1'")
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertSuccessfullyParsedSegment(result, InstituteSegmentId.CommunicationInfo, 5, 4, 3)
|
||||||
|
|
||||||
|
result.getFirstSegmentById<CommunicationInfo>(InstituteSegmentId.CommunicationInfo)?.let { segment ->
|
||||||
|
assertThat(segment.bankInfo.bankCountryCode).isEqualTo(BankCountryCode)
|
||||||
|
assertThat(segment.bankInfo.bankCode).isEqualTo(BankCode)
|
||||||
|
|
||||||
|
assertThat(segment.defaultLanguage).isEqualTo(language)
|
||||||
|
|
||||||
|
assertThat(segment.parameters).containsExactlyInAnyOrder(
|
||||||
|
CommunicationParameter(Kommunikationsdienst.Https, BankFinTsServerAddress),
|
||||||
|
CommunicationParameter(Kommunikationsdienst.TCP_IP, BankFinTsServerAddress)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
?: run { Assert.fail("No segment of type CommunicationInfo found in ${result.receivedSegments}") }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun parseUserParameters() {
|
fun parseUserParameters() {
|
||||||
|
|
Loading…
Reference in New Issue