29 | 29 |
import java.util.List;
|
30 | 30 |
import java.util.Map;
|
31 | 31 |
import java.util.Objects;
|
|
32 |
import java.util.Optional;
|
32 | 33 |
import java.util.Properties;
|
33 | 34 |
import java.util.regex.Matcher;
|
34 | 35 |
import java.util.regex.Pattern;
|
|
51 | 52 |
import org.kapott.hbci.passport.HBCIPassport;
|
52 | 53 |
import org.kapott.hbci.passport.HBCIPassportInternal;
|
53 | 54 |
import org.kapott.hbci.status.HBCIMsgStatus;
|
|
55 |
import org.kapott.hbci.structures.Konto;
|
|
56 |
import org.kapott.hbci.tools.StringUtil;
|
54 | 57 |
|
55 | 58 |
/**
|
56 | 59 |
* Kapselt die authentifizierten Initialisierungsdialoge. Also im Wesentlichen alles, was mit den UPD zu tun hat.
|
|
561 | 564 |
// Manche Banken schicken in den UPDs scheinbar die Konto-Daten nicht mehr immer mit. Daher merken wird uns die vorherigen
|
562 | 565 |
// Werte, wenn keine neuen uebertragen wurden
|
563 | 566 |
if (upd != null && upd.size() > 0) {
|
564 | |
final Pattern pattern = Pattern.compile("(KInfo(.*?)\\.KTV)\\.(bic|iban)");
|
565 | |
for (final Object okey : upd.keySet()) {
|
|
567 |
Konto[] konten = passport.getAccounts();
|
|
568 |
final Pattern pattern = Pattern.compile("UPD\\.(KInfo(.*?)\\.KTV)\\.number");
|
|
569 |
for (final Object okey : result.keySet()) {
|
566 | 570 |
final String key = okey.toString();
|
567 | 571 |
final Matcher m = pattern.matcher(key);
|
568 | |
if (m.matches() && !result.contains("UPD." + key)) {
|
|
572 |
if (m.matches()) {
|
569 | 573 |
final String kinfo = m.group(1);
|
570 | |
if (Objects.equals(result.getProperty("UPD." + kinfo + ".KIK.country"), upd.getProperty(kinfo + ".KIK.country"))
|
571 | |
&& Objects.equals(result.getProperty("UPD." + kinfo + ".KIK.blz"), upd.getProperty(kinfo + ".KIK.blz"))
|
572 | |
&& Objects.equals(result.getProperty("UPD." + kinfo + ".number"), upd.getProperty(kinfo + ".number"))) {
|
573 | |
HBCIUtils.log(key + " is missing, using the previous UPD's value", HBCIUtils.LOG_DEBUG);
|
574 | |
p.put(okey, upd.getProperty(key));
|
|
574 |
if (!p.contains(kinfo + ".bic") || !p.contains(kinfo + ".iban")) {
|
|
575 |
Optional<Konto> matchingKonto = Arrays.asList(konten).stream()
|
|
576 |
.filter(konto ->
|
|
577 |
Objects.equals(konto.number, result.get(okey)) &&
|
|
578 |
Objects.equals(konto.blz, result.get("UPD." + kinfo + ".KIK.blz")) &&
|
|
579 |
Objects.equals(konto.country, result.get("UPD." + kinfo + ".KIK.country")))
|
|
580 |
.findAny();
|
|
581 |
matchingKonto.ifPresent(konto -> {
|
|
582 |
if (StringUtil.hasText(konto.iban) && StringUtil.hasText(konto.bic)) {
|
|
583 |
HBCIUtils.log(kinfo + ".iban / .bic is missing, using the previous UPD's value",
|
|
584 |
HBCIUtils.LOG_DEBUG);
|
|
585 |
p.put(kinfo + ".bic", konto.bic);
|
|
586 |
p.put(kinfo + ".iban", konto.iban);
|
|
587 |
}
|
|
588 |
});
|
575 | 589 |
}
|
576 | 590 |
}
|
577 | 591 |
}
|