Esempio n. 1
0
 public KeySearchView(KeyserverPublicKey srchKey)
 {
     this.keyLine = srchKey.keyLine;
     this.keyId   = srchKey.pubLine.keyId;
     if (srchKey.uidLines.Count > 0)
     {
         this.uidString = srchKey.uidLines[0].uidString;
     }
     this.keyCreatedDate = srchKey.pubLine.keyCreatedDate;
     this.keyExpiredDate = srchKey.pubLine.keyExpiredDate;
     this.algorithm      = ((PublicKeyAlgorithmTag)srchKey.pubLine.algorithm).ToString();
     this.keySize        = srchKey.pubLine.keySize;
 }
        public async Task ReadResults(string searchValue)
        {
            string resp = await client.GetStringAsync(string.Format(srchString, searchValue));

            if (!string.IsNullOrEmpty(resp))
            {
                int keyLine    = 0;
                int uidLineCnt = 0;
                KeyserverPublicKey svrPublicKey = new KeyserverPublicKey();
                bool saveSvrEntry = false;
                foreach (string respLine in resp.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
                {
                    string[] lineType = respLine.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);

                    if (lineType != null && lineType.Count() > 0)
                    {
                        switch (lineType[0])
                        {
                        case "info":
                            break;

                        case "pub":
                            svrPublicKey.keyLine = keyLine++;
                            uidLineCnt           = 0;
                            if (saveSvrEntry)
                            {
                                m_SearchResults.Add(svrPublicKey);
                            }
                            svrPublicKey          = new KeyserverPublicKey();
                            saveSvrEntry          = true;
                            svrPublicKey.pubLine  = new PubLine(respLine);
                            svrPublicKey.uidLines = new List <UidLine>();
                            break;

                        case "uid":
                            svrPublicKey.uidLines.Add(new UidLine(respLine, uidLineCnt++));
                            break;

                        default:
                            break;
                        }
                    }
                }
                m_SearchResults.Add(svrPublicKey); // get the last entry
            }
        }