Esempio n. 1
0
 protected FirebaseHttpClient(IServiceAccountCredentials credentials, FirebaseSDKConfiguration configuration, Uri authority = null)
 {
     Credentials   = credentials;
     Configuration = configuration;
     Authority     = authority;
     Client        = Configuration.HttpClientProxy(configuration);
 }
 public ValidationUiService(
     IFileSystem fileSystem,
     IHttpClientProxy httpClientProxy)
 {
     _fileSystem      = fileSystem;
     _httpClientProxy = httpClientProxy;
 }
Esempio n. 3
0
 public CurrencyConverterService(IHttpClientProxy httpClientProxy, CurrencyConverterApi currencyConverter, HomeContext context)
 {
     _httpClientProxy = httpClientProxy;
     _context         = context;
     _apiKey          = currencyConverter.ApiKey;
     _url             = currencyConverter.Url;
 }
        public WorkflowHttpClientProxyProvider CreateWorkflowHttpProxy()
        {
            _httpClient             = Resolve <IHttpClientFactory>().CreateClient();//TestServer.CreateClient();
            _httpClient.BaseAddress = new Uri(Configuration.GetValue <string>("BaseUrl"));

            string accessToken = WebUtility.UrlEncode(JsonConvert.SerializeObject(new
            {
                Id       = "8a010000-5d88-0015-e013-08d6bd87c815",
                FullName = "新用户1",
                TenantId
            }));

            if (_httpClient.DefaultRequestHeaders.Any(x => x.Key == "Authorization") == false)
            {
                _httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken);
            }

            var session = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new
            {
                UserId   = "8a010000-5d88-0015-e013-08d6bd87c815",
                FullName = "新用户1",
                TopOrgId = TenantId,
                TenantId
            }));

            _httpClient.DefaultRequestHeaders.Add("Evos-Authentication", WebEncoders.Base64UrlEncode(session));

            IHttpClientProxy clientProxy = Resolve <IHttpClientProxy>();

            clientProxy.HttpClient = _httpClient;

            return(new WorkflowHttpClientProxyProvider(clientProxy));
        }
 public WebAssemblyCachedApplicationConfigurationClient(
     IHttpClientProxy <IAbpApplicationConfigurationAppService> proxy,
     ApplicationConfigurationCache cache)
 {
     Proxy = proxy;
     Cache = cache;
 }
