Biometric operations
There are three basic operations:
- enrollment: The enrollment is the operation performed to capture the users's specific biometric features and register them in the system.
- verification: The verification is the operation to authenticate the identity of the users capturing their current biometric features and comparing them against the template previously generated in the enrollment.
- identification: The identification tries to identify the identity of an unknown user based on their biometric features comparing them against all registered users in the database.
MobbID uses the concept of a BiometricView.
- A BiometricView is a subclass of
android.view.View
in Android or aUIView
in iOS. - Each biometric technology has its correspondent BiometricView. BiometricView takes care of capturing the biometric feature from the user and perform the enrollment, verification or identification.
- FaceView: It will open the camera and guide the user with a comprehensive UI to capture his/her face.
- VoiceView: It will handle the microphone to and show the user what he/she should do to capture his/her voice.
- SignatureView: It will capture the handwritten signature of the user using the touch screen of the device.
- IrisView: It will open the camera and take a picture of the irises of the user.
- FingerprintView: It the let the users use their fingerprints with the built-in fingerprint sensor to authenticate themselves.
- FaceVoiceView: It will capture the face and the voice at the same time. This is a special case, the user needs to be enrolled in both Face and Voice technologies and it's only valid for verification.
The general approach to use one of these BiometricViews is:
- Create the BiometricView. BiometricView are designed to work best in fullscreen mode.
- Set up its listener (
BiometricMethodListener
) or delegate (BiometricMethodDelegate
) to receive the result of the operation. - Add the view to your Activity content view or to your ViewController as a subview.
- Kicks off the biometric recognition process.
- Wait and check for the result of the operation.
Please find here more detailed information about the specific technologies and their implementation:
Enrollment
The enrollment is the operation performed to capture the user's specific biometric features and register them in the system.
TODO
1. Create an instance of the BiometricView
@property (nonatomic, strong) FaceView * faceView;
@implementation YourViewController
@synthesize faceView;
// lazy initialise of the property (or initialise it in your preferred way)
- (FaceView *) faceView {
if (!faceView) {
faceView = [[FaceView alloc] initWithFrame:self.view.bounds];
}
return faceView;
}
2 & 3. Set up its delegate and add it your YourViewController
// set the delegate
[self.faceView setDelegate:self];
// add the BiometricView to your UI hierarchy
[self.view addSubview:self.faceView];
YourViewController must conform to the BiometricMethodDelegate
protocol.
4. Kick off the enrollment process
MobbIDSDKRecognitionParameters * parameters = [[MobbIDSDKRecognitionParameters alloc] init];
parameters.userId = self.userId;
parameters.securityKey = securityKey;
[self.faceView startRecognitionIn:MobbIDSDKRecognitionMode_Enrollment withParameters:parameters];
The securityKey
is only used in the enrollment process. It will be used later in improve enrollments as a security measurement. You must use nil for verification/identification operations. This securityKey should be secret and related to the user somehow.
5. Wait and check for the result of the operation
#pragma mark -- BiometricMethodDelegate
- (void) enrollmentFinished:(MobbIDSDKOperationEnrollmentResult)resultCode data:(MobbIDSDKOperationEnrollmentResultData *)data error:(NSError *)errorOccurred
{
// Enrollment face process has finished
switch (resultCode) {
case MobbIDSDKOperationEnrollmentResult_USER_ENROLLED:
// The user has been properly enrolled. They can now be verified with their face
...
break;
case MobbIDSDKOperationEnrollmentResult_ERROR:
//It's up to you to handle possible errors. Check the protocol class to view possible error codes (localised description of the error and failure reason are available in the NSError with the NSLocalizedDescriptionKey and NSLocalizedFailureReasonErrorKey respectively).
...
default:
break;
}
// Tear down the biometric view
[self.faceView stopRecognition];
// You could also remove it from you UI hierarchy if you want...
}
1. Create an instance of the BiometricView
IXFaceView faceView;
...
faceView = DependencyService.Get<IXFaceView>();
2 & 3. Set up its delegate and add it your YourPage
Warning: The steps differ a little here. We first need to create the biometric view and then we will be able to set the delegate. The creation process returns a
Xamarin.Form View
that will be set asContent
of theContentView
provided as placeholder.
// being biometricView a ContentView placed somewhere in YourPage layout
biometricView.Content = faceView.CreateView(biometricView);
faceView.Delegate = this;
YourPage must implement the IXBiometricMethodDelegate
interface.
4. Kick off the enrollment process
IXMobbIDRecognitionParameters parameters = DependencyService.Get<IXMobbIDRecognitionParameters>(DependencyFetchTarget.NewInstance);
parameters.UserId = userId;
parameters.SecurityKey = securityKey;
faceView.StartRecognitionIn(XMobbIDRecognitionMode.Enrollment, parameters);
The mode for the enrollment must be XMobbIDRecognitionMode.Enrollment
.
The parameters.SecurityKey
is only used in the enrollment process. It will be used later in improve enrollments as a security meassurement. This security key should be secret and related to the user somehow.
5. Wait and check for the result of the operation
void IXBiometricMethodDelegate.EnrollmentFinished(XMobbIDEnrollmentResult result, IXMobbIDEnrollmentResultData data, IXMobbIDSDKError error)
{
// Enrollment face process has finished
switch (result)
{
case XMobbIDEnrollmentResult.UserEnrolled:
// The user has been properly enrolled. They can now be verified with their face
...
break;
case XMobbIDEnrollmentResult.Error:
//It's up to you to handle possible errors.
...
default:
break;
}
// Tear down the biometric view
faceView.StopRecognition();
// You could also remove it from you UI hierarchy if you want...
}
Verification
TODO
Assuming you've already created and enrolled the user and you have also created the BiometricView instance:
2 & 3. Set up its delegate and add it your YourViewController
// set the delegate
[self.faceView setDelegate:self];
// add the BiometricView to your UI hierarchy
[self.view addSubview:self.faceView];
YourViewController must conform to the BiometricMethodDelegate
protocol.
4. Kick off the verification process
MobbIDSDKRecognitionParameters * parameters = [[MobbIDSDKRecognitionParameters alloc] init];
parameters.userId = userId;
[self.faceView startRecognitionIn:MobbIDSDKRecognitionMode_Verification withParameters:parameters];
5. Wait and check for the result of the operation
#pragma mark -- BiometricMethodDelegate
- (void)verificationFinished:(MobbIDSDKOperationVerificationResult)resultCode
data:(MobbIDSDKOperationVerificationResultData *)data
error:(NSError *)errorOccurred
{
// Verification has finished
switch (resultCode) {
case MobbIDSDKOperationVerificationResult_USER_VERIFIED:
// The user's identity has been verified... grant him/her access to your service
...
break;
case MobbIDSDKOperationVerificationResult_USER_NOT_VERIFIED:
// The user's identity cannot be verified.
...
break;
case MobbIDSDKOperationVerificationResult_ERROR:
default:
//It's up to you to handle possible errors. Check the protocol class to view possible error codes (localised description of the error and failure reason are available in the NSError with the NSLocalizedDescriptionKey and NSLocalizedFailureReasonErrorKey respectively).
...
break;
}
// Tear down the biometric view
[self.faceView stopRecognition];
// You could also remove it from you UI hierarchy if you want...
}
Assuming you've already created and enrolled the user and you have also created the BiometricView instance:
2 & 3. Set up its delegate and add it your YourPage
Warning: The steps differ a little here. We first need to create the biometric view and then we will be able to set the delegate. The creation process returns a
Xamarin.Form View
that will be set asContent
of theContentView
provided as placeholder.
// being biometricView a ContentView placed somewhere in YourPage layout
biometricView.Content = faceView.CreateView(biometricView);
faceView.Delegate = this;
YourPage must implement the IXBiometricMethodDelegate
interface.
4. Kick off the verification process
IXMobbIDRecognitionParameters parameters = DependencyService.Get<IXMobbIDRecognitionParameters>(DependencyFetchTarget.NewInstance);
parameters.UserId = userId;
faceView.StartRecognitionIn(XMobbIDRecognitionMode.Verification, parameters);
The mode for the enrollment must be XMobbIDRecognitionMode.Verification
.
Do no set any value for the parameters.SecurityKey
variable as it is only expected for enrollment.
5. Wait and check for the result of the operation
void IXBiometricMethodDelegate.VerificationFinished(XMobbIDVerificationResult result, IXMobbIDVerificationResultData data, IXMobbIDSDKError error)
{
// Verification has finished
switch (resultCode)
{
case XMobbIDVerificationResult.UserVerified:
// The user's identity has been verified... grant them access to your service
...
break;
case XMobbIDVerificationResult.UserNotVerified:
// The user's identity cannot be verified.
...
break;
case XMobbIDVerificationResult.Error:
default:
//It's up to you to handle possible errors.
...
break;
}
// Tear down the biometric view
faceView.StopRecognition();
// You could also remove it from you UI hierarchy if you want...
}