Ejemplo n.º 1
0
        /*************************************************************************************************/
        public bool AddPassword(DatabasePassword password)
        {
            Int64 uniqueID = 0;
            bool  result   = false;

            if (password != null)
            {
                if (_encryptedPasswords.Count != 0)
                {
                    uniqueID = _encryptedPasswords[_encryptedPasswords.Count - 1].UniqueID + 1;
                }

                DatabasePassword newPassword = new DatabasePassword(
                    uniqueID,
                    password.UserGUID,
                    password.Application,
                    password.Username,
                    password.Email,
                    password.Description,
                    password.Website,
                    password.Passphrase);

                _encryptedPasswords.Add(newPassword);
                _csvPasswordManager.UpdatePasswordCSVFile(_passwordsCsvPath, _encryptedPasswords);

                result = true;
            }

            return(result);
        }
Ejemplo n.º 2
0
        /*************************************************************************************************/
        public bool ModifyPassword(DatabasePassword password, DatabasePassword modifiedPassword)
        {
            bool result = false;

            int index = _localPasswordDb.FindIndex(x => x.UniqueID == password.UniqueID);

            if (index != -1)
            {
                _localPasswordDb[index] = modifiedPassword;
                result = true;
            }
            else
            {
                result = false;
            }

            return(result);
        }
Ejemplo n.º 3
0
        /*=================================================================================================
        *       PRIVATE METHODS
        *================================================================================================*/
        /*************************************************************************************************/
        /*************************************************************************************************/
        private DatabasePassword ParseLine(string line)
        {
            DatabasePassword pass = null;

            string[] fields = line.Split(',');

            if (fields.Length == (int)CsvPasswordIndexes.NumIndexes)
            {
                pass = new DatabasePassword(Convert.ToInt64(fields[(int)CsvPasswordIndexes.UniqueId], CultureInfo.CurrentCulture),
                                            fields[(int)CsvPasswordIndexes.UserId],
                                            fields[(int)CsvPasswordIndexes.Application],
                                            fields[(int)CsvPasswordIndexes.Username],
                                            fields[(int)CsvPasswordIndexes.Email],
                                            fields[(int)CsvPasswordIndexes.Description],
                                            fields[(int)CsvPasswordIndexes.Website],
                                            fields[(int)CsvPasswordIndexes.Password]);
            }

            return(pass);
        }
Ejemplo n.º 4
0
        /*************************************************************************************************/
        public bool AddPassword(DatabasePassword password)
        {
            bool result = false;

            if (password != null)
            {
                using (var dbConn = DbConnection)
                {
                    dbConn.Open();

                    string query = @"INSERT INTO Passwords 
                                    (UserGUID, Application, Username, Email, Description, Website, Passphrase)
                                 VALUES(
                                    @UserGUID,
                                    @Application,
                                    @Username,
                                    @Email,
                                    @Description,
                                    @Website,
                                    @Passphrase)";

                    int dbresult = dbConn.Execute(query, new
                    {
                        UserGUID    = password.UserGUID,
                        Application = password.Application,
                        Username    = password.Username,
                        Email       = password.Email,
                        Description = password.Description,
                        Website     = password.Website,
                        Passphrase  = password.Passphrase,
                    });

                    if (dbresult != 0)
                    {
                        result = true;
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 5
0
        /*************************************************************************************************/
        public bool DeletePassword(DatabasePassword password)
        {
            bool result = false;

            if (password != null)
            {
                int index = GetIndexOfPassword(password.UniqueID);

                if (index != -1)
                {
                    _encryptedPasswords.RemoveAt(index);
                    _csvPasswordManager.UpdatePasswordCSVFile(_passwordsCsvPath, _encryptedPasswords);
                    result = true;
                }
                else
                {
                    result = false;
                }
            }

            return(result);
        }
Ejemplo n.º 6
0
        /*************************************************************************************************/
        public bool ModifyPassword(DatabasePassword password, DatabasePassword modifiedPassword)
        {
            bool result = false;

            if (password != null && modifiedPassword != null)
            {
                int index = GetIndexOfPassword(password.UniqueID);

                if (index != -1)
                {
                    _encryptedPasswords[index] = modifiedPassword;
                    _csvPasswordManager.UpdatePasswordCSVFile(_passwordsCsvPath, _encryptedPasswords);
                    result = true;
                }
                else
                {
                    result = false;
                }
            }

            return(result);
        }
Ejemplo n.º 7
0
        /*************************************************************************************************/
        public bool ModifyPassword(DatabasePassword password, DatabasePassword modifiedPassword)
        {
            bool result = false;

            if (password != null && modifiedPassword != null)
            {
                using (var dbConn = DbConnection)
                {
                    dbConn.Open();

                    string query = @"UPDATE Passwords 
                                 SET Application = @Application, 
                                     Username = @Username, 
                                     Email = @Email,
                                     Description = @Description,
                                     Website = @Website,
                                     Passphrase = @Passphrase
                                 WHERE UniqueID = @UniqueID";

                    var dbResult = dbConn.Execute(query, new
                    {
                        Application = modifiedPassword.Application,
                        Username    = modifiedPassword.Username,
                        Email       = modifiedPassword.Email,
                        Description = modifiedPassword.Description,
                        Website     = modifiedPassword.Website,
                        Passphrase  = modifiedPassword.Passphrase,
                        UniqueID    = password.UniqueID
                    });

                    if (dbResult > 0)
                    {
                        result = true;
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 8
0
        /*************************************************************************************************/
        public bool DeletePassword(DatabasePassword password)
        {
            bool result = false;

            if (password != null)
            {
                using (var dbConn = DbConnection)
                {
                    dbConn.Open();

                    string query = @"DELETE FROM Passwords
                                 WHERE UniqueID = @UniqueID";

                    var dbResult = dbConn.Execute(query, new { UniqueID = password.UniqueID });

                    if (dbResult == 1)
                    {
                        result = true;
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 9
0
 private void Resetbutton_Click(object sender, EventArgs e)
 {
     DatabaseULR.Clear();
     DatabaseName.Clear();
     DatabasePassword.Clear();
 }
Ejemplo n.º 10
0
 public bool DeletePassword(DatabasePassword password)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 11
0
 public bool ModifyPassword(DatabasePassword password, DatabasePassword modifiedPassword)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 12
0
 /*************************************************************************************************/
 public bool DeletePassword(DatabasePassword password)
 {
     _localPasswordDb.RemoveAll(x => x.UniqueID == password.UniqueID);
     return(true);
 }
Ejemplo n.º 13
0
 /*=================================================================================================
 *       PUBLIC METHODS
 *================================================================================================*/
 /*************************************************************************************************/
 public bool AddPassword(DatabasePassword password)
 {
     _localPasswordDb.Add(password);
     return(true);
 }