A filter that can be applied to a list of certificates.
        /// <summary>
        /// Sets the filter.
        /// </summary>
        /// <param name="filter">The filter.</param>
        internal void SetFilter(CertificateListFilter filter)
        {
            if (m_items == null || m_items.Count == 0)
            {
                return;
            }

            if (ItemsLV.View == View.List)
            {
                ItemsLV.Items.Clear();
                ItemsLV.View = View.Details;
            }

            for (int ii = 0; ii < m_items.Count; ii++)
            {
                ListViewItem item = m_items[ii];

                X509Certificate2 certificate = item.Tag as X509Certificate2;

                if (certificate == null)
                {
                    continue;
                }

                if (item.ListView != null)
                {
                    if (!filter.Match(certificate))
                    {
                        item.Remove();
                    }
                }
                else
                {
                    if (filter.Match(certificate))
                    {
                        ItemsLV.Items.Add(item);
                    }
                }
            }

            if (ItemsLV.Items.Count == 0)
            {
                Instructions = "No certificates meet the current filter criteria.";
                AdjustColumns();
                return;
            }
        }
Ejemplo n.º 2
0
        private void FilterBTN_Click(object sender, EventArgs e)
        {
            try
            {
                CertificateListFilter filter = new CertificateListFilter();
                filter.SubjectName = SubjectNameTB.Text.Trim();
                filter.IssuerName  = IssuerNameTB.Text.Trim();
                filter.Domain      = DomainTB.Text.Trim();
                filter.PrivateKey  = PrivateKeyCK.Checked;

                List <CertificateListFilterType> types = new List <CertificateListFilterType>();

                if (ApplicationCK.Checked)
                {
                    types.Add(CertificateListFilterType.Application);
                }

                if (CaCK.Checked)
                {
                    types.Add(CertificateListFilterType.CA);
                }

                if (SelfSignedCK.Checked)
                {
                    types.Add(CertificateListFilterType.SelfSigned);
                }

                if (IssuedCK.Checked)
                {
                    types.Add(CertificateListFilterType.Issued);
                }

                if (types.Count > 0)
                {
                    filter.CertificateTypes = types.ToArray();
                }

                CertificatesCTRL.SetFilter(filter);
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
        private void FilterBTN_Click(object sender, EventArgs e)
        {
            try
            {
                CertificateListFilter filter = new CertificateListFilter();
                filter.SubjectName = SubjectNameTB.Text.Trim();
                filter.IssuerName = IssuerNameTB.Text.Trim();
                filter.Domain = DomainTB.Text.Trim();
                filter.PrivateKey = PrivateKeyCK.Checked;

                List<CertificateListFilterType> types = new List<CertificateListFilterType>();

                if (ApplicationCK.Checked)
                {
                    types.Add(CertificateListFilterType.Application);
                }

                if (CaCK.Checked)
                {
                    types.Add(CertificateListFilterType.CA);
                }

                if (SelfSignedCK.Checked)
                {
                    types.Add(CertificateListFilterType.SelfSigned);
                }

                if (IssuedCK.Checked)
                {
                    types.Add(CertificateListFilterType.Issued);
                }

                if (types.Count > 0)
                {
                    filter.CertificateTypes = types.ToArray();
                }

                CertificatesCTRL.SetFilter(filter);
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Sets the filter.
        /// </summary>
        /// <param name="filter">The filter.</param>
        internal void SetFilter(CertificateListFilter filter)
        {
            if (m_items == null || m_items.Count == 0)
            {
                return;
            }

            if (ItemsLV.View == View.List)
            {
                ItemsLV.Items.Clear();
                ItemsLV.View = View.Details;
            }

            for (int ii = 0; ii < m_items.Count; ii++)
            {
                ListViewItem item = m_items[ii];

                X509Certificate2 certificate = item.Tag as X509Certificate2;
                
                if (certificate == null)
                {
                    continue;
                }

                if (item.ListView != null)
                {
                    if (!filter.Match(certificate))
                    {
                        item.Remove();
                    }
                }
                else
                {
                    if (filter.Match(certificate))
                    {
                        ItemsLV.Items.Add(item);
                    }
                }
            }

            if (ItemsLV.Items.Count == 0)
            {
                Instructions = "No certificates meet the current filter criteria.";
                AdjustColumns();
                return;
            }
        }