Skip to content

Commit

Permalink
fixed sca exemption check
Browse files Browse the repository at this point in the history
  • Loading branch information
age-77 committed Nov 4, 2021
1 parent 68cb2f2 commit 18e6d48
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.kapott.hbci.GV.AbstractHBCIJob;
import org.kapott.hbci.GV.GVTAN2Step;
import org.kapott.hbci.GV.GVVeuStep;
import org.kapott.hbci.GV_Result.HBCIJobResult;
import org.kapott.hbci.callback.AbstractHBCICallback;
import org.kapott.hbci.callback.HBCICallback;
import org.kapott.hbci.dialog.AbstractHbciDialog;
Expand All @@ -50,6 +51,7 @@

import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import static de.adorsys.multibanking.domain.BankApi.HBCI;
Expand Down Expand Up @@ -101,8 +103,7 @@ public R execute(HBCICallback hbciCallback) {

//check for SCA is really needed after execution
tan2StepRequired = Optional.ofNullable(hktan)
.map(gvtan2Step -> KnownReturncode.W3076.searchReturnValue(gvtan2Step.getJobResult().getJobStatus().getRetVals()) == null
&& KnownReturncode.W3076.searchReturnValue(gvtan2Step.getJobResult().getGlobStatus().getRetVals()) == null)
.map(gvtan2Step -> !isScaExempted(hbciExecStatus, gvtan2Step.getJobResult()))
.orElse(false);

R jobResponse = createJobResponse();
Expand All @@ -119,6 +120,17 @@ public R execute(HBCICallback hbciCallback) {
return jobResponse;
}

private boolean isScaExempted(HBCIExecStatus hbciExecStatus, HBCIJobResult hbciJobResult) {
return KnownReturncode.W3076.searchReturnValue(hbciJobResult.getJobStatus().getRetVals()) != null ||
KnownReturncode.W3076.searchReturnValue(hbciJobResult.getGlobStatus().getRetVals()) != null ||
hbciExecStatus.getMsgStatusList().stream()
.filter(Objects::nonNull)
.anyMatch(hbciMsgStatus ->
KnownReturncode.W3076.searchReturnValue(hbciMsgStatus.globStatus.getRetVals()) != null
|| KnownReturncode.W3076.searchReturnValue(hbciMsgStatus.segStatus.getRetVals()) != null
);
}

private R initDialog(HBCICallback hbciCallback) {
log.debug("init new hbci dialog");
PinTanPassport bpdPassport = fetchBpd(hbciCallback);
Expand Down

0 comments on commit 18e6d48

Please sign in to comment.