Ejemplo n.º 1
0
        public static WinHelloProvider CreateInstance(AuthCacheType authCacheType)
        {
            EnsureWinHelloAvailability();

            lock (_mutex)
            {
                WinHelloProvider winHelloProvider = null;
                if (_instance != null && (winHelloProvider = _instance.Target as WinHelloProvider) != null)
                {
                    if (winHelloProvider.CurrentCacheType == authCacheType)
                    {
                        return(winHelloProvider);
                    }
                    else
                    {
                        throw new AuthProviderException("Incompatible cache type with existing instance.");
                    }
                }

                winHelloProvider = new WinHelloProvider(authCacheType);
                _instance        = new WeakReference(winHelloProvider);

                return(winHelloProvider);
            }
        }
        public override bool Initialize(IPluginHost host)
        {
            if (Host != null)
            {
                Debug.Assert(false); Terminate();
            }
            if (host == null)
            {
                return(false);
            }

            _provider = new WinHelloProvider();

            Host = host;
            Host.KeyProviderPool.Add(_provider);
            Host.MainWindow.FileClosingPre += FileClosingPreHandler;

            GlobalWindowManager.WindowAdded += WindowAddedHandler;

            _timer          = new System.Timers.Timer(1000);
            _timer.Elapsed += ElapsedHandler;
            _timer.Start();

            return(true);
        }
Ejemplo n.º 3
0
        public static bool IsAvailable()
        {
#if DEBUG
            return(true);
#else
            return(WinHelloProvider.IsAvailable());
#endif
        }
Ejemplo n.º 4
0
        public static IAuthProvider GetInstance(IntPtr keePassWindowHandle, AuthCacheType authCacheType)
        {
#if DEBUG
            var provider = new XorProvider(authCacheType);
#else
            var provider = WinHelloProvider.CreateInstance(authCacheType);
#endif
            if (UAC.IsCurrentProcessElevated)
            {
                return(new WinHelloProviderForegroundDecorator(provider, keePassWindowHandle));
            }
            else
            {
                return(provider);
            }
        }