public void Save() { m_migrationSource.ServerUrl = SelectedDatabase.DatabaseSetName; m_migrationSource.SourceIdentifier = SelectedDatabase.DatabaseName; m_migrationSource.FriendlyName = string.Format("{0}@{1}", m_migrationSource.ServerUrl, m_migrationSource.SourceIdentifier); m_migrationSource.ServerIdentifier = m_migrationSource.FriendlyName; m_migrationSource.CustomSettings.CustomSetting.Clear(); SaveCustomSetting(ClearQuestConstants.UserNameKey, UserName); if (CQLoginCredentialManagerFactory.OSIsNotSupported()) // windows XP does not support stored credentials { SaveCustomSetting(ClearQuestConstants.PasswordKey, m_password); SaveCustomSetting(ClearQuestConstants.LoginCredentialSettingKey, ClearQuestConstants.LoginCredentialSettingUseTextUsernamePasswordPairInConfig); m_migrationSource.StoredCredential.CredentialString = null; } else { string credentialString = m_migrationSource.FriendlyName; if (WinCredentialsProxy.CredentialExists(credentialString, WinCredentials.CredentialType.Generic)) { WinCredentialsProxy.DeleteCredential(credentialString); } WinCredentialsProxy.AddGeneralCredential(credentialString, UserName, m_password, WinCredentials.CredentialPersistence.Session, string.Empty); m_migrationSource.StoredCredential.CredentialString = credentialString; } }
public void Save() { m_migrationSource.ServerUrl = SelectedDatabase.DatabaseSetName; m_migrationSource.SourceIdentifier = SelectedDatabase.DatabaseName; m_migrationSource.FriendlyName = string.Format("{0}@{1}", m_migrationSource.ServerUrl, m_migrationSource.SourceIdentifier); m_migrationSource.ServerIdentifier = m_migrationSource.FriendlyName; m_migrationSource.CustomSettings.CustomSetting.Clear(); SaveCustomSetting(ClearQuestConstants.UserNameKey, UserName); if (CQLoginCredentialManagerFactory.OSIsNotSupported()) // windows XP does not support stored credentials { SaveCustomSetting(ClearQuestConstants.PasswordKey, m_password); SaveCustomSetting(ClearQuestConstants.LoginCredentialSettingKey, ClearQuestConstants.LoginCredentialSettingUseTextUsernamePasswordPairInConfig); m_migrationSource.StoredCredential.CredentialString = null; TraceManager.TraceInformation("ClearQuestConnectDialog: Skipped adding credentials to the credential store because the operating system does not support it"); } else { // todo: move this to the adapter as a helper method string credentialString = ClearQuestConstants.CqConnectionStringUrlPrefix + m_migrationSource.FriendlyName; if (WinCredentialsProxy.CredentialExists(credentialString, WinCredentials.CredentialType.Generic)) { WinCredentialsProxy.DeleteCredential(credentialString); } WinCredentialsProxy.AddGeneralCredential(credentialString, UserName, m_password, WinCredentials.CredentialPersistence.LocalComputer, string.Empty); m_migrationSource.StoredCredential.CredentialString = credentialString; TraceManager.TraceInformation("ClearQuestConnectDialog: Successfully added credentials to the credential store with the key '{0}'", credentialString); } }