Esempio n. 1
0
 public override string GetCellData(string columnName, KeePassLib.PwEntry entry)
 {
     switch (columnName)
     {
     case sshKeyStatusColumnName:
         var agentModeAgent = ext.agent as Agent;
         if (agentModeAgent != null && agentModeAgent.IsLocked)
         {
             return("Agent Locked");
         }
         try {
             var key = entry.GetSshKey();
             if (key == null)
             {
                 return("N/A");
             }
             if (ext.agent.GetAllKeys().Get(key.Version, key.GetPublicKeyBlob()) != null)
             {
                 return("Loaded");
             }
         } catch (PpkFormatterException) {
             return("Error");
         } catch (Exception ex) {
             Debug.Fail(ex.Message);
             return("*Error");
         }
         return("Not Loaded");
     }
     Debug.Fail(string.Format("Unknown column name: {0}", columnName));
     return(string.Empty);
 }
Esempio n. 2
0
        public override void PerformCellAction(string columnName, KeePassLib.PwEntry entry)
        {
            switch (columnName)
            {
            case sshKeyStatusColumnName:
                try {
                    var key = entry.GetSshKey();
                    if (key == null)
                    {
                        break;
                    }
                    var agentKey = ext.agent.GetAllKeys().Get(key.Version, key.GetPublicKeyBlob());
                    if (agentKey == null)
                    {
                        ext.AddEntry(entry, null);
                    }
                    else
                    {
                        ext.agent.RemoveKey(agentKey);
                    }
                } catch (Exception ex) {
                    Debug.Fail(ex.Message);
                }
                break;

            default:
                Debug.Fail(string.Format("Unsupported column: {0}", columnName));
                break;
            }
        }
Esempio n. 3
0
        private string CreateAddress(IotaSetting settings)
        {
            var group = this.m_host.Database.RootGroup.FindCreateGroup(settings.FolderName, true);

            var entry = new KeePassLib.PwEntry(true, true);

            entry.Strings.Set(PwDefs.TitleField, new KeePassLib.Security.ProtectedString(false, settings.EntryTitle));
            KeePassLib.Security.ProtectedString protectedStringSeed = CreateSeed();
            entry.Strings.Set(PwDefs.PasswordField, protectedStringSeed);
            group.AddEntry(entry, true);

            if (protectedStringSeed.IsEmpty)
            {
                return("Seed value is empty!");
            }
            var seed = protectedStringSeed.ReadString();

            var addresses = new List <string>();

            for (int i = 0; i < settings.NoOfAddress; i++)
            {
                var address = this.CreateAddress(protectedStringSeed.ReadString(), i, settings.SecurityLevel);
                addresses.Add(address);

                if (this.ProgressChanged != null)
                {
                    this.ProgressChanged(this, new EventArgs());
                }
            }

            if (settings.Storagelocation == Storagelocation.Notes)
            {
                var notesString     = String.Join("\n", addresses.Select((address, i) => $"Address {i.ToString().PadLeft(3, '0')} {address}"));
                var protectedString = new KeePassLib.Security.ProtectedString(false, notesString);
                entry.Strings.Set(PwDefs.NotesField, protectedString);
            }
            else
            {
                for (int i = 0; i < addresses.Count; i++)
                {
                    var addressName     = "Address " + i.ToString().PadLeft(3, '0');
                    var protectedString = new KeePassLib.Security.ProtectedString(false, addresses[i]);
                    entry.Strings.Set(addressName, protectedString);
                }
            }

            try
            {
                CheckAndAddIotaIcon();
                entry.CustomIconUuid = new PwUuid(this.iconUuId);
            }
            catch { }

            this.m_host.Database.Modified = true;
            // Force the groups to refresh
            m_host.MainWindow.UpdateUI(false, null, true, m_host.Database.RootGroup, true, null, true);

            return("Addresses created");
        }
Esempio n. 4
0
 /// <summary>
 /// Add an entry to this group.
 /// </summary>
 /// <param name="pe">Entry to be added. Must not be <c>null</c>.</param>
 /// <param name="bTakeOwnership">If this parameter is <c>true</c>, the
 /// parent group reference of the entry will be set to the current
 /// group (i.e. the current group takes ownership of the entry).</param>
 public void AddEntry(PwEntry pe, bool bTakeOwnership)
 {
     AddEntry(pe, bTakeOwnership, false);
 }