public void MasterPasswordUpdateTest() { var newFavorite = this.AddFavoriteWithTestPassword(); var rdpOptions = newFavorite.ProtocolProperties as IContainsCredentials; var guardedOptions = new GuardedSecurity(this.PrimaryPersistence, rdpOptions.GetSecurity()); guardedOptions.Password = VALIDATION_VALUE; this.PrimaryFavorites.Update(newFavorite); DatabasePasswordUpdate.UpdateMastrerPassord(settings.ConnectionString, string.Empty, VALIDATION_VALUE_B); settings.DatabaseMasterPassword = VALIDATION_VALUE_B; bool result = DatabaseConnections.TestConnection(); Assert.IsTrue(result, "Couldn't update database master password"); // the secondary persistence has to reflect the database password change ((SqlPersistenceSecurity)this.SecondaryPersistence.Security).UpdateDatabaseKey(); IFavorite resultFavorite = this.SecondaryFavorites.FirstOrDefault(); var resolvedSecurity = new GuardedSecurity(this.SecondaryPersistence, resultFavorite.Security); Assert.AreEqual(VALIDATION_VALUE, resolvedSecurity.Password, "Favorite password doesn't match after database password update."); var secondaryRdpOptions = resultFavorite.ProtocolProperties as IContainsCredentials; var resolvedOptionsSecurity = new GuardedSecurity(this.SecondaryPersistence, secondaryRdpOptions.GetSecurity()); Assert.AreEqual(VALIDATION_VALUE, resolvedOptionsSecurity.Password, "Favorite TS gateway password doesn't match after database password update."); }
private static void ConfigureTsGateway(RdpOptions options, string newValue) { options.TsGateway.SeparateLogin = true; var guarded = new GuardedSecurity(persistence, options.TsGateway.Security); guarded.Domain = newValue; }
internal static bool ForceShutdown(IPersistence persistence, IFavorite favorite, ShutdownCommands shutdownCommand) { var guarded = new GuardedSecurity(persistence, favorite.Security); var security = guarded.GetResolvedCredentials(); var credentials = new NetworkCredential(security.UserName, security.Password, security.Domain); return(ForceShutdown(favorite.ServerName, shutdownCommand, credentials) == 0); }
private static void AssertSecurityImported(IPersistence persistence, ISecurityOptions security) { var guarded = new GuardedSecurity(persistence, security); Assert.AreEqual(TEST_USERNAME, guarded.UserName); Assert.AreEqual(TEST_DOMAIN, guarded.Domain); Assert.AreEqual(TEST_PASSWORD, guarded.Password); }
private static void SetupSecurityValues(IPersistence persistence, ISecurityOptions security) { var guarded = new GuardedSecurity(persistence, security); guarded.UserName = TEST_USERNAME; guarded.Domain = TEST_DOMAIN; guarded.Password = TEST_PASSWORD; }
private void AssertSecurityValues(IFavorite testFavorite, string expectedValue) { var guarded = new GuardedSecurity(this.PrimaryPersistence, testFavorite.Security); Assert.AreEqual(expectedValue, guarded.Password, "Favorite password doesn't match after update."); Assert.AreEqual(expectedValue, guarded.UserName, "Favorite user name doesn't match after update."); Assert.AreEqual(expectedValue, guarded.Domain, "Favorite user name doesn't match after update."); }
/// <summary> /// Checks, if Gateway has still assigned persistence security, to be able work with passwords. /// </summary> internal static void AssertRdpSecurity(IPersistence persistence, IFavorite favorite) { TestConnectionManager.Instance.ChangeProtocol(favorite, KnownConnectionConstants.RDP); var rdpOptions = favorite.ProtocolProperties as RdpOptions; var guarded = new GuardedSecurity(persistence, rdpOptions.TsGateway.Security); guarded.Password = "******"; // shouldn't fail }
private void UpdateWithNewSecuredValue(IFavorite testFavorite, string newValue) { var guarded = new GuardedSecurity(this.PrimaryPersistence, testFavorite.Security); guarded.UserName = newValue; guarded.Password = newValue; guarded.Domain = newValue; this.PrimaryFavorites.Update(testFavorite); }
private void ApplyValueToAllFavorites(List <IFavorite> selectedFavorites, string newUserName, Action <IGuardedSecurity, string> applyValue) { foreach (var favorite in selectedFavorites) { var guarded = new GuardedSecurity(this.persistence, favorite.Security); applyValue(guarded, newUserName); } }
private IFavorite AddFavoriteWithTestPassword() { IFavorite testFavorite = this.CreateTestFavorite(); var guarded = new GuardedSecurity(this.PrimaryPersistence, testFavorite.Security); guarded.Password = VALIDATION_VALUE; this.PrimaryFavorites.Add(testFavorite); return(testFavorite); }
public void ApplyUserNameToAllFavoritesTest() { PrimaryFavorites.ApplyUserNameToAllFavorites(this.TestFavorites, VALIDATION_VALUE); foreach (IFavorite secondaryFavorite in SecondaryFavorites) { var guarded = new GuardedSecurity(this.PrimaryPersistence, secondaryFavorite.Security); Assert.AreEqual(VALIDATION_VALUE, guarded.UserName, "User name was not set properly to all favorites"); } }
public void SavedPassword_ResolveCredentials_ReturnsSavedPassword() { var guarded = new GuardedSecurity(this.persistenceMock.Object, original); guarded.Password = PASSWORD; var result = guarded.GetResolvedCredentials(); const string MESSAGE = "Localy saved password has always precedence over default password or stored credential."; Assert.AreEqual(original.EncryptedPassword, result.EncryptedPassword, MESSAGE); }
public void ValidParams_ResolveCredentials_ReturnsNotOriginalInstance() { var guarded = new GuardedSecurity(this.persistenceMock.Object, original); var result = guarded.GetResolvedCredentials(); result.Password = "******"; const string MESSAGE = "Changing the resolved instance password cant affect the original. We return new instance."; Assert.AreNotEqual(original.EncryptedPassword, result.EncryptedPassword, MESSAGE); }
private IFavorite CreateTestFavorite() { List <IGroup> groups = CreateTestGroups(); IFavorite favorite = TestMocksFactory.CreateFavorite(groups); favorite.ServerName = "TestServerName"; IPersistence persistence = TestMocksFactory.CreatePersistence().Object; var guarded = new GuardedSecurity(persistence, favorite.Security); guarded.Domain = "TestDomain"; guarded.UserName = "******"; favorite.Port = 9999; favorite.Notes = "Here are test notes."; return(favorite); }
internal void SaveTo(ISecurityOptions security, bool savePassword) { ICredentialSet selectedCredential = this.credentialDropdown.SelectedItem as ICredentialSet; security.Credential = selectedCredential == null ? Guid.Empty : selectedCredential.Id; var guarded = new GuardedSecurity(this.persistence, security); this.credentialsPanel1.SaveUserAndDomain(guarded); if (savePassword) { this.credentialsPanel1.SavePassword(guarded); } else { security.EncryptedPassword = String.Empty; } }
private void ConvertSecurity(IFavorite result, FavoriteConfigurationElement sourceFavorite) { var security = result.Security; var guarded = new GuardedSecurity(this.Persistence, security); guarded.Domain = sourceFavorite.DomainName; guarded.UserName = sourceFavorite.UserName; // because persistence and application masterpassword may differ, // we have to go through encryption without credential resolution guarded.Password = this.Persistence.Security.DecryptPassword(sourceFavorite.EncryptedPassword); var credential = this.Persistence.Credentials[sourceFavorite.Credential]; if (credential != null) { security.Credential = credential.Id; } }
private void ConvertSecurity(FavoriteConfigurationElement result, IFavorite sourceFavorite) { var security = sourceFavorite.Security; var guarded = new GuardedSecurity(this.Persistence, security); result.DomainName = guarded.Domain; result.UserName = guarded.UserName; // because persistence and application masterpassword may differ, we have to go through encryption var resultSecurity = new FavoriteConfigurationSecurity(this.Persistence, result); resultSecurity.Password = guarded.Password; ICredentialSet credential = this.Persistence.Credentials[security.Credential]; if (credential != null) { result.Credential = credential.Name; } }
public void UpdateFavoriteThreeTimes_FiresEventsAndStoresSecurity() { IFavorite favorite = this.AddFavoriteToPrimaryPersistence(); // first time change nothing to ensure, that dummy update doesn't fail. // EF Security.CachedCredentials property is still null. this.PrimaryFavorites.Update(favorite); var guarded = new GuardedSecurity(this.PrimaryPersistence, favorite.Security); // now assign new values to security and commit it as newly added, should not fail guarded.UserName = VALIDATION_VALUE; this.PrimaryFavorites.Update(favorite); // try again to ensure, that second update also doesn't fail. guarded.UserName = VALIDATION_VALUE_B; this.PrimaryFavorites.Update(favorite); IFavorite target = this.SecondaryFavorites.FirstOrDefault(); Assert.AreEqual(VALIDATION_VALUE_B, guarded.UserName, "Protocol properties weren't updated"); Assert.AreEqual(3, this.updatedCount, "Event wasn't delivered"); }
private IGuardedSecurity ResolveCredentials(ISecurityOptions original) { var guarded = new GuardedSecurity(this.persistenceMock.Object, original); return(guarded.GetResolvedCredentials()); }
internal void LoadFrom(ISecurityOptions security) { var guarded = new GuardedSecurity(this.persistence, security); this.credentialsPanel1.LoadFrom(guarded); }
internal FavoriteViewModel(IFavorite favorite, IPersistence persistence) { this.Favorite = favorite; this.storedCredentials = persistence.Credentials; this.guarded = new GuardedSecurity(persistence, favorite.Security); }
private static string GetDomain(RdpOptions options) { var guarded = new GuardedSecurity(persistence, options.TsGateway.Security); return(guarded.Domain); }