public AccountListWindow(long userId)
 {
     InitializeComponent();
     this.userId         = userId;
     this.sqLiteDbHelper = SQLiteDbHelper.getInstance();
     this.showAllAccounts();
 }
Example #2
0
        private void saveData(String username, String password)
        {
            SQLiteDbHelper sqliteDbHelper = SQLiteDbHelper.getInstance();

            byte[] salt = CryptoHelper.generateSalt();
            byte[] hash = CryptoHelper.HashPassword(password, salt);
            sqliteDbHelper.insertUser(username, hash, salt);
        }
Example #3
0
        public AccountDetailsWindow(State state, long userId)
        {
            InitializeComponent();
            this.currentState = state;
            this.userId       = userId;
            SQLiteDbHelper sqLiteDbHelper = SQLiteDbHelper.getInstance();

            this.hash = sqLiteDbHelper.getUserHash(this.userId);
        }
Example #4
0
 public AccountDetailsWindow(State state, long accountId, long userId)
 {
     InitializeComponent();
     this.currentState = state;
     this.userId       = userId;
     if (this.currentState == State.Edit)
     {
         SQLiteDbHelper sqLiteDbHelper = SQLiteDbHelper.getInstance();
         this.accountDetails = sqLiteDbHelper.selectWithId(accountId, userId);
         this.hash           = sqLiteDbHelper.getUserHash(this.userId);
         this.fillFields(accountDetails);
     }
 }
Example #5
0
        private Boolean authenticateUser(String username, String password)
        {
            SQLiteDbHelper sqliteDbHelper = SQLiteDbHelper.getInstance();
            List <User>    selectedUsers  = sqliteDbHelper.selectUser(username);

            foreach (User user in selectedUsers)
            {
                if (CryptoHelper.ValidatePassword(password, user.Hash, user.Salt))
                {
                    this.userId = user.Id;
                    return(true);
                }
            }
            return(false);
        }
Example #6
0
        public void onSaveBtnClicked(object sender, RoutedEventArgs e)
        {
            SQLiteDbHelper sqLiteDbHelper = SQLiteDbHelper.getInstance();
            String         passwordText   = this.getPasswordFieldText();

            byte[] salt              = CryptoHelper.generateSalt();
            String saltString        = Convert.ToBase64String(salt);
            String encryptedPassword = CryptoHelper.EncryptStringAES(passwordText, hash, salt);

            if (this.currentState == State.Add)
            {
                sqLiteDbHelper.insert(this.userId, titleField.Text, usernameField.Text, encryptedPassword, saltString);
            }
            else
            {
                AccountDetails updatedAccountDetails = new AccountDetails(this.accountDetails.Id, titleField.Text, usernameField.Text, encryptedPassword, saltString);
                sqLiteDbHelper.update(updatedAccountDetails, this.userId);
            }

            this.Close();
        }