示例#1
0
        public void InitDefaultPwd(string accessToken)
        {
            var initBytes  = Encoding.UTF8.GetBytes(string.Concat(SaltValue1, BaseCode, SaltValue2));
            var defaultPwd = GeneralToolkitLib.Hashing.SHA256.GetSHA256HashAsHexString(initBytes);

            _passwordStorage.Set(accessToken, defaultPwd);
        }
示例#2
0
        public BookmarkService(BookmarkManager bookmarkManager, ApplicationSettingsService applicationSettingsService)
        {
            _bookmarkManager            = bookmarkManager;
            _applicationSettingsService = applicationSettingsService;
            _protectedMemoryStorageKey  = new SecureRandomGenerator().GetAlphaNumericString(256);
            _directory = ApplicationBuildConfig.UserDataPath;

            applicationSettingsService.LoadSettings();

            _passwordStorage = new PasswordStorage();
            _passwordStorage.Set(_protectedMemoryStorageKey, GetDefaultPassword());
        }
示例#3
0
        private void SaveToSharedFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!_appSettingsService.Settings.UseSharedSyncFolder)
            {
                MessageBox.Show(Resources.FormMain_saveToSharedFolderMenuDisabled, Resources.FormMain__Could_not_save, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (string.IsNullOrWhiteSpace(_appSettingsService.Settings.SyncFolderPath) || !Directory.Exists(_appSettingsService.Settings.SyncFolderPath))
            {
                MessageBox.Show(Resources.FormMain_saveToSharedFoldrMenuInvalidPath, Resources.FormMain__Could_not_save, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            var formSetPassword = new FormSetPassword();

            if (formSetPassword.ShowDialog(this) != DialogResult.OK)
            {
                formSetPassword.Dispose();
                return;
            }


            string password = formSetPassword.VerifiedPassword;

            _passwordStorage.Set("SharedFolderPassword", password);
            formSetPassword.Dispose();

            bool result = _logicManager.SaveToSharedFolder();

            if (result)
            {
                MessageBox.Show("Database successfully saved to sync folder", Resources.FormMain__Database_Saved, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Failed to save database to sync folder path", Resources.FormMain__Could_not_save, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#4
0
        private void createNewDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (
                MessageBox.Show(this, "Do you want to create a new Memo database? Doing so will overwrite any existing stored database under this account.", "Create new database?",
                                MessageBoxButtons.OKCancel, MessageBoxIcon.Question) !=
                DialogResult.OK)
            {
                return;
            }

            var frmsetPassword = new FormSetPassword {
                Text = "Choose password"
            };

            if (frmsetPassword.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            string password = frmsetPassword.VerifiedPassword;

            if (string.IsNullOrEmpty(password))
            {
                MessageBox.Show(this, "Password can not be empty!", Resources.FormMain__ErrorText, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            _passwordStorage.Set(PwdKey, password);
            _tabPageDataCollection = TabPageDataCollection.CreateNewPageDataCollection(_appSettingsService.Settings.DefaultEmptyTabPages);
            _memoStorageService.SaveTabPageCollection(_tabPageDataCollection, password);

            _appSettingsService.Settings.PasswordDerivedString =
                GeneralConverters.GeneratePasswordDerivedString(_appSettingsService.Settings.ApplicationSaltValue + password + _appSettingsService.Settings.ApplicationSaltValue);

            _appSettingsService.SaveSettings();
            InitializeTabControls();
            _applicationState.DatabaseLoaded = true;
            _applicationState.DatabaseExists = true;
            UpdateApplicationState();
        }
示例#5
0
        public bool OpenBookmarks(string password)
        {
            string filename = _directory + BookmarkFileName;

            if (!File.Exists(filename))
            {
                return(false);
            }

            bool loadSuccessful = _bookmarkManager.LoadFromFile(filename, password);

            if (loadSuccessful)
            {
                _passwordStorage.Set(_protectedMemoryStorageKey, password);
                Log.Information("Loaded bookmarks from file");
                return(true);
            }
            Log.Error("Failed to load bookmarks from file");
            return(false);
        }