Пример #1
0
        public void AddCertificate(object sender, EventArgs args)
        {
            AddCertificateWindowController cwc = new AddCertificateWindowController();

            NSApplication.SharedApplication.BeginSheet(cwc.Window, VMCertStoreSnapInEnvironment.Instance.mainWindow, () => {
            });
            nint result = NSApplication.SharedApplication.RunModalForWindow(cwc.Window);

            try {
                if (result == (nint)VMIdentityConstants.DIALOGOK)
                {
                    var    dto       = cwc.CertificateDTO;
                    string storeName = (string)Tag;
                    string storePass = "";
                    using (var session = new VecsStoreSession(ServerNode.ServerDTO.VecsClient, storeName, storePass)) {
                        session.AddCertificateEntry(dto.Alias, "", "", dto.Certificate);
                    }
                    UIErrorHelper.ShowAlert("Successfully added Certificate", "Info");
                    ServerNode.UpdateStoreInfo(storeName);
                    NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadTableView", this);
                }
            } catch (Exception e) {
                UIErrorHelper.ShowAlert(e.Message, "Alert");
            } finally {
                VMCertStoreSnapInEnvironment.Instance.mainWindow.EndSheet(cwc.Window);
                cwc.Dispose();
            }
        }
 public void AddCertificate (object sender, EventArgs args)
 {
     AddCertificateWindowController cwc = new AddCertificateWindowController ();
     NSApplication.SharedApplication.BeginSheet (cwc.Window, VMCertStoreSnapInEnvironment.Instance.mainWindow, () => {
     });
     nint result = NSApplication.SharedApplication.RunModalForWindow (cwc.Window);
     try {
         if (result == (nint)VMIdentityConstants.DIALOGOK) {
             var dto = cwc.CertificateDTO;
             string storeName = (string)Tag;
             string storePass = "";
             using (var session = new VecsStoreSession (ServerNode.ServerDTO.VecsClient, storeName, storePass)) {
                 session.AddCertificateEntry (dto.Alias, "", "", dto.Certificate);
             }
             UIErrorHelper.ShowAlert ("Successfully added Certificate", "Info");
             ServerNode.UpdateStoreInfo (storeName);
             NSNotificationCenter.DefaultCenter.PostNotificationName ("ReloadTableView", this);
         }
     } catch (Exception e) {
         UIErrorHelper.ShowAlert (e.Message, "Alert");
     } finally {
         VMCertStoreSnapInEnvironment.Instance.mainWindow.EndSheet (cwc.Window);
         cwc.Dispose ();
     }
 }
Пример #3
0
 public void AddRootCertificate()
 {
     UIErrorHelper.CheckedExec(delegate() {
         var dto = new AddCertificateDTO {
             PrivateKey = new PrivateKeyDTO()
         };
         AddCertificateWindowController cwc = new AddCertificateWindowController(dto);
         nint result = NSApplication.SharedApplication.RunModalForWindow(cwc.Window);
         if (result == (int)Constants.DIALOGOK)
         {
             var cert = File.ReadAllText(dto.Certificate);
             ServerDTO.VMCAClient.AddRootCertificate(cert, "", dto.PrivateKey.ToString());
         }
     });
 }