public bool CanCreateVault(VaultParams vaultParams) { if (null == vaultParams) { return(false); } if (string.IsNullOrWhiteSpace(vaultParams.FilePath)) { return(false); } //if (!Uri.IsWellFormedUriString("file:///" + vaultParams.FilePath.Replace("\\", "/"), UriKind.Absolute)) //{ // return false; //} if (string.IsNullOrWhiteSpace(vaultParams.Name)) { return(false); } if (null == vaultParams.Password || null == vaultParams.ValidationPassword) { return(false); } if (!SecureStringExtension.Equals(vaultParams.Password, vaultParams.ValidationPassword)) { return(false); } return(true); }
public bool CanChangePassword(VaultParams vaultParams) { if (!Vault.Exists()) { return(false); } if (null == vaultParams.Password || vaultParams.Password.Length <= 0) { return(false); } if (null == vaultParams.ValidationPassword || vaultParams.ValidationPassword.Length <= 0) { return(false); } if (!SecureStringExtension.Equals(vaultParams.Password, vaultParams.ValidationPassword)) { return(false); } return(true); }
public bool CanOpenVault(VaultParams vaultParams) { if (null == vaultParams) { return(false); } if (string.IsNullOrWhiteSpace(vaultParams.FilePath)) { return(false); } //if (!Uri.IsWellFormedUriString("file:///" + vaultParams.FilePath.Replace("\\", "/"), UriKind.Absolute)) //{ // return false; //} if (!File.Exists(vaultParams.FilePath)) { return(false); } if (null == vaultParams.Password || vaultParams.Password.Length <= 0) { return(false); } return(true); }
private void OpenVault(VaultParams vaultParams) { System.Diagnostics.Debug.WriteLine($"-- OpenVault -> vaultParams.FilePath = {vaultParams.FilePath}"); if (Vault.Exists()) { // TODO: Figure out what to do with this var _vault = Vault.GetInstance(); _vault.EncryptToFile(_vault.Location, _vault.EncryptionInfo.ProtectedKey); Vault.Delete(); } if (string.IsNullOrWhiteSpace(vaultParams.FilePath)) { throw new ArgumentNullException("filePath", "Path to file is either null or empty."); } var vault = Vault.GetInstance(); try { vault.DecryptFromFile(vaultParams.FilePath, vaultParams.Password); vault.SetupProtectedKey(vaultParams.Password); _navigationService.Navigate <VaultViewModel>(); } catch (Exception e) { Vault.Delete(); _messageInteraction.Raise(new MessageInteraction(e.Message)); } }
public DatabaseView() { InitializeComponent(); Parameters = new VaultParams(); EncryptionInfo = new EncryptionInfo { DeriviationRounds = 10000, SelectedAlgorithm = Algorithm.AES_256, }; }
public OpenVaultView() { InitializeComponent(); Parameters = new VaultParams(); var set = this.CreateBindingSet <OpenVaultView, OpenVaultViewModel>(); set.Bind(this).For(view => view.Interaction).To(viewModel => viewModel.MessageInteraction).OneWay(); set.Apply(); }
private void ChangePassword(VaultParams vaultParams) { try { Vault.ChangePassword(vaultParams.Password); _messageInteraction.Raise(new MessageInteraction("Password changed.")); } catch (System.Exception e) { _messageInteraction.Raise(new MessageInteraction(e.Message)); } }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { VaultParams vaultParams = new VaultParams(); if (values[0] is string filePath) { vaultParams.FilePath = filePath; } if (values[1] is string name) { vaultParams.Name = name; } if (values[2] is string description) { vaultParams.Description = description; } vaultParams.EncryptionInfo = new EncryptionInfo(); if (values[3] is int index) { // Algorithm combobox index switch (index) { case 0: vaultParams.EncryptionInfo.SelectedAlgorithm = Algorithm.AES_256; break; case 1: vaultParams.EncryptionInfo.SelectedAlgorithm = Algorithm.Twofish_256; break; default: break; } } if (values[4] is double deriviationRounds) { vaultParams.EncryptionInfo.DeriviationRounds = System.Convert.ToInt32(Math.Floor(deriviationRounds)); } if (values[5] is SecureString password) { vaultParams.Password = password; } return(vaultParams); }
private void CreateVault(VaultParams vaultParams) { if (Vault.Exists()) { // TODO: Rewrite this var _vault = Vault.GetInstance(); _vault.EncryptToFile(_vault.Location, _vault.EncryptionInfo.ProtectedKey); Vault.Delete(); } var vault = Vault.GetInstance(); vault.Location = vaultParams.FilePath; vault.Name = vaultParams.Name; vault.Description = vaultParams.Description; vault.EncryptionInfo = vaultParams.EncryptionInfo; // Create example entries vault.FolderList = new MvxObservableCollection <Folder>() { new Folder() { Name = "Example Folder", Color = new XmlColor(Color.FromArgb(255, 255, 132, 0)), EntryList = new MvxObservableCollection <Entry>() { new Entry() { Name = "Example Entry", Color = new XmlColor(Color.FromArgb(255, 255, 132, 0)), FieldList = new MvxObservableCollection <Field>() { new Field() { Type = FieldTypes.Note, Name = "Welcome to SolPM", Value = "Thank you for trying out Solar Password Manager!\n\nGet started by making a new field for this entry. To do that you can press the \"+\" button on the bottom right side of the screen and choose the type of the field you wish to add.\nAfter filling the field you may want to save this entry by pressing the respective button in the right upper corner of the screen or simply hitting Ctrl+S on your keyboard.\nWhen outside of entry editing mode, you may add new entries or folders to your Vault from the menu on the upper side of the window or by using the keyboard shortcuts displayed next to the functions in the menu.", } } } } } }; vault.SetupEncryption(vaultParams.Password); vaultParams.Password.Dispose(); _navigationService.Navigate <VaultViewModel>(); }