From 6854c9270705a6cd60496ef97551c5da835dfd4d Mon Sep 17 00:00:00 2001 From: Lubos Racansky Date: Thu, 7 Sep 2023 16:18:02 +0200 Subject: [PATCH] Fix #773: Upload presence check photo for failed authentication attempts - Parse frame even if the presence check failed --- .../provider/IProovPresenceCheckProvider.java | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/presencecheck/iproov/provider/IProovPresenceCheckProvider.java b/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/presencecheck/iproov/provider/IProovPresenceCheckProvider.java index e736562d5..97061280e 100644 --- a/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/presencecheck/iproov/provider/IProovPresenceCheckProvider.java +++ b/enrollment-server-onboarding/src/main/java/com/wultra/app/onboardingserver/presencecheck/iproov/provider/IProovPresenceCheckProvider.java @@ -185,23 +185,29 @@ public PresenceCheckResult getResult(OwnerId id, SessionInfo sessionInfo) throws throw new RemoteCommunicationException("Missing response body when validating a verification in iProov, " + id); } - final PresenceCheckResult result = new PresenceCheckResult(); - final ClaimValidateResponse response = parseResponse(responseEntity.getBody(), ClaimValidateResponse.class); - if (response.getPassed()) { - result.setStatus(PresenceCheckStatus.ACCEPTED); + return convert(response, id); + } - if (ifFrameAvailable(response)) { - logger.debug("Parsing frame image {}", id); - result.setPhoto(parseImage(response.getFrame())); - } else { - logger.debug("Frame is not available, {}", id); - } + private static PresenceCheckResult convert(final ClaimValidateResponse source, final OwnerId id) { + final PresenceCheckResult target = new PresenceCheckResult(); + + if (source.getPassed()) { + target.setStatus(PresenceCheckStatus.ACCEPTED); } else { - result.setStatus(PresenceCheckStatus.REJECTED); - result.setRejectReason(response.getReason()); + logger.debug("Image rejected with reason={}, {}", source.getReason(), id); + target.setStatus(PresenceCheckStatus.REJECTED); + target.setRejectReason(source.getReason()); } - return result; + + if (ifFrameAvailable(source)) { + logger.debug("Parsing frame image {}", id); + target.setPhoto(parseImage(source.getFrame())); + } else { + logger.debug("Frame is not available, {}", id); + } + + return target; } @Override