Beispiel #1
0
        void RevokeCertificate()
        {
            MMCActionHelper.CheckedExec(delegate()
            {
                var cert      = this.SelectedNodes[0].Tag as X509Certificate2;
                var serverDTO = (ScopeNode.Parent as VMCAServerNode).ServerDTO;
                var vmcaCert  = new VMCACertificate(serverDTO.VMCAClient, cert);
                vmcaCert.Revoke();
                ResultNodes.Remove(this.SelectedNodes[0] as ResultNode);
            });
            RefreshList();
            var parent = this.ScopeNode.Parent as VMCAServerNode;

            if (parent != null)
            {
                foreach (var node in parent.Children)
                {
                    var certNode = node as VMCACertsNode;
                    if (certNode != null && (CertificateState)certNode.Tag == CertificateState.Revoked)
                    {
                        certNode.DoRefresh();
                    }
                }
            }
        }
Beispiel #2
0
 public static void Validate(VMCAServerDTO serverDTO, string cert)
 {
     try {
         VMCACertificate.Validate(cert);
     } catch (Exception e) {
         throw e;
     }
 }
Beispiel #3
0
 public static void RevokeCertificate(X509Certificate2 cert, VMCAServerDTO dto)
 {
     try {
         var vmcaCert = new VMCACertificate(dto.VMCAClient, cert);
         vmcaCert.Revoke();
     } catch (Exception e) {
         throw e;
     }
 }
Beispiel #4
0
 void ShowCertificateString()
 {
     MMCActionHelper.CheckedExec(delegate()
     {
         var cert = this.SelectedNodes[0].Tag as X509Certificate2;
         var frm  = new InfoForm(VMCACertificate.GetCertificateAsString(cert));
         frm.Icon = VMCASnapInEnvironment.Instance.GetIconResource(VMCAIconIndex.cert);
         MMCDlgHelper.ShowForm(frm);
     });
 }
 void RevokeCertificate()
 {
     MMCActionHelper.CheckedExec(delegate()
     {
         var cert      = this.SelectedNodes[0].Tag as X509Certificate2;
         var serverDTO = (ScopeNode.Parent as VMCAServerNode).ServerDTO;
         var vmcaCert  = new VMCACertificate(serverDTO.VMCAClient, cert);
         vmcaCert.Revoke();
         ResultNodes.Remove(this.SelectedNodes[0] as ResultNode);
     });
 }
Beispiel #6
0
        public override NSMenu MenuForEvent(NSEvent theEvent)
        {
            UIErrorHelper.CheckedExec(delegate() {
                CGPoint pt   = this.ConvertPointFromView(theEvent.LocationInWindow, null);
                _selectedRow = this.GetRow(pt);
                //get datasource and node information
                NSTableViewDataSource ds = (NSTableViewDataSource)this.DataSource;
                NSMenu menu = new NSMenu();
                if (_selectedRow >= 0)
                {
                    if (ds is NodesListView)
                    {
                        string data = (ds as NodesListView).Entries [(int)_selectedRow].DisplayName;
                        switch (data)
                        {
                        case "Key Pairs":
                            NSMenuItem createKeyPair = new NSMenuItem("Create Key Pair", HandleKeyPairRequest);
                            menu.AddItem(createKeyPair);
                            break;

                        case "Certificates":
                            NSMenuItem createCertificate = new NSMenuItem("Create Certificate", HandleCreateSelfSignedCertificate);
                            menu.AddItem(createCertificate);
                            break;

                        case "Signing Requests":
                            NSMenuItem createSigningRequest = new NSMenuItem("Create SigningRequest", HandleCreateSigningRequest);
                            menu.AddItem(createSigningRequest);
                            break;

                        default:
                            break;
                        }
                    }
                    else if (ds is CertificateDetailsListView || ds is PrivateCertsListView)
                    {
                        X509Certificate2 cert = null;
                        if (ds is CertificateDetailsListView)
                        {
                            CertificateDetailsListView lw = ds as CertificateDetailsListView;
                            cert = lw.Entries [(int)_selectedRow];
                            if (lw.CertificateState == (int)VMCA.CertificateState.Active)
                            {
                                NSMenuItem revokeCert = new NSMenuItem("Revoke Certificate", (object sender, EventArgs e) => {
                                    UIErrorHelper.CheckedExec(delegate() {
                                        VMCACertificateService.RevokeCertificate(cert, lw.ServerDto);
                                        NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadAll", this);
                                    });
                                });
                                menu.AddItem(revokeCert);
                            }
                        }
                        if (ds is PrivateCertsListView)
                        {
                            cert = CertificateExtensions.GetX509Certificate2FromString((ds as PrivateCertsListView).Entries [(int)_selectedRow].Certificate);
                        }
                        NSMenuItem showCert = new NSMenuItem("Show Certificate", (object sender, EventArgs e) => {
                            CertificateService.DisplayX509Certificate2(this, cert);
                        });
                        menu.AddItem(showCert);

                        NSMenuItem showCertString = new NSMenuItem("Show Certificate String", (object sender, EventArgs e) => {
                            UIHelper.ShowGenericWindowAsSheet(VMCACertificate.GetCertificateAsString(cert), "Certificate String", VMCAAppEnvironment.Instance.MainWindow);
                        });
                        menu.AddItem(showCertString);

                        /* if (lw.CertificateState == -1) {
                         * NSMenuItem deleteString = new NSMenuItem ("Delete Certificate", (object sender, EventArgs e) => {
                         *  lw.ServerDto.PrivateCertificates.RemoveAll (x => x.Certificate.Equals (cert.ToString ()));
                         *  NSNotificationCenter.DefaultCenter.PostNotificationName ("ReloadTableView", this);
                         *
                         * });
                         * menu.AddItem (deleteString);
                         * }*/
                    }
                    else if (ds is CSRDetailListView)
                    {
                        CSRDetailListView lw = ds as CSRDetailListView;
                        var csr             = lw.Entries [(int)_selectedRow].CSR;
                        NSMenuItem showCert = new NSMenuItem("Show CSR", (object sender, EventArgs e) => {
                            UIHelper.ShowGenericWindowAsSheet(csr, "CSR", VMCAAppEnvironment.Instance.MainWindow);
                        });
                        menu.AddItem(showCert);
                    }
                    else if (ds is KeyPairDetailListView)
                    {
                        KeyPairDetailListView lw = ds as KeyPairDetailListView;
                        var privateKey           = lw.Entries [(int)_selectedRow].PrivateKey;
                        var publicKey            = lw.Entries [(int)_selectedRow].PublicKey;
                        KeyPairData keyPair      = new KeyPairData(privateKey, publicKey);
                        NSMenuItem showCert      = new NSMenuItem("Export KeyPair", (object sender, EventArgs e) => {
                            VMCAKeyPairNode.SaveKeyData(keyPair);
                        });
                        menu.AddItem(showCert);
                    }
                    NSMenu.PopUpContextMenu(menu, theEvent, theEvent.Window.ContentView);
                }
            });
            return(base.MenuForEvent(theEvent));
        }