public static FavoriteConfigurationElementCollection GetFavorites(bool isDatabaseFavorite) { if (!isDatabaseFavorite) { TerminalsConfigurationSection section = GetSection(); if (section != null) { return(section.Favorites); } } else { FavoriteConfigurationElementCollection collection = new FavoriteConfigurationElementCollection(); using (TerminalsObjectContext dc = TerminalsObjectContext.Create()) { if (dc == null) { return(null); } foreach (var connection in dc.Connections) { FavoriteConfigurationElement favorite = connection.ToFavorite(); collection.Add(favorite); } } return(collection); } return(null); }
/// <summary> /// During this procedure, the old master key material should be still present. /// This finds all stored passwords and updates them to reflect new key material. /// </summary> private static void UpdateAllFavoritesPasswords(TerminalsConfigurationSection configSection, string newMasterPassword) { string newKeyMaterial = GetKeyMaterial(newMasterPassword); configSection.UpdatePasswordsByNewKeyMaterial(newKeyMaterial); UpdateFavoritePasswordsByNewKeyMaterial(newKeyMaterial); StoredCredentials.UpdatePasswordsByNewKeyMaterial(newKeyMaterial); }
private static void ConfigFileChanged(object sender, EventArgs e) { TerminalsConfigurationSection old = GetSection(); ForceReload(); ConfigurationChangedEventArgs args = ConfigurationChangedEventArgs.CreateFromSettings(old, GetSection()); FireConfigurationChanged(args); }
internal FavoriteConfigurationElementCollection GetFavorites() { TerminalsConfigurationSection section = GetSection(); if (section != null) { return(section.Favorites); } return(null); }
internal FavoriteConfigurationElement GetDefaultFavorite() { TerminalsConfigurationSection section = GetSection(); if (section != null && section.DefaultFavorite.Count > 0) { return(section.DefaultFavorite[0]); } return(null); }
private void UpdateStoredPasswords(string newKeyMaterial) { TerminalsConfigurationSection configSection = GetSection(); configSection.EncryptedDefaultPassword = PasswordFunctions2.EncryptPassword(DefaultPassword, newKeyMaterial); configSection.EncryptedAmazonAccessKey = PasswordFunctions2.EncryptPassword(AmazonAccessKey, newKeyMaterial); configSection.EncryptedAmazonSecretKey = PasswordFunctions2.EncryptPassword(AmazonSecretKey, newKeyMaterial); configSection.EncryptedConnectionString = PasswordFunctions2.EncryptPassword(ConnectionString, newKeyMaterial); configSection.DatabaseMasterPasswordHash = PasswordFunctions2.EncryptPassword(DatabaseMasterPassword, newKeyMaterial); }
internal static ConfigurationChangedEventArgs CreateFromSettings( TerminalsConfigurationSection oldSettings, TerminalsConfigurationSection newSettings) { var args = new ConfigurationChangedEventArgs(); args.OldFavorites = oldSettings.Favorites.ToList(); args.NewFavorites = newSettings.Favorites.ToList(); args.OldTags = oldSettings.Tags.ToList(); args.NewTags = newSettings.Tags.ToList(); return args; }
internal static ConfigurationChangedEventArgs CreateFromSettings( TerminalsConfigurationSection oldSettings, TerminalsConfigurationSection newSettings) { var args = new ConfigurationChangedEventArgs(); args.OldFavorites = oldSettings.Favorites.ToList(); args.NewFavorites = newSettings.Favorites.ToList(); args.OldTags = oldSettings.Tags.ToList(); args.NewTags = newSettings.Tags.ToList(); return(args); }
public static void UpdateMasterPassword(string newPassword) { TerminalsConfigurationSection configSection = GetSection(); UpdateAllFavoritesPasswords(configSection, newPassword); // start of not secured transaction. Old key is still present, // but passwords are already encrypted by newKey configSection.TerminalsPassword = newPassword; SaveImmediatelyIfRequested(); // finish transaction, the passwords now reflect the new key UpdateKeyMaterial(newPassword); }
private static void EditFavoriteInSettings(FavoriteConfigurationElement favorite, string oldName) { if (!favorite.IsDatabaseFavorite) { TerminalsConfigurationSection section = GetSection(); section.Favorites[oldName] = favorite.Clone() as FavoriteConfigurationElement; SaveImmediatelyIfRequested(); } else { using (TerminalsObjectContext dc = TerminalsObjectContext.Create()) { Sql.Connections connection = favorite.ToConnection(dc, dc.Connections.Where(x => x.Name == oldName).FirstOrDefault()); dc.SaveChanges(); } } }
private static TerminalsConfigurationSection GetSection() { if (remappingInProgress && remappingSection != null) { return(remappingSection); } try { remappingSection = null; return(Config.GetSection("settings") as TerminalsConfigurationSection); } catch (Exception ex) { if (!(remappingInProgress && remappingSection == null)) { Log.Warn("Warning remapping configuration file: " + ex.Message, ex); } try { // kick into the import routine _config = ImportConfiguration(); _config = GetConfiguration(); remappingSection = _config.GetSection("settings") as TerminalsConfigurationSection; return(remappingSection); } catch (Exception importException) { Log.Info("Terminals was able to automatically upgrade your existing connections.", importException); return(new TerminalsConfigurationSection()); } } }
private static TerminalsConfigurationSection GetSection() { if (remappingInProgress && remappingSection != null) return remappingSection; try { remappingSection = null; return Config.GetSection("settings") as TerminalsConfigurationSection; } catch (Exception ex) { if (!(remappingInProgress && remappingSection == null)) Log.Warn("Warning remapping configuration file: " + ex.Message, ex); try { // kick into the import routine _config = ImportConfiguration(); _config = GetConfiguration(); remappingSection = _config.GetSection("settings") as TerminalsConfigurationSection; return remappingSection; } catch (Exception importException) { Log.Info("Terminals was able to automatically upgrade your existing connections.", importException); return new TerminalsConfigurationSection(); } } }