Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 5
0
 public ActionResult Create(Bam.Net.Encryption.VaultItem dao)
 {
     return(Update(dao));
 }
Ejemplo n.º 6
0
 public DecryptedVaultItem(VaultItem item, VaultKey key)
 {
     this.Item     = item;
     this.VaultKey = key;
 }