Esempio n. 1
0
        protected override void OnLoad(EventArgs e)
        {
            var units = WinBio.EnumBiometricUnits(WinBioBiometricType.Fingerprint);

            Log(string.Format("Found {0} units", units.Length));

            // Check if we have a connected fingerprint sensor
            if (units.Length == 0)
            {
                MessageBox.Show("Error: Fingerprint sensor not found! Exiting...", "Error", MessageBoxButtons.OK);
                Application.Exit();
                return;
            }

            var unit = units[0];

            _unitId = unit.UnitId;
            Log(string.Format("Using unit id: {0}", _unitId));
            Log(string.Format("Device instance id: {0}", unit.DeviceInstanceId));
            Log(string.Format("Using database: {0}", DatabaseId));

            // Check if we need to create a new database
            if (WinBioConfiguration.DatabaseExists(DatabaseId) == false)
            {
                InitialStart();
            }
            else
            {
                OpenBiometricSession();
            }
        }
Esempio n. 2
0
        private void InitialStart()
        {
            // Stop Windows Biometric Service to apply changes
            RestartService("WbioSrvc", 5000, ServiceMode.Stop);

            var databases = WinBio.EnumDatabases(WinBioBiometricType.Fingerprint);

            Console.WriteLine("Found {0} databases", databases.Length);
            for (var i = 0; i < databases.Length; i++)
            {
                Console.WriteLine("DatabaseId {0}: {1}", i, databases[i].DatabaseId);
            }
            if (WinBioConfiguration.DatabaseExists(DatabaseId))
            {
                Console.WriteLine("Removing database: {0}", DatabaseId);
                WinBioConfiguration.RemoveDatabase(DatabaseId);
            }

            // Start Windows Biometric Service to apply changes
            RestartService("WbioSrvc", 5000, ServiceMode.Start);

            Console.WriteLine("Creating database: {0}", DatabaseId);
            WinBioConfiguration.AddDatabase(DatabaseId, _unitId);
            Console.WriteLine("Adding sensor to the pool: {0}", _unitId);
            WinBioConfiguration.AddUnit(DatabaseId, _unitId);

            // Restart Windows Biometric Service to apply changes
            RestartService("WbioSrvc", 5000, ServiceMode.Restart);

            Log("Successfully recreated database.");

            OpenBiometricSession();
        }
Esempio n. 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!WinBioConfiguration.DatabaseExists(Shared.DatabaseId))
            {
                MessageBox.Show(Properties.Resources.InitializeDatabase, Properties.Resources.PluginError, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            errorProvider.Clear();

            if (String.IsNullOrEmpty(tbxPassword.Text))
            {
                errorProvider.SetError(tbxPassword, FingerprintPlugin.Properties.Resources.EmptyPasswordError);
                return;
            }
            else
            {
                errorProvider.SetError(tbxPassword, String.Empty);

                if (tbxPassword.Text != tbxVerif.Text)
                {
                    errorProvider.SetError(tbxVerif, FingerprintPlugin.Properties.Resources.PasswordMismatchError);
                    return;
                }
                else
                {
                    errorProvider.SetError(tbxVerif, String.Empty);
                }
            }

            CheckFinger checkFinger = new CheckFinger();

            var selectedInit = (FingerprintUnit)cbReaderUnit.SelectedItem;

            checkFinger.UnitId          = selectedInit.Id;
            checkFinger.StartEnrollment = true;

            if (checkFinger.ShowDialog() != DialogResult.OK)
            {
                MessageBox.Show(Properties.Resources.FingerprintConfigurationError, Properties.Resources.PluginError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DbMasterKeyManager dbManager = new DbMasterKeyManager();

            dbManager.AddOrUpdate(DatabaseName, tbxPassword.Text, checkFinger.TemplateFingerGuid, checkFinger.UnitId);
            dbManager.Save();


            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        public void InitialStart()
        {
            if (WinBioConfiguration.DatabaseExists(DatabaseId))
            {
                return;
            }

            Messages.Items.Add(string.Format("Creating database: {0}", DatabaseId));
            WinBioConfiguration.AddDatabase(DatabaseId, UnitId);
            Messages.Items.Add(string.Format("Adding sensor to the pool: {0}", UnitId));
            WinBioConfiguration.AddUnit(DatabaseId, UnitId);

            // Restart Windows Biometric Service to apply changes
            Messages.Items.Add("Restart Service WbioSrvc");
            RestartService("WbioSrvc", 5000, ServiceMode.Restart);
        }
Esempio n. 5
0
        private void Initialize()
        {
            try
            {
                RefreshReaderUnits();

                if (!WinBioConfiguration.DatabaseExists(Shared.DatabaseId))
                {
                    gpMasterKey.Enabled   = false;
                    btnInitialize.Enabled = true;
                }
                else
                {
                    gpMasterKey.Enabled   = true;
                    btnInitialize.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Properties.Resources.FingerprintInitError, Properties.Resources.PluginError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Esempio n. 6
0
 public static void Main()
 {
     try
     {
         var units = WinBio.EnumBiometricUnits(WinBioBiometricType.Fingerprint);
         Console.WriteLine("Found {0} units", units.Length);
         if (units.Length == 0)
         {
             return;
         }
         var unit   = units[0];
         var unitId = unit.UnitId;
         Console.WriteLine("Using unit id: {0}", unitId);
         Console.WriteLine("Device instance id: {0}", unit.DeviceInstanceId);
         var databases = WinBio.EnumDatabases(WinBioBiometricType.Fingerprint);
         Console.WriteLine("Found {0} databases", databases.Length);
         for (var i = 0; i < databases.Length; i++)
         {
             Console.WriteLine("DatabaseId {0}: {1}", i, databases[i].DatabaseId);
         }
         if (WinBioConfiguration.DatabaseExists(DatabaseId))
         {
             Console.WriteLine("Removing database: {0}", DatabaseId);
             WinBioConfiguration.RemoveDatabase(DatabaseId);
         }
         Console.WriteLine("Creating database: {0}", DatabaseId);
         WinBioConfiguration.AddDatabase(DatabaseId, unitId);
         Console.WriteLine("Adding sensor to the pool: {0}", unitId);
         WinBioConfiguration.AddUnit(DatabaseId, unitId);
         Console.WriteLine("Opening biometric session");
         var session = WinBio.OpenSession(WinBioBiometricType.Fingerprint, WinBioPoolType.Private, WinBioSessionFlag.Basic, new[] { unitId }, DatabaseId);
         try
         {
             Console.WriteLine("Type sub type and press enter:");
             WinBioBiometricSubType subType;
             if (!Enum.TryParse(Console.ReadLine(), true, out subType))
             {
                 Console.WriteLine("Invalid sub type");
                 return;
             }
             var identity = AddEnrollment(session, unitId, subType);
             Console.WriteLine("Identity: {0}", identity);
             Console.WriteLine();
             var enrollments = WinBio.EnumEnrollments(session, unitId, identity);
             Console.WriteLine("Found {0} enrollments for that identity:", enrollments.Length);
             foreach (var enrollment in enrollments)
             {
                 Console.WriteLine(enrollment);
             }
             Console.WriteLine();
             Console.WriteLine("Verify identity with any finger:");
             WinBioRejectDetail rejectDetail;
             WinBio.Verify(session, identity, WinBioBiometricSubType.Any, out unitId, out rejectDetail);
             Console.WriteLine("Success");
         }
         finally
         {
             Console.WriteLine("Closing biometric session");
             WinBio.CloseSession(session);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Exception: " + ex.GetType().Name);
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.StackTrace);
     }
 }