Example #1
0
        /// <summary>
        /// Handle node actions
        /// </summary>
        /// <param name="action">action that was triggered</param>
        /// <param name="status">asynchronous status for updating the console</param>
        protected override void OnAction(Microsoft.ManagementConsole.Action action, AsyncStatus status)
        {
            switch ((string)action.Tag)
            {
            case "IssueCert":         //issue cert
                IssCert issue = new IssCert(caInfo);
                if (this.SnapIn.Console.ShowDialog(issue) == DialogResult.OK)
                {
                    CertSave certSave = new CertSave(caInfo);
                    certSave.cert = issue.cert;
                    this.SnapIn.Console.ShowDialog(certSave);

                    // notify any listening views that a change happened
                    RaiseOnChange((string)action.Tag);
                }
                break;

            case "IssueCRL":     // Issue CRL
                string  result = caInfo.IssueCRL();
                X509Crl crl    = caInfo.GetCRL();
                // Save the result
                CRLsave crlSave = new CRLsave();
                crlSave.crl = crl;
                this.SnapIn.Console.ShowDialog(crlSave);
                break;
            }
        }
Example #2
0
        /// <summary>
        /// Handle short cut style menu actions for selection
        /// </summary>
        /// <param name="action">triggered action</param>
        /// <param name="status">asynchronous status used to update the console</param>
        protected override void OnSelectionAction(Microsoft.ManagementConsole.Action action, AsyncStatus status)
        {
            X509Certificate cert = (X509Certificate)this.SelectedNodes[0].Tag;

            switch ((string)action.Tag)
            {
            case "ViewCert":
                SystemX509.X509Certificate2UI.DisplayCertificate(new SystemX509.X509Certificate2(cert.GetEncoded()));
                break;

            case "ExportCert":
                CertSave certSave = new CertSave(context.caInfo);
                certSave.cert = cert;
                this.SnapIn.Console.ShowDialog(certSave);
                break;

            case "RevokeCert":
                revokeCert revoke = new revokeCert(cert);
                if (this.SnapIn.Console.ShowDialog(revoke) == DialogResult.OK)
                {
                    context.caInfo.RevokeCertificate(cert, (CRLReason)revoke.cbReason.SelectedIndex);
                    Refresh();
                }
                break;

            case "RenewCert":

                break;

            case "RekeyCert":
                RekeyCert rekey = new RekeyCert(context.caInfo, cert);
                if (this.SnapIn.Console.ShowDialog(rekey) == DialogResult.OK)
                {
                    certSave      = new CertSave(context.caInfo);
                    certSave.cert = rekey.cert;
                    this.SnapIn.Console.ShowDialog(certSave);
                    Refresh();
                }
                break;

            case "UnRevokeCert":
                context.caInfo.UnRevokeCertificate(cert);
                Refresh();
                break;
            }
        }