Esempio n. 6
0
 public WebAssemblyRemoteTenantStore(
     IHttpClientProxy <IAbpTenantAppService> proxy,
     WebAssemblyRemoteTenantStoreCache cache)
 {
     Proxy = proxy;
     Cache = cache;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="httpProxy"></param>
 /// <param name="connectorProvider"></param>
 /// <param name="loggerFactory"></param>
 public DefaultUserServiceProxy(IHttpClientProxy httpProxy,
                                ExternalConnectorProvider connectorProvider,
                                ILoggerFactory loggerFactory)
 {
     this.httpProxy         = httpProxy;
     this.connectorProvider = connectorProvider;
     logger = loggerFactory.CreateLogger <DefaultUserServiceProxy>();
 }
Esempio n. 8
0
 public WebexTeamsApiService(IHttpClientProxy httpClientProxy)
 {
     _httpClientProxy = httpClientProxy;
     _defaultJsonSerializerSettings = new JsonSerializerSettings
     {
         ContractResolver = new CamelCasePropertyNamesContractResolver()
     };
 }
Esempio n. 9
0
 public RestProxy(
     IHttpRequestFactory httpRequestFactory,
     IRestCallResultAdapter resultAdapter,
     IHttpClientProxy httpClientProxy)
 {
     _httpRequestFactory = httpRequestFactory;
     _resultAdapter      = resultAdapter;
     _httpClientProxy    = httpClientProxy;
 }
        internal HttpClient GetClient()
        {
            if (client == null)
            {
                client = App.Config.HttpClientFactory.GetHttpClient(App.Config.AuthRequestTimeout);
            }

            return(client.GetHttpClient());
        }
Esempio n. 11
0
 public ConnectionSettings(UserCredentials defaultUserCredentials, TimeSpan?connectionTimeout, Action <IEventStoreHttpConnection, Exception> errorHandler, ILog log, IHttpClientProxy httpClientProxy, string connectionName)
 {
     DefaultUserCredentials = defaultUserCredentials;
     ConnectionTimeout      = connectionTimeout;
     ErrorHandler           = errorHandler;
     Log             = log;
     HttpClientProxy = httpClientProxy;
     ConnectionName  = connectionName;
 }
Esempio n. 12
0
        private HttpClient GetClient(TimeSpan?timeout = null)
        {
            if (this.client == null)
            {
                this.client = Client.Options.HttpClientFactory.GetHttpClient(timeout ?? DEFAULT_HTTP_CLIENT_TIMEOUT);
            }

            return(this.client.GetHttpClient());
        }
Esempio n. 13
0
 public MvcRemoteTenantStore(
     IHttpClientProxy <IAbpTenantAppService> proxy,
     IHttpContextAccessor httpContextAccessor,
     IDistributedCache <TenantConfiguration> cache)
 {
     Proxy = proxy;
     HttpContextAccessor = httpContextAccessor;
     Cache = cache;
 }
Esempio n. 14
0
        private HttpClient GetClient()
        {
            if (client == null)
            {
                client = App.Config.HttpClientFactory.GetHttpClient(App.Config.DatabaseRequestTimeout);
            }

            return(client.GetHttpClient());
        }
Esempio n. 15
0
        public SecretShare(IHttpClientProxy client, int id)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            _inner = new SecretsListExtract(client, $"Secrets/PublicShare/{id}");
        }
 public ConnectionSettings(UserCredentials defaultUserCredentials, TimeSpan? connectionTimeout, Action<IEventStoreHttpConnection, Exception> errorHandler, ILog log, IHttpClientProxy httpClientProxy, string connectionName)
 {
     DefaultUserCredentials = defaultUserCredentials;
     ConnectionTimeout = connectionTimeout;
     ErrorHandler = errorHandler;
     Log = log;
     HttpClientProxy = httpClientProxy;
     ConnectionName = connectionName;
 }
 public WebAssemblyCachedApplicationConfigurationClient(
     IHttpClientProxy <IAbpApplicationConfigurationAppService> proxy,
     ApplicationConfigurationCache cache,
     ICurrentTenantAccessor currentTenantAccessor)
 {
     Proxy = proxy;
     Cache = cache;
     CurrentTenantAccessor = currentTenantAccessor;
 }
        public AntiForgeryAction(IHttpClientProxy client)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            _client = client;
        }
Esempio n. 19
0
        public LoginManager(ApiConfiguration apiConfiguration, IHttpClientProxy httpClientProxy)
        {
            this.apiConfiguration      = apiConfiguration;
            this.httpClientProxy       = httpClientProxy;
            loginRefreshTimer.Elapsed += LoginRefreshTimer_Elapsed;

            loginMethod = LoginMethod.ActiveDirectory;
            httpClientProxy.UseActiveDirectoryAuthorization = loginMethod == LoginMethod.ActiveDirectory;
        }
Esempio n. 20
0
        public SecretsList(IHttpClientProxy client)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            _inner = new SecretsListExtract(client, "Secrets");
        }
 public MvcCachedApplicationConfigurationClient(
     IDistributedCache <ApplicationConfigurationDto> cache,
     IHttpClientProxy <IAbpApplicationConfigurationAppService> proxy,
     ICurrentUser currentUser,
     IHttpContextAccessor httpContextAccessor)
 {
     Proxy               = proxy;
     CurrentUser         = currentUser;
     HttpContextAccessor = httpContextAccessor;
     Cache               = cache;
 }
