Exemple #1
0
        private void InitializeCQClient()
        {
            Microsoft.TeamFoundation.Migration.BusinessModel.MigrationSource migrationSourceConfig = m_configurationService.MigrationSource;
            string dbSet  = migrationSourceConfig.ServerUrl;
            string userDb = migrationSourceConfig.SourceIdentifier;

            ICredentialManagementService credManagementService =
                m_serviceContainer.GetService(typeof(ICredentialManagementService)) as ICredentialManagementService;

            ICQLoginCredentialManager loginCredManager =
                CQLoginCredentialManagerFactory.CreateCredentialManager(credManagementService, migrationSourceConfig);

            // connect to user session
            UserSessionConnConfig = new ClearQuestConnectionConfig(loginCredManager.UserName,
                                                                   loginCredManager.Password,
                                                                   userDb,
                                                                   dbSet);
            m_userSession = CQConnectionFactory.GetUserSession(UserSessionConnConfig);

            #region we won't need admin session until we start syncing cq schema
            //// connect to admin session
            //if (!string.IsNullOrEmpty(loginCredManager.AdminUserName))
            //{
            //    AdminSessionConnConfig = new ClearQuestConnectionConfig(loginCredManager.AdminUserName,
            //                                                                loginCredManager.AdminPassword ?? string.Empty,
            //                                                                userDb,
            //                                                                dbSet);
            //    m_adminSession = CQConnectionFactory.GetAdminSession(AdminSessionConnConfig);
            //}
            #endregion
            MigrationContext = new ClearQuestMigrationContext(m_userSession, migrationSourceConfig);
        }
        /// <summary>
        /// Creates a credential manager based on the migration source configuration
        /// </summary>
        /// <param name="credManagementService"></param>
        /// <param name="migrationSourceConfig"></param>
        /// <returns>Created credential manager</returns>
        /// <exception cref="">ClearQuestAdapter.Exceptions.ClearQuestInvalidConfigurationException</exception>
        public static ICQLoginCredentialManager CreateCredentialManager(
            ICredentialManagementService credManagementService,
            MigrationSource migrationSourceConfig)
        {
            if (null != credManagementService &&
                credManagementService.IsMigrationSourceConfiguredToUseStoredCredentials(new Guid(migrationSourceConfig.InternalUniqueId)))
            {
                if (OSIsNotSupported())
                {
                    throw new System.NotSupportedException(ClearQuestResource.StoredCredentialNotSupported);
                }

                return(new CQStoredCredentialManager(credManagementService, migrationSourceConfig));
            }
            else
            {
                foreach (var setting in migrationSourceConfig.CustomSettings.CustomSetting)
                {
                    if (setting.SettingKey.Equals(ClearQuestConstants.LoginCredentialSettingKey, StringComparison.Ordinal))
                    {
                        return(GetTypedCredentialManager(setting.SettingValue, migrationSourceConfig));
                    }
                }

                throw new ClearQuestInvalidConfigurationException(ClearQuestResource.ClearQuest_Config_MissingLoginCredentialSettingType);
            }
        }
        public CQStoredCredentialManager(
            ICredentialManagementService credManagementService,
            MigrationSource migrationSourceConfig)
        {
            var credentials =
                credManagementService.GetCredentialsForMigrationSource(new Guid(migrationSourceConfig.InternalUniqueId));

            if (null == credentials || credentials.Count == 0)
            {
                string credUri = (migrationSourceConfig.StoredCredential == null ?
                                  string.Empty : migrationSourceConfig.StoredCredential.CredentialString);
                throw new InvalidOperationException(
                          string.Format(ClearQuestResource.ClearQuest_Error_CredntialMissing, credUri));
            }
            else
            {
                Debug.Assert(credentials.Count == 1, "more than 1 credentials are found");
                UserName = credentials[0].UserName;
                Password = credentials[0].Password;
            }
        }
Exemple #4
0
        private void InitializeCQClient()
        {
            MigrationSource migrationSourceConfig = m_configurationService.MigrationSource;
            string          dbSet  = migrationSourceConfig.ServerUrl;
            string          userDb = migrationSourceConfig.SourceIdentifier;

            ICredentialManagementService credManagementService =
                m_serviceContainer.GetService(typeof(ICredentialManagementService)) as ICredentialManagementService;

            ICQLoginCredentialManager loginCredManager =
                CQLoginCredentialManagerFactory.CreateCredentialManager(credManagementService, migrationSourceConfig);

            // connect to user session
            UserSessionConnConfig = new ClearQuestConnectionConfig(loginCredManager.UserName,
                                                                   loginCredManager.Password,
                                                                   userDb,
                                                                   dbSet);
            m_userSession = CQConnectionFactory.GetUserSession(UserSessionConnConfig);

            #region admin session is not needed until we sync context
            //// connect to admin session
            //if (!string.IsNullOrEmpty(loginCredManager.AdminUserName))
            //{
            //    AdminSessionConnConfig = new ClearQuestConnectionConfig(loginCredManager.AdminUserName,
            //                                                                loginCredManager.AdminPassword ?? string.Empty,
            //                                                                userDb,
            //                                                                dbSet);
            //    m_adminSession = CQConnectionFactory.GetAdminSession(AdminSessionConnConfig);
            //}
            #endregion

            // parse the filter strings in the configuration file
            m_filters = new CQRecordFilters(m_configurationService.Filters, m_userSession);

            m_migrationContext = new ClearQuestMigrationContext(m_userSession, migrationSourceConfig);
        }