public void UpdateStoreInfo(string storename)
 {
     UIErrorHelper.CheckedExec(delegate() {
         if (storename != null)
         {
             string storePass = "";
             using (var session = new VecsStoreSession(ServerDTO.VecsClient, storename, storePass)) {
                 // update store info
                 if (StoresInfo.ContainsKey(storename))
                 {
                     StoresInfo [storename] = new CertBagItem()
                     {
                         PrivateKeys = session.GetPrivateKeys().Concat(session.GetEncryptedPrivateKeys()).ToList(),
                         SecretKeys  = session.GetSecretKeys().ToList(),
                         Certs       = session.GetCertificates().ToList()
                     };
                     CalculateKeyInfo();
                 }
                 else
                 {
                     StoresInfo.Add(storename, new CertBagItem()
                     {
                         PrivateKeys = session.GetPrivateKeys().Concat(session.GetEncryptedPrivateKeys()).ToList(),
                         SecretKeys  = session.GetSecretKeys().ToList(),
                         Certs       = session.GetCertificates().ToList()
                     });
                     NoStores++;
                 }
             }
         }
     });
 }
Beispiel #2
0
        public override void Refresh()
        {
            ResultNodes.Clear();

            var entriesNode = this.ScopeNode as VecsStoreEntriesNode;
            var dto         = entriesNode.ServerDTO;
            var storeName   = entriesNode.StoreName;
            var storePass   = "";

            MMCActionHelper.CheckedExec(delegate()
            {
                using (var session = new VecsStoreSession(dto.VecsClient, storeName, storePass))
                {
                    var lst = session.GetCertificates();
                    if (lst == null)
                    {
                        return;
                    }

                    foreach (var certDTO in lst)
                    {
                        var resultNode = new ResultNode {
                            DisplayName = certDTO.Alias
                        };
                        resultNode.ImageIndex = (int)VMCertStoreImageIndex.TrustedCert;
                        if (certDTO.Cert != null)
                        {
                            resultNode.SubItemDisplayNames.Add(certDTO.Cert.Subject);
                            resultNode.SubItemDisplayNames.Add(certDTO.Cert.Issuer);
                            resultNode.SubItemDisplayNames.Add(certDTO.Cert.NotBefore.ToShortDateString());
                            resultNode.SubItemDisplayNames.Add(certDTO.Cert.NotAfter.ToShortDateString());
                            resultNode.SubItemDisplayNames.Add(certDTO.Cert.GetKeyUsage());
                            resultNode.Tag = certDTO;
                        }

                        this.ResultNodes.Add(resultNode);
                    }
                }
            });
            this.Sort(0);
            this.DescriptionBarText = this.ResultNodes.Count.ToString();
        }
 public async void  FillServerInfo()
 {
     try {
         var stores = ServerDTO.VecsClient.GetStores();
         IsDetailsLoaded = true;
         StoresInfo.Clear();
         foreach (var store in stores)
         {
             var storePass = "";
             using (var session = new VecsStoreSession(ServerDTO.VecsClient, store, storePass)) {
                 //store add
                 StoresInfo.Add(store, new CertBagItem()
                 {
                     PrivateKeys = session.GetPrivateKeys().Concat(session.GetEncryptedPrivateKeys()).ToList(),
                     SecretKeys  = session.GetSecretKeys().ToList(),
                     Certs       = session.GetCertificates().ToList()
                 });
             }
         }
         CalculateKeyInfo();
     } catch (Exception e) {
         // do nothing in async task.
     }
 }