Esempio n. 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FirebaseClient"/> class.
        /// </summary>
        /// <param name="baseUrl"> The base url. </param>
        /// <param name="offlineDatabaseFactory"> Offline database. </param>
        public FirebaseClient(string baseUrl, FirebaseOptions options = null)
        {
            this.Options    = options ?? new FirebaseOptions();
            this.HttpClient = Options.HttpClientFactory.GetHttpClient(null);

            this.baseUrl = baseUrl;

            if (!this.baseUrl.EndsWith("/"))
            {
                this.baseUrl += "/";
            }
        }
 public MvcCachedApplicationConfigurationClient(
     IDistributedCache <ApplicationConfigurationDto> cache,
     IHttpClientProxy <IAbpApplicationConfigurationAppService> proxy,
     ICurrentUser currentUser,
     IHttpContextAccessor httpContextAccessor,
     IOptions <AbpAspNetCoreMvcClientCacheOptions> options)
 {
     Proxy               = proxy;
     CurrentUser         = currentUser;
     HttpContextAccessor = httpContextAccessor;
     Cache               = cache;
     Options             = options.Value;
 }
        /// <summary>
        /// Creates a new <see cref="IEventStoreHttpConnection"/> to single node using specific <see cref="ConnectionSettings"/>
        /// </summary>
        /// <param name="settings">The <see cref="ConnectionSettings"/> to apply to the new connection</param>
        /// <param name="endpoint">The endpoint to connect to.</param>
        /// <returns>a new <see cref="IEventStoreHttpConnection"/></returns>
        internal EventStoreHttpConnection(ConnectionSettings settings, string endpoint)
        {
            Ensure.NotNull(settings, "settings");
            Ensure.NotNull(endpoint, "endpoint");

            _httpClientProxy = settings.HttpClientProxy;
            _settings        = settings;
            _log             = settings.Log;
            _endpoint        = endpoint;
            _errorHandler    = settings.ErrorHandler;
            _connectionName  = settings.ConnectionName;
            _httpClient      = GetClient();
        }
Esempio n. 25
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IConfiguration>(Configuration)
            .AddHttpContextAccessor()
            .AddLogging(builder =>
            {
            })
            .AddHttpClient("workflow")
            .ConfigureHttpMessageHandlerBuilder(builder =>
            {
                HttpClientHandler handler           = new HttpClientHandler();
                handler.MaxRequestContentBufferSize = int.MaxValue;
                handler.ClientCertificateOptions    = ClientCertificateOption.Automatic;
                handler.UseDefaultCredentials       = true;
                handler.UseProxy = false;
                handler.ServerCertificateCustomValidationCallback += (s, arg1, arg2, arg3) => true;
                builder.PrimaryHandler = handler;
                builder.Build();
            });

            services.AddProcessEngine(Configuration);

            services.AddSingleton <IUserServiceProxy, DefaultUserServiceProxy>();

            var sd = services.FirstOrDefault(x => x.ServiceType == typeof(IServiceWebApiHttpProxy));

            if (sd != null)
            {
                services.Remove(sd);
            }
            services.AddTransient <IServiceWebApiHttpProxy>(sp =>
            {
                IHttpClientProxy proxy = IntegrationTestContext.testContext.CreateHttpClientProxy(new UserInfo
                {
                    Id       = "8a010000-5d88-0015-e013-08d6bd87c815",
                    FullName = "用户1",
                    TenantId = IntegrationTestContext.testContext.TenantId
                });
                return(new ServiceWebApiHttpProxy(proxy, sp.GetService <ILoggerFactory>()));
            });

            IMvcBuilder mvcBuilder = services.AddMvc()
                                     .AddProcessEngineRestServices(Configuration)
                                     .SetCompatibilityVersion(CompatibilityVersion.Latest);

            mvcBuilder.AddApplicationPart(GetType().Assembly);

            ServiceProvider = services.BuildServiceProvider();

            return(ServiceProvider);
        }
        public CreateSecretAction(IHttpClientProxy client, IAntiForgeryAction antiForgeryAction)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (antiForgeryAction == null)
            {
                throw new ArgumentNullException("antiForgeryAction");
            }

            _client            = client;
            _antiForgeryAction = antiForgeryAction;
        }
