private void TryRemove(ICredentialSet toRemove) { var credentailToRemove = toRemove as DbCredentialSet; DeleteFromDatabase(credentailToRemove); this.cache.Delete(credentailToRemove); }
private void TryAdd(ICredentialSet toAdd) { var credentialToAdd = toAdd as DbCredentialSet; AddToDatabase(credentialToAdd); this.cache.Add(credentialToAdd); }
public void CredentialsUpdateTest() { IFavorite favorite = this.CreateTestFavorite(); this.PrimaryFavorites.Add(favorite); ICredentialSet credential = this.PrimaryFactory.CreateCredentialSet(); credential.Name = "testCredential"; var guarded = new GuardedCredential(credential, this.PrimaryPersistence.Security); guarded.Password = VALIDATION_VALUE; this.PrimaryPersistence.Credentials.Add(credential); IFavorite secondary = this.SecondaryFavorites.FirstOrDefault(); Assert.AreEqual(Guid.Empty, secondary.Security.Credential, "Favorite credentials should be null"); favorite.Security.Credential = credential.Id; this.PrimaryFavorites.Update(favorite); var secondaryFavorites = this.SecondaryFavorites as Terminals.Data.DB.Favorites; secondaryFavorites.RefreshCache(); secondary = this.SecondaryFavorites.FirstOrDefault(); Guid favoriteCredential = secondary.Security.Credential; Assert.AreNotEqual(Guid.Empty, favoriteCredential, "Favorite credential wasn't assigned properly"); ICredentialSet resolvedCredentials = this.SecondaryPersistence.Credentials[favoriteCredential]; var resolvedGuarded = new GuardedCredential(resolvedCredentials, this.SecondaryPersistence.Security); Assert.AreEqual(VALIDATION_VALUE, resolvedGuarded.Password, "Favorite credentials, doesn't match"); this.AssertStoredCredentialsCount(); }
internal static void AssertCredentialsValidation(IDataValidator validator, ICredentialSet credentailSet, int expectedErrorsCount) { credentailSet.Name = LongText; var results = validator.Validate(credentailSet); Assert.AreEqual(expectedErrorsCount, results.Count(), "CredentailSet validation failed"); }
private void UpdateFromControls(ICredentialSet toUpdate) { toUpdate.Name = this.NameTextbox.Text; var guarded = new GuardedCredential(toUpdate, this.persistence.Security); this.credentialsPanel1.SaveTo(guarded); }
public void ResolveCredentials(ISecurityOptions result, Guid credentialId) { ICredentialSet source = this.credentials[credentialId]; this.UpdateFromCredential(source, result); this.UpdateFromDefaultValues(result); }
internal ManageCredentialForm(IPersistence persistence, ICredentialSet editedCredential) { InitializeComponent(); this.persistence = persistence; this.editedCredential = editedCredential; FillControlsFromCredential(); }
private static void AssertFavoriteCredentialSet(IPersistence persistence) { IFavorite favoriteWithCredentials = persistence.Favorites.ToList()[1]; var credentialsId = favoriteWithCredentials.Security.Credential; ICredentialSet credential = persistence.Credentials[credentialsId]; Assert.IsNotNull(credential, "Favorite referenced credential was lost"); }
/// <summary> /// Creates new instance of parameters required to open new connection /// </summary> /// <param name="favorites">Not null colleciton of favorites, where to connect</param> /// <param name="forceConsole">For RDP only. If defined, will replace the RDP Console option</param> /// <param name="forceNewWindow">If defined, will replace the favorite option to open connection in new window</param> /// <param name="credentials">If defined, replaces the favorite authentication informations</param> internal ConnectionDefinition(IEnumerable<IFavorite> favorites, bool? forceConsole = null, bool? forceNewWindow = null, ICredentialSet credentials = null, string newFavorite = "") { this.Favorites = favorites.ToList(); // evaluate imediately this.ForceConsole = forceConsole; this.ForceNewWindow = forceNewWindow; this.Credentials = credentials; this.NewFavorite = newFavorite; }
private void EditSelectedCredential() { ICredentialSet selected = this.GetSelectedCredentials(); if (selected != null) { this.EditCredential(selected); } }
/// <summary> /// Creates new instance of parameters required to open new connection /// </summary> /// <param name="favorites">Not null colleciton of favorites, where to connect</param> /// <param name="forceConsole">For RDP only. If defined, will replace the RDP Console option</param> /// <param name="forceNewWindow">If defined, will replace the favorite option to open connection in new window</param> /// <param name="credentials">If defined, replaces the favorite authentication informations</param> internal ConnectionDefinition(IEnumerable <IFavorite> favorites, bool?forceConsole = null, bool?forceNewWindow = null, ICredentialSet credentials = null, string newFavorite = "") { this.Favorites = favorites.ToList(); // evaluate imediately this.ForceConsole = forceConsole; this.ForceNewWindow = forceNewWindow; this.Credentials = credentials; this.NewFavorite = newFavorite; }
private void EditCredential(ICredentialSet selected) { using (var mgr = new ManageCredentialForm(this.persistence, selected)) { if (mgr.ShowDialog() == DialogResult.OK) { this.BindList(); } } }
public void CredentialSet_ResolveCredentials_ReturnsCredentialValues() { ICredentialSet credential = this.SetupCredential(); original.Credential = credential.Id; IGuardedSecurity result = this.ResolveCredentials(original); const string MESSAGE = "When credential set is defined, its pasword is used to connect."; Assert.AreEqual(credential.EncryptedPassword, result.EncryptedPassword, MESSAGE); }
internal static void UpdateFromCredential(ICredentialSet source, ISecurityOptions target) { if (source != null) { target.Credential = source.Id; target.Domain = source.Domain; target.UserName = source.UserName; target.EncryptedPassword = source.EncryptedPassword; } }
private void UpdateFromvrDCredentials(vRDConfigurationFileCredentialsFolderCredentials source, ICredentialSet target) { var guarded = new GuardedCredential(target, this.persistence.Security); guarded.Domain = source.Domain; target.Name = source.Name; guarded.Password = source.Password; guarded.UserName = source.UserName; }
public void Add(ICredentialSet toAdd) { if (string.IsNullOrEmpty(toAdd.Name)) { return; } this.cache.Add(toAdd); this.Save(); }
// dont do it in constructor to prevent wrong acces to the persistence from designer private void UserSelectForm_Shown(object sender, EventArgs e) { // it always has to be present this.customCredentials = this.persistence.Factory.CreateCredentialSet(); this.customCredentials.Name = "(custom)"; List<ICredentialSet> credentials = this.persistence.Credentials.ToList(); credentials.Insert(0, this.customCredentials); this.credentialsComboBox.DataSource = credentials; this.credentialsComboBox.SelectedItem = this.customCredentials; }
// dont do it in constructor to prevent wrong acces to the persistence from designer private void UserSelectForm_Shown(object sender, EventArgs e) { // it always has to be present this.customCredentials = this.persistence.Factory.CreateCredentialSet(); this.customCredentials.Name = "(custom)"; List <ICredentialSet> credentials = this.persistence.Credentials.ToList(); credentials.Insert(0, this.customCredentials); this.credentialsComboBox.DataSource = credentials; this.credentialsComboBox.SelectedItem = this.customCredentials; }
public void Add(ICredentialSet toAdd) { try // no concurrency here, because there are no dependences on other tables { this.TryAdd(toAdd); } catch (EntityException exception) { this.dispatcher.ReportActionError(Add, toAdd, this, exception, "Unable to add credential to database"); } }
public void Update(ICredentialSet toUpdate) { var oldItem = this[toUpdate.Id]; if (oldItem != null) { this.cache.Remove(oldItem); } this.cache.Add(toUpdate); this.Save(); }
private void UpdateOldOrCreateNew() { if (this.editedCredential != null) { this.Update(this.editedCredential); return; } ICredentialSet newCredential = this.CreateNewCredential(); Credentials.Add(newCredential); }
private void UpdateFromCredential(ICredentialSet source, ISecurityOptions target) { if (source != null) { target.Credential = source.Id; var guardedSource = new GuardedCredential(source, this.PersistenceSecurity); var guardedTarget = new GuardedCredential(target, this.PersistenceSecurity); guardedTarget.Domain = guardedSource.Domain; guardedTarget.UserName = guardedSource.UserName; target.EncryptedPassword = source.EncryptedPassword; } }
public void UpdateCredentialsPasswordsByNewKeyMaterialTest() { // this is the only one test, which plays with different master passwords Settings.Instance.PersistenceSecurity = this.PrimaryPersistence.Security; this.AddTestCredentialsToDatabase(); this.PrimaryPersistence.Security.UpdateMasterPassword(VALIDATION_VALUE_B); ICredentialSet checkCredentials = this.SecondaryPersistence.Credentials.FirstOrDefault(); string resolvedPassword = this.ResolveVerifiedPassword(checkCredentials); Assert.AreEqual(VALIDATION_VALUE, resolvedPassword, "Password lost after update of key material"); }
internal string ResolveDomainName() { ICredentialSet cred = this.credentials[this.favorite.Credential]; if (cred != null) { var guarded = new GuardedCredential(cred, this.security); return(guarded.Domain); } return(this.favorite.DomainName); }
private void TryUpdate(ICredentialSet toUpdate) { using (var database = DatabaseConnections.CreateInstance()) { var credentialToUpdate = toUpdate as DbCredentialSet; database.CredentialBase.Attach(credentialToUpdate); database.Cache.MarkAsModified(credentialToUpdate); database.SaveImmediatelyIfRequested(); database.Cache.Detach(credentialToUpdate); this.cache.Update(credentialToUpdate); } }
internal ManageCredentialForm(IPersistence persistence, ICredentialSet editedCredential) { InitializeComponent(); this.persistence = persistence; this.validator = persistence.Factory.CreateValidator(); this.editedCredential = editedCredential; this.credentialsPanel1.Settings = Settings.Instance; this.credentialsPanel1.tableLayoutPanel1.Location = new Point(78, 0); this.credentialsPanel1.tableLayoutPanel1.Size = new Size(this.NameTextbox.Width + 35, 80); this.credentialsPanel1.LoadMRUs(); FillControlsFromCredential(); }
private bool UpdateCredential() { ICredentialSet conflicting = Credentials[this.NameTextbox.Text]; bool hasConflicting = conflicting != null && !conflicting.Equals(this.editedCredential); if (hasConflicting && this.EditedNameHasChanged()) { return(UpdateConflicting(conflicting, this.editedCredential)); } UpdateOldOrCreateNew(); return(true); }
private bool ValidateNameAndUserName() { ICredentialSet prototype = this.CreateNewCredential(); var results = this.validator.Validate(prototype); string nameErrorMessage = results["Name"]; this.errorProvider.SetError(this.NameTextbox, nameErrorMessage); // the validated object contains only encrypted properties. string userNameErrorMessage = results["EncryptedUserName"]; this.credentialsPanel1.SetUserNameError(this.errorProvider, userNameErrorMessage); return(results.Empty); }
private void TryApplyCredentials(List <IFavorite> selectedFavorites, ICredentialSet credential) { using (Database database = DatabaseConnections.CreateInstance()) { var dbFavorites = selectedFavorites.Cast <DbFavorite>().ToList(); Data.Favorites.ApplyCredentialsToFavorites(selectedFavorites, credential); database.Cache.AttachAll(dbFavorites); // here we have to mark it modified, because caching detail properties // sets proper credential set reference database.Cache.MarkAsModified(dbFavorites); this.batchActions.SaveAndReportFavoritesUpdated(database, dbFavorites, selectedFavorites); } }
private bool UpdateConflicting(ICredentialSet conflicting, ICredentialSet oldItem) { DialogResult result = MessageBox.Show("The Credential Name you entered already exists.\r\n" + "Do you want to overwrite it?", "Credential manager", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result != DialogResult.Yes) return false; if (oldItem != null) Credentials.Remove(oldItem); this.Update(conflicting); return true; }
private void DeleteButton_Click(object sender, EventArgs e) { ICredentialSet toRemove = this.GetSelectedCredentials(); if (toRemove != null) { if (MessageBox.Show("Are you sure you want to delete credential " + toRemove.Name + "?", "Credential manager", MessageBoxButtons.YesNo) == DialogResult.Yes) { this.Credentials.Remove(toRemove); this.BindList(); } } }
private static void AssertUserAndCredential(IPersistence persistence) { // we don't have to authenticate, because it was already done by upgrade IFavorite favorite = persistence.Favorites.First(); var guardedSecurity = new GuardedCredential(favorite.Security, persistence.Security); Assert.AreEqual(PasswordTests.USERPASSWORD, guardedSecurity.Password, "Upgrade favorite password failed."); ICredentialSet credential = persistence.Credentials.First(); var guarded = new GuardedCredential(credential, persistence.Security); Assert.AreEqual(TEST_PASSWORD, guarded.UserName, "Credential user name upgrade failed."); Assert.AreEqual(TEST_PASSWORD, guarded.Password, "Credential password upgrade failed."); }
public string ResolveUserName() { if (!string.IsNullOrEmpty(this.favorite.Credential)) { ICredentialSet cred = this.credentials[this.favorite.Credential]; if (cred != null) { var guarded = new GuardedCredential(cred, this.security); return(guarded.UserName); } } return(this.favorite.UserName); }
public void Update(ICredentialSet toUpdate) { try { this.TryUpdate(toUpdate); } catch (DbUpdateException) // item already removed { this.cache.Delete((DbCredentialSet)toUpdate); } catch (EntityException exception) { this.dispatcher.ReportActionError(Update, toUpdate, this, exception, "Unable to update credential set."); } }
public void Remove(ICredentialSet toRemove) { try { this.TryRemove(toRemove); } catch (DbUpdateException) { this.cache.Delete((DbCredentialSet)toRemove); } catch (EntityException exception) { this.dispatcher.ReportActionError(this.Remove, toRemove, this, exception, "Unable to remove credential from database."); } }
private static void UpdateFromvrDCredentials(vRDConfigurationFileCredentialsFolderCredentials source, ICredentialSet target) { target.Domain = source.Domain; target.Name = source.Name; target.Password = source.Password; target.UserName = source.UserName; }
private void TryUpdate(ICredentialSet toUpdate) { using (Database database = DatabaseConnections.CreateInstance()) { var credentialToUpdate = toUpdate as DbCredentialSet; database.CredentialBase.Attach(credentialToUpdate); database.Cache.MarkAsModified(credentialToUpdate); database.SaveImmediatelyIfRequested(); database.Cache.Detach(credentialToUpdate); this.cache.Update(credentialToUpdate); } }
private void ConnectFromQuickCombobox(bool forceConsole, bool forceNewWindow = false, ICredentialSet credentials = null) { string connectionName = this.tscConnectTo.Text; if (!string.IsNullOrEmpty(connectionName)) { this.connectionsUiFactory.ConnectByFavoriteNames(new List<string>() { connectionName }, forceConsole, forceNewWindow, credentials); } }
private void Update(ICredentialSet conflicting) { this.UpdateFromControls(conflicting); Credentials.Update(conflicting); }
/// <summary> /// Creates new instance of parameters required to open new connection /// </summary> /// <param name="favorite">Not null favorite, where to connect</param> /// <param name="forceConsole">For RDP only. If defined, will replace the RDP Console option</param> /// <param name="forceNewWindow">If defined, will replace the favorite option to open connection in new window</param> /// <param name="credentials">If defined, replaces the favorite authentication informations</param> internal ConnectionDefinition(IFavorite favorite, bool? forceConsole = null, bool? forceNewWindow = null, ICredentialSet credentials = null) : this(new List<IFavorite>() { favorite }, forceConsole, forceNewWindow, credentials) { }
private void EditCredential(ICredentialSet selected) { using (var mgr = new ManageCredentialForm(this.persistence, selected)) { if (mgr.ShowDialog() == DialogResult.OK) this.BindList(); } }
internal static void ApplyCredentialsToFavorites(List<IFavorite> selectedFavorites, ICredentialSet credential) { foreach (IFavorite favorite in selectedFavorites) { favorite.Security.Credential = credential.Id; } }
public void ApplyCredentialsToAllFavorites(List<IFavorite> selectedFavorites, ICredentialSet credential) { ApplyCredentialsToFavorites(selectedFavorites, credential); SaveAndReportFavoritesUpdate(selectedFavorites); }
public void Remove(ICredentialSet toRemove) { try { this.TryRemove(toRemove); } catch (DbUpdateException) { this.cache.Delete((DbCredentialSet)toRemove); } catch (EntityException exception) { this.dispatcher.ReportActionError(Remove, toRemove, this, exception, "Unable to remove credential from database."); } }
public void Remove(ICredentialSet toRemove) { this.cache.Remove(toRemove); this.Save(); }
public void Update(ICredentialSet toUpdate) { var oldItem = this[toUpdate.Id]; if (oldItem != null) this.cache.Remove(oldItem); this.cache.Add(toUpdate); Save(); }
void ISecurityOptions.UpdateFromCredential(ICredentialSet source) { UpdateFromCredential(source, this); }
public void Add(ICredentialSet toAdd) { if (String.IsNullOrEmpty(toAdd.Name)) return; this.cache.Add(toAdd); this.Save(); }
internal static ValidationStates Validate(ICredentialSet credentialSet) { var results = ValidateObject(credentialSet); return new ValidationStates(results); }
private void UpdateFromControls(ICredentialSet toUpdate) { toUpdate.Name = this.NameTextbox.Text; this.credentialsPanel1.SaveTo(toUpdate); }