Example #1
0
 public ActionResult Update(Bam.Net.Encryption.VaultItem dao)
 {
     try
     {
         dao.Save();
         return(Json(new { Success = true, Message = "", Dao = dao.ToJsonSafe() }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
Example #2
0
        private static VaultItem CreateFromFilter(IQueryFilter filter, Database database = null)
        {
            Database db  = database ?? Db.For <VaultItem>();
            var      dao = new VaultItem();

            filter.Parameters.Each(p =>
            {
                dao.Property(p.ColumnName, p.Value);
            });
            dao.Save(db);
            return(dao);
        }
Example #3
0
        public string this[string key]
        {
            get
            {
                if (Items.ContainsKey(key))
                {
                    return(Items[key].Value);
                }
                else
                {
                    Decrypt();
                    if (Items.ContainsKey(key))
                    {
                        return(Items[key].Value);
                    }
                }

                return(null);
            }
            set
            {
                lock (writeLock)
                {
                    if (Decrypt())
                    {
                        if (Items.ContainsKey(key))
                        {
                            Items[key].Value = value;
                        }
                        else
                        {
                            VaultItem item     = VaultItemsByVaultId.AddNew();
                            string    password = Key.PrivateKeyDecrypt(Key.Password);
                            item.Key   = key.AesPasswordEncrypt(password);
                            item.Value = value.AesPasswordEncrypt(password);
                            item.Save();
                            Items[key] = new DecryptedVaultItem(item, Key);
                        }
                    }
                }
            }
        }
Example #4
0
 public ActionResult Delete(long id)
 {
     try
     {
         string msg = "";
         Bam.Net.Encryption.VaultItem dao = Bam.Net.Encryption.VaultItem.OneWhere(c => c.KeyColumn == id);
         if (dao != null)
         {
             dao.Delete();
         }
         else
         {
             msg = string.Format("The specified id ({0}) was not found in the table (VaultItem)", id);
         }
         return(Json(new { Success = true, Message = msg, Dao = "" }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
Example #5
0
 public ActionResult Create(Bam.Net.Encryption.VaultItem dao)
 {
     return(Update(dao));
 }
Example #6
0
 public DecryptedVaultItem(VaultItem item, VaultKey key)
 {
     this.Item     = item;
     this.VaultKey = key;
 }