예제 #1
0
        public Migrator(
            MigrationConfigurationBase configuration,
            ServerStore serverStore,
            CancellationToken cancellationToken)
        {
            var hasCredentials =
                string.IsNullOrWhiteSpace(configuration.UserName) == false &&
                string.IsNullOrWhiteSpace(configuration.Password) == false;

            var httpClientHandler = new HttpClientHandler
            {
                UseDefaultCredentials = hasCredentials == false,
            };

            if (hasCredentials)
            {
                httpClientHandler.Credentials = new NetworkCredential(
                    configuration.UserName,
                    configuration.Password,
                    configuration.Domain);
            }

            _client = new HttpClient(httpClientHandler);

            _serverUrl = configuration.ServerUrl.TrimEnd('/');

            _serverStore       = serverStore;
            _version           = configuration.MajorVersion;
            _cancellationToken = cancellationToken;
        }
예제 #2
0
파일: Migrator.cs 프로젝트: garayx/ravendb
        public Migrator(MigrationConfigurationBase configuration, ServerStore serverStore)
        {
            _serverUrl         = UrlHelper.TryGetLeftPart(configuration.ServerUrl);
            _serverStore       = serverStore;
            _buildMajorVersion = configuration.BuildMajorVersion;
            _buildVersion      = configuration.BuildVersion;

            //because of backward compatibility useCompression == false here
            var httpClientHandler = RequestExecutor.CreateHttpMessageHandler(_serverStore.Server.Certificate.Certificate, setSslProtocols: false, useCompression: false);

            httpClientHandler.UseDefaultCredentials = false;

            if (string.IsNullOrWhiteSpace(configuration.ApiKey) == false)
            {
                Authenticator.GetApiKeyParts(configuration.ApiKey); // will throw if not in correct format
                _apiKey = configuration.ApiKey;
                _enableBasicAuthenticationOverUnsecuredHttp = configuration.EnableBasicAuthenticationOverUnsecuredHttp;
            }
            else if (string.IsNullOrWhiteSpace(configuration.UserName) == false &&
                     string.IsNullOrWhiteSpace(configuration.Password) == false)
            {
                var domain = string.IsNullOrWhiteSpace(configuration.Domain) ? "\\" : configuration.Domain;
                httpClientHandler.Credentials = new NetworkCredential(
                    configuration.UserName,
                    configuration.Password,
                    domain);
            }

            _httpClient = new HttpClient(httpClientHandler);
        }
예제 #3
0
        public Migrator(MigrationConfigurationBase configuration, ServerStore serverStore)
        {
            _serverUrl         = UrlHelper.TryGetLeftPart(configuration.ServerUrl);
            _serverStore       = serverStore;
            _buildMajorVersion = configuration.BuildMajorVersion;
            _buildVersion      = configuration.BuildVersion;

            var httpClientHandler = RequestExecutor.CreateHttpMessageHandler(_serverStore.Server.Certificate.Certificate, setSslProtocols: false);

            httpClientHandler.UseDefaultCredentials = false;
            if (string.IsNullOrWhiteSpace(configuration.UserName) == false &&
                string.IsNullOrWhiteSpace(configuration.Password) == false)
            {
                var domain = string.IsNullOrWhiteSpace(configuration.Domain) ? "\\" : configuration.Domain;
                httpClientHandler.Credentials = new NetworkCredential(
                    configuration.UserName,
                    configuration.Password,
                    domain);
            }

            _httpClient = new HttpClient(httpClientHandler);
        }