Esempio n. 27
0
        public HttpClientProxyTests()
        {
            _messageHandler = new MockHttpMessageHandler();
            _httpClient     = new HttpClient(_messageHandler);
            var settingsContainer = Substitute.For <IOptions <WebexTeamsSettings> >();
            var settings          = new WebexTeamsSettings
            {
                BotAuthToken     = "botAuthToken",
                WebexTeamsApiUrl = "https://localhost:1234"
            };

            settingsContainer.Value.Returns(settings);
            _subject = new HttpClientProxy(_httpClient, settingsContainer);
        }
        public SecretsListExtract(IHttpClientProxy client, string relativePath)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (relativePath == null)
            {
                throw new ArgumentNullException("relativePath");
            }

            _client       = client;
            _relativePath = relativePath;
        }
Esempio n. 29
0
        /// <summary>
        /// Workflow HttpClient注入
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static IServiceCollection AddWorkflowClient(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddSpringCoreTypeRepository();

            services.AddHttpClient(HTTPCLIENT_WORKFLOW)
            .ConfigureHttpMessageHandlerBuilder(builder =>
            {
                HttpClientHandler handler           = new HttpClientHandler();
                handler.MaxRequestContentBufferSize = int.MaxValue;
                handler.ClientCertificateOptions    = ClientCertificateOption.Automatic;
                handler.UseDefaultCredentials       = true;
                handler.ServerCertificateCustomValidationCallback += (s, arg1, arg2, arg3) => true;
                builder.PrimaryHandler = handler;
                builder.Build();
            });

            services.AddSingleton <ExternalConnectorProvider>(sp =>
            {
                return(new ExternalConnectorProvider(configuration));
            });

            services.AddTransient <IAccessTokenProvider, DefaultAccessTokenProvider>();

            services.AddHttpClient <DefaultHttpClientProxy>(HTTPCLIENT_WORKFLOW);

            services.AddTransient <IHttpClientProxy>(sp =>
            {
                IHttpClientProxy httpClientProxy = sp.GetService <DefaultHttpClientProxy>();

                var eco = sp.GetService <ExternalConnectorProvider>();
                var url = eco.WorkflowUrl;
                if (!string.IsNullOrWhiteSpace(url))
                {
                    httpClientProxy.HttpClient.BaseAddress = new Uri(url);
                }

                return(httpClientProxy);
            });

            services.AddTransient <WorkflowHttpClientProxyProvider>(sp =>
            {
                return(new WorkflowHttpClientProxyProvider(sp.GetService <IHttpClientProxy>()));
            });

            services.AddUserSession <DefaultUserSession>();

            return(services);
        }
Esempio n. 30
0
        private void ExecuteGet(IExecutionEntity execution, string url, object request, string dataObj, IHttpClientProxy httpProxy)
        {
            url = QueryParameter(execution, url, request, true);

            if (string.IsNullOrWhiteSpace(dataObj))
            {
                AsyncHelper.RunSync(() => httpProxy.GetAsync(url));
            }
            else
            {
                HttpResponseMessage response = AsyncHelper.RunSync(() => httpProxy.GetAsync <HttpResponseMessage>(url, CancellationToken.None));

                object data = null;
                if (response is null == false)
                {
                    response.EnsureSuccessStatusCode();
                    data = AsyncHelper.RunSync(() => ToObject(response));
                }

                execution.SetVariable(dataObj, data);
            }
        }
Esempio n. 31
0
 /// <inheritdoc />
 public ProcessInstanceTasksClient(IHttpClientProxy httpProxy)
 {
     this.httpProxy = httpProxy;
 }
 public ConnectionSettingsBuilder WithHttpClientProxy(IHttpClientProxy httpClientProxy)
 {
     _httpClientProxy = httpClientProxy;
     return this;
 }