예제 #1
0
        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;
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        void m_worker_DoWork(object sender, DoWorkEventArgs e)
        {
            Debug.Assert(e.Argument is MigrationSource, "Wrong argument type");
            MigrationSource migrationSourceConfig = e.Argument as MigrationSource;

            string dbSet  = migrationSourceConfig.ServerUrl;
            string userDb = migrationSourceConfig.SourceIdentifier;

            CredentialManagementService credManagementService =
                new CredentialManagementService(migrationSourceConfig);

            ICQLoginCredentialManager  loginCredManager      = CQLoginCredentialManagerFactory.CreateCredentialManager(credManagementService, migrationSourceConfig);
            ClearQuestConnectionConfig userSessionConnConfig = new ClearQuestConnectionConfig(loginCredManager.UserName,
                                                                                              loginCredManager.Password,
                                                                                              userDb,
                                                                                              dbSet);

            ClearQuestOleServer.Session userSession = CQConnectionFactory.GetUserSession(userSessionConnConfig);

            Dictionary <string, bool> queryList = CQWorkSpace.GetQueryListWithValidity(userSession);

            e.Result = queryList;
        }
        public void Initialize(Configuration configuration)
        {
            CredentialManagementService credManagementService = new CredentialManagementService(configuration);

            foreach (MigrationSource ms in configuration.SessionGroup.MigrationSources.MigrationSource)
            {
                try
                {
                    string dbSet  = ms.ServerUrl;
                    string userDb = ms.SourceIdentifier;

                    ICQLoginCredentialManager loginCredManager =
                        CQLoginCredentialManagerFactory.CreateCredentialManager(credManagementService, ms);
                    Guid migrSrcId = new Guid(ms.InternalUniqueId);

                    var userSessionConnConfig = new ClearQuestConnectionConfig(loginCredManager.UserName,
                                                                               loginCredManager.Password,
                                                                               userDb,
                                                                               dbSet);
                    ClearQuestOleServer.Session userSession = CQConnectionFactory.GetUserSession(userSessionConnConfig);

                    if (!m_cqSessions.ContainsKey(migrSrcId))
                    {
                        m_cqSessions.Add(migrSrcId, userSession);
                    }
                }
                catch (ClearQuestInvalidConfigurationException)
                {
                    continue;
                }
                catch (Exception e)
                {
                    TraceManager.TraceException(e);
                }
            }
        }