Exemple #1
0
        /// <summary>
        /// Here we use the modified favorite used in connection,
        /// becaue e.g. credentials may differ from the saved credentials.
        /// </summary>
        internal string BuildTooTip(IFavorite selected)
        {
            var    guarded         = new GuardedCredential(selected.Security, this.persistenceSecurity);
            string userDisplayName = HelperFunctions.UserDisplayName(guarded.Domain, guarded.UserName);

            return(GetToolTipText(selected, userDisplayName));
        }
Exemple #2
0
        private void UpdateFromControls(ICredentialSet toUpdate)
        {
            toUpdate.Name = this.NameTextbox.Text;
            var guarded = new GuardedCredential(toUpdate, this.persistence.Security);

            this.credentialsPanel1.SaveTo(guarded);
        }
Exemple #3
0
        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();
        }
Exemple #4
0
 /// <summary>
 ///     both Credential and security passwords are in the same table, updated by this method
 /// </summary>
 private void UpdateCredentialBasePasswords()
 {
     foreach (var credentials in this.database.CredentialBase)
     {
         var guarded = new GuardedCredential(credentials, this.persistenceSecurity);
         guarded.UpdatePasswordByNewKeyMaterial(this.newKeyMaterial);
     }
 }
Exemple #5
0
 private void FillControlsFromCredential()
 {
     if (this.editedCredential != null)
     {
         var guarded = new GuardedCredential(this.editedCredential, this.persistence.Security);
         this.credentialsPanel1.LoadFrom(guarded);
         this.NameTextbox.Text     = editedCredential.Name;
         this.editedCredentialName = editedCredential.Name;
     }
 }
Exemple #6
0
        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;
        }
Exemple #7
0
        public void UpdatePasswordsByNewKeyMaterial(string newKeyMaterial)
        {
            foreach (var credentials in this.cache)
            {
                var guarded = new GuardedCredential(credentials, this.persistenceSecurity);
                guarded.UpdatePasswordByNewKeyMaterial(newKeyMaterial);
            }

            this.Save();
        }
        private ICredentialSet SetupCredential()
        {
            var credential = new CredentialSet();
            var guardedSec = new GuardedCredential(credential, this.persistenceMock.Object.Security);

            guardedSec.Password = PASSWORD;
            var credentials = new Mock <ICredentials>();

            credentials.Setup(cr => cr[It.IsAny <Guid>()]).Returns(credential);
            this.persistenceMock.SetupGet(p => p.Credentials).Returns(credentials.Object);
            return(credential);
        }
Exemple #9
0
        private DbCredentialSet CreateTestCredentialSet()
        {
            DbCredentialSet credentials = this.PrimaryFactory.CreateCredentialSet() as DbCredentialSet;

            credentials.Name = "TestCredentialName";
            var guarded = new GuardedCredential(credentials, this.PrimaryPersistence.Security);

            guarded.Domain   = "TestDomain";
            guarded.UserName = "******";
            guarded.Password = VALIDATION_VALUE;
            return(credentials);
        }
        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 CreateCredentialInPersistence()
        {
            // because of internal usage in Favorite we have to reference the singleton
            var persistence = this.Persistence;
            var credential  = new CredentialSet();
            var guarded     = new GuardedCredential(credential, this.Persistence.Security);

            credential.Name  = CREDENTIAL_NAME;
            guarded.Password = EXPECTEDPASSWORD;
            guarded.Domain   = EXPECTED_DOMAIN;
            guarded.UserName = EXPECTED_USER;
            persistence.Credentials.Add(credential);
        }
        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.");
        }
Exemple #13
0
        private void CredentialDropdown_SelectedIndexChanged(object sender, EventArgs e)
        {
            var  set = this.credentialDropdown.SelectedItem as ICredentialSet;
            bool hasSelectedCredential = set != null;

            if (hasSelectedCredential)
            {
                var guarded = new GuardedCredential(set, this.persistence.Security);
                this.credentialsPanel1.LoadDirectlyFrom(guarded);
            }

            this.credentialsPanel1.Enabled = !hasSelectedCredential;
            this.FireSelectedCredentialChanged(hasSelectedCredential);
        }
        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);
        }
Exemple #15
0
        private string ResolveVerifiedPassword(ICredentialSet checkCredentialSet)
        {
            var guarded = new GuardedCredential(checkCredentialSet, this.SecondaryPersistence.Security);

            return(guarded.Password);
        }
Exemple #16
0
        private EditedCredentials ToEditedCredentials(ICredentialSet editedCredentials)
        {
            var guarded = new GuardedCredential(editedCredentials, this.persistence.Security);

            return(new EditedCredentials(editedCredentials, guarded.UserName, guarded.Domain));
        }