Пример #1
0
        /// <summary>
        /// Creates a pop-up window
        /// </summary>
        /// <param name="sender">VPN session</param>
        /// <param name="e">Event arguments</param>
        public TwoFactorAuthenticationPopup(object sender, UsernamePasswordAuthenticationRequestedEventArgs e) :
            base(sender, e)
        {
            var session = sender as VPNSession;

            // Query profile supported & user enrolled 2-Factor authentication methods.
            var methods = TwoFactorAuthenticationMethods.Any;

            if (Session.ConnectingProfile.IsTwoFactorAuthentication)
            {
                methods &= Session.ConnectingProfile.TwoFactorMethods;
            }
            if (Session.UserInfo.IsTwoFactorAuthentication)
            {
                methods &= Session.UserInfo.TwoFactorMethods;
            }

            // Prepare the list of methods.
            var last_method = Properties.Settings.Default.InstanceSettings.TryGetValue(session.AuthenticatingInstance.Base.AbsoluteUri, out var settings) ? settings.LastTwoFactorAuthenticationMethod : null;

            MethodList = new ObservableCollection <TwoFactorAuthenticationBasePanel>();
            TwoFactorAuthenticationBasePanel method;

            if (methods.HasFlag(TwoFactorAuthenticationMethods.TOTP))
            {
                MethodList.Add(method = new TOTPAuthenticationPanel(session.Wizard, session.AuthenticatingInstance));
                if (last_method == method.ID)
                {
                    _selected_method = method;
                }
            }
            if (methods.HasFlag(TwoFactorAuthenticationMethods.YubiKey))
            {
                MethodList.Add(method = new YubiKeyAuthenticationPanel(session.Wizard, session.AuthenticatingInstance));
                if (last_method == method.ID)
                {
                    _selected_method = method;
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Creates a pop-up window
 /// </summary>
 /// <param name="sender">VPN session</param>
 /// <param name="e">Event arguments</param>
 public UsernamePasswordPopup(object sender, UsernamePasswordAuthenticationRequestedEventArgs e) :
     base(sender, e)
 {
     _username = Properties.Settings.Default.InstanceSettings.TryGetValue(Session.AuthenticatingInstance.Base.AbsoluteUri, out var settings) ? settings.LastUsername : null;
 }