Skip to content

Commit

Permalink
LC-224 - Identity listener improvements (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
SMaros authored Oct 23, 2023
1 parent a01f7b7 commit 3727194
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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<CustomFieldDefinition> customFieldDefinitions,
String name,
CustomFieldDefinitionType type) {
Expand Down

0 comments on commit 3727194

Please sign in to comment.