Skip to content

Pattern 8: Biometric Enrollment

This pattern is the biometric-specific specialization of Pattern 15: Enrollment Process. Read Pattern 15 first.

Current Handler Shape

Enrollment is implemented as a generated command handler, usually a static method. The command carries EnrollmentId and PersonId; the adapter captures the vendor template and completes the session through IEnrollmentService.

public static class FaceEnrollment
{
    public static async Task<DeviceCommandResult> EnrollFace(
        BiometricTerminal terminal,
        Access.Enroll.Face command,
        Protocol protocol,
        IEnrollmentService enrollment,
        CancellationToken ct)
    {
        enrollment.Begin(terminal);

        try
        {
            var scanned = await protocol.ScanFace(ct);

            var data = new EnrollmentData
            {
                EnrollmentId = command.EnrollmentId,
                PersonId = command.PersonId,
                Technology = "vendor.face",
                TemplateData = scanned.Template,
            };

            return await enrollment.Complete(data, ct);
        }
        catch (TimeoutException)
        {
            await terminal.SetStatus("enrollment", null);
            return new DeviceCommandResult(CommandResult.Timeout);
        }
        catch (OperationCanceledException)
        {
            await terminal.SetStatus("enrollment", null);
            return new DeviceCommandResult(CommandResult.Timeout);
        }
    }
}

Rules

  • Do not store enrollment session state on the Thing unless the protocol requires a long-running device mode that cannot be represented by the command/session.
  • Use command.EnrollmentId and command.PersonId; do not read current session IDs from IEnrollmentService.
  • Use enrollment.Begin(thing) before capture and enrollment.Complete(data, ct) after successful capture.
  • Return timeout for user cancellation, device timeout, or command cancellation.
  • Document template technology strings and whether templates are vendor-proprietary.

Technology Identifiers

Use vendor-specific technology strings:

  • vendor.fingerprint.v2
  • vendor.face.visible
  • vendor.face.ir
  • vendor.iris

The technology string must identify the template format, not just the biometric modality.