Exemplo n.º 1
0
        private void OnClickFaceAuthWithCrpObj(object sender, EventArgs e)
        {
            string Tag = "FaceAuthWithCrpObj";

            Android.Content.PM.Permission permissionCheck = Android.Content.PM.Permission.Granted;
            if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
            {
                permissionCheck = CheckSelfPermission(Manifest.Permission.Camera);
            }
            if (permissionCheck != Android.Content.PM.Permission.Granted)
            {
                log.Info(Tag, "The camera permission is not enabled. Please enable it.");

                // request camera permissions
                if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
                {
                    RequestPermissions(new string[] { Manifest.Permission.Camera }, 1);
                }
                return;
            }
            BioAuthnCallback callback = new FidoBioAuthnCallback();
            // Cancellation Signal
            CancellationSignal cancellationSignal = new CancellationSignal();

            FaceManager faceManager = new FaceManager(this);

            Log.Info("HasEnrolledTemplates", faceManager.HasEnrolledTemplates.ToString());
            Log.Info("IsHardwareDetected", faceManager.IsHardwareDetected.ToString());
            Log.Info("CanAuth", faceManager.CanAuth().ToString());

            log.Info(Tag, $"IsHardwareDetected:{faceManager.IsHardwareDetected}");

            // Checks whether 3D facial authentication can be used.
            int errorCode = faceManager.CanAuth();

            if (errorCode != 0)
            {
                log.Info(Tag, "Can not authenticate. errorCode=" + errorCode);
                return;
            }
            // flags
            int flags = 0;

            // Authentication messsage handler.
            Handler handler = null;

            // Recommended CryptoObject to be set to null. KeyStore is not associated with face authentication in current
            // version. KeyGenParameterSpec.Builder.SetUserAuthenticationRequired() must be set false in this scenario.
            CryptoObject crypto = null;

            log.Info(Tag, "Start face authentication.\nAuthenticating......\n");
            faceManager.Auth(crypto, cancellationSignal, flags, callback, handler);
        }
Exemplo n.º 2
0
        private BioAuthnPrompt CreateBioAuthnPrompt()
        {
            BioAuthnCallback callback = new FidoBioAuthnCallback();

            return(new BioAuthnPrompt(this, ContextCompat.GetMainExecutor(this), callback));
        }