コード例 #1
0
        private void DlgSettings_Load(object sender, EventArgs e)
        {
            // Prepare algorithms
            foreach (YubikeyAlgorithm item in YubikeyPolicyUtility.GetYubicoAlgorithms())
            {
                drpAlgorithm.Items.Add(item);

                if (item.Value == YubikeyPivNative.YKPIV_ALGO_RSA2048)
                {
                    drpAlgorithm.SelectedItem = item;
                }
            }

            UpdateView();

            try
            {
                Domain domain = Domain.GetComputerDomain();

                if (!string.IsNullOrWhiteSpace(domain.Name))
                {
                    llBrowseCA.Visible = true;
                }
            }
            catch (ActiveDirectoryObjectNotFoundException)
            {
                llBrowseCA.Visible = false;
            }
        }
コード例 #2
0
        private void RefreshEligibleForEnroll()
        {
            bool eligible = true;

            if (!_devicePresent)
            {
                eligible = false;
            }

            if (!YubikeyPolicyUtility.IsValidPin(txtPin.Text))
            {
                eligible = false;
            }

            if (txtPin.Text != txtPinAgain.Text)
            {
                eligible = false;
            }

            if (string.IsNullOrEmpty(txtUser.Text))
            {
                eligible = false;
            }

            if (_hasBeenEnrolled)
            {
                eligible = false;
            }

            cmdEnroll.Enabled = eligible;
        }
コード例 #3
0
 private void txtPinNew_Validating(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (!YubikeyPolicyUtility.IsValidPin(txtPinNew.Text))
     {
         txtPinNew.BackColor = Color.LightCoral;
         e.Cancel            = true;
     }
     else
     {
         txtPinNew.BackColor = Color.White;
         e.Cancel            = false;
     }
 }
コード例 #4
0
        private void RefreshEligibilityForReset()
        {
            bool eligible = true;

            if (!YubikeyPolicyUtility.IsValidPin(txtPinNew.Text))
            {
                eligible = false;
            }

            if (txtPinNew.Text != txtPinNewAgain.Text)
            {
                eligible = false;
            }

            cmdChange.Enabled = eligible;
        }
コード例 #5
0
        private void DlgEnroll_Load(object sender, EventArgs e)
        {
            AcceptButton = cmdEnroll;

            // Start worker that checks for inserted yubikeys
            YubikeyDetector.Instance.StateChanged += YubikeyStateChange;
            YubikeyDetector.Instance.Start();

            _devicePresent = YubikeyDetector.Instance.CurrentState;

            // Call once for initial setup
            YubikeyStateChange();

            _hsmUpdateTimer.Interval = 1000;
            _hsmUpdateTimer.Tick    += HsmUpdateTimerOnTick;
            _hsmUpdateTimer.Start();

            RefreshHSM();

            try
            {
                Domain domain = Domain.GetComputerDomain();

                if (!string.IsNullOrWhiteSpace(domain.Name))
                {
                    llBrowseStdUser.Visible = true;
                }
                llBrowseAdmUser.Visible = true;
            }
            catch (ActiveDirectoryObjectNotFoundException)
            {
                llBrowseStdUser.Visible = false;
                llBrowseAdmUser.Visible = false;
            }

            // Prepare algorithms
            foreach (YubikeyAlgorithm item in YubikeyPolicyUtility.GetYubicoAlgorithms())
            {
                drpAlgorithm.Items.Add(item);

                if (item.Value == _settings.DefaultAlgorithm)
                {
                    drpAlgorithm.SelectedItem = item;
                }
            }
        }
コード例 #6
0
        private void UpdateView()
        {
            if (_settings.EnrollmentManagementKey != null && _settings.EnrollmentManagementKey.Length > 0)
            {
                txtManagementKey.Text = BitConverter.ToString(_settings.EnrollmentManagementKey).Replace("-", "");
            }

            if (!string.IsNullOrWhiteSpace(_settings.CSREndpoint))
            {
                txtCSREndpoint.Text = _settings.CSREndpoint;
            }

            if (!string.IsNullOrWhiteSpace(_settings.EnrollmentCaTemplate))
            {
                txtCaTemplate.Text = _settings.EnrollmentCaTemplate;
            }

            if (!string.IsNullOrWhiteSpace(_settings.EnrollmentAgentCertificate))
            {
                _selectedCertificateThumb = _settings.EnrollmentAgentCertificate;
                WindowsCertificate cert = WindowsCertStoreUtilities.FindCertificate(_settings.EnrollmentAgentCertificate);

                if (cert != null)
                {
                    DisplaySelectedCertificate(cert);
                }
                else
                {
                    MessageBox.Show(this,
                                    "The certificate with the thumbprint " + _selectedCertificateThumb +
                                    " was not found in your certificate store.", "Certificate not found", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }

            if (_settings.DefaultAlgorithm > 0)
            {
                YubikeyAlgorithm algo = YubikeyPolicyUtility.GetYubicoAlgorithms().FirstOrDefault(s => s.Value == _settings.DefaultAlgorithm);

                if (algo != null)
                {
                    drpAlgorithm.SelectedItem = algo;
                }
            }
        }