From 372719418f55caafdeb3e688ee5d55860d9d85b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maro=C5=A1=20Silady?= <38668012+SMaros@users.noreply.github.com> Date: Mon, 23 Oct 2023 08:37:34 +0200 Subject: [PATCH] LC-224 - Identity listener improvements (#848) --- .../server/extensions/IIdentityListener.java | 34 ++++++++++++++++++- .../identity/ExampleIdentityListener.java | 12 ++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IIdentityListener.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IIdentityListener.java index fef6ef3e8..5fc99940b 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IIdentityListener.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IIdentityListener.java @@ -21,6 +21,20 @@ import com.generalbytes.batm.server.extensions.aml.verification.IdentityApplicant; public interface IIdentityListener { + + /** + * @deprecated Use {@link #onIdentityVerificationResult(String, ApplicantCheckResult)} instead. + * + * @param rawPayload raw data received from the identity verification provider (e.g., in a webhook). + * Might be used to access additional data not recognized by the identity verification extension. + * @param result data parsed by the identity verification extension. + * Contains identity applicant ID that could be used to obtain the Identity, + * see {@link IExtensionContext#findIdentityVerificationApplicant(String)} + * and {@link IdentityApplicant#getIdentity()} + */ + @Deprecated + default void onVerificationResult(String rawPayload, ApplicantCheckResult result) { + } /** * Called by the server when an identity verification result is received from an identity verification provider. * @@ -31,6 +45,24 @@ public interface IIdentityListener { * see {@link IExtensionContext#findIdentityVerificationApplicant(String)} * and {@link IdentityApplicant#getIdentity()} */ - default void onVerificationResult(String rawPayload, ApplicantCheckResult result) { + default void onIdentityVerificationResult(String rawPayload, ApplicantCheckResult result) { + } + + /** + * Called when a new identity is created by the master or admin service. + * + * @param publicIdentityId Public ID of the newly created identity. + */ + default void onIdentityCreated(String publicIdentityId) { + } + + /** + * Called whenever the admin or master service changes the state of an identity. + * + * @param publicIdentityId Public ID of the identity whose state has changed. + * @param stateFrom The previous state of the identity before the change. + * @param stateTo The new state of the identity after the change. + */ + default void onIdentityStateChanged(String publicIdentityId, int stateFrom, int stateTo) { } } diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/ExampleIdentityListener.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/ExampleIdentityListener.java index ffaaa42e9..e65f62b72 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/ExampleIdentityListener.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/ExampleIdentityListener.java @@ -28,7 +28,7 @@ public class ExampleIdentityListener implements IIdentityListener { Logger log = LoggerFactory.getLogger(ExampleIdentityListener.class); @Override - public void onVerificationResult(String rawPayload, ApplicantCheckResult result) { + public void onIdentityVerificationResult(String rawPayload, ApplicantCheckResult result) { WebhookData data = parsePayload(rawPayload); IExtensionContext ctx = IdentityExampleExtension.getExtensionContext(); IdentityApplicant applicant = ctx.findIdentityVerificationApplicant(result.getIdentityApplicantId()); @@ -86,6 +86,16 @@ public void onVerificationResult(String rawPayload, ApplicantCheckResult result) new ChoiceCustomFieldValue(element.getId()))); } + @Override + public void onIdentityCreated(String publicIdentityId) { + log.info("Identity with public ID {} has been created", publicIdentityId); + } + + @Override + public void onIdentityStateChanged(String publicIdentityId, int stateFrom, int stateTo) { + log.info("Identity with public ID {} changed from state {} to state {}", publicIdentityId, stateFrom, stateTo); + } + private CustomFieldDefinition findCustomFieldDefinition(Collection customFieldDefinitions, String name, CustomFieldDefinitionType type) {