Ejemplo 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;
 }
Ejemplo n.º 3
0
 public CurrencyConverterService(IHttpClientProxy httpClientProxy, CurrencyConverterApi currencyConverter, HomeContext context)
 {
     _httpClientProxy = httpClientProxy;
     _context         = context;
     _apiKey          = currencyConverter.ApiKey;
     _url             = currencyConverter.Url;
 }
Ejemplo n.º 4
0
        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;
 }
Ejemplo 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>();
 }
Ejemplo n.º 8
0
 public WebexTeamsApiService(IHttpClientProxy httpClientProxy)
 {
     _httpClientProxy = httpClientProxy;
     _defaultJsonSerializerSettings = new JsonSerializerSettings
     {
         ContractResolver = new CamelCasePropertyNamesContractResolver()
     };
 }
Ejemplo n.º 9
0
 public RestProxy(
     IHttpRequestFactory httpRequestFactory,
     IRestCallResultAdapter resultAdapter,
     IHttpClientProxy httpClientProxy)
 {
     _httpRequestFactory = httpRequestFactory;
     _resultAdapter      = resultAdapter;
     _httpClientProxy    = httpClientProxy;
 }
Ejemplo n.º 10
0
        internal HttpClient GetClient()
        {
            if (client == null)
            {
                client = App.Config.HttpClientFactory.GetHttpClient(App.Config.AuthRequestTimeout);
            }

            return(client.GetHttpClient());
        }
Ejemplo 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;
 }
Ejemplo 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());
        }
Ejemplo n.º 13
0
 public MvcRemoteTenantStore(
     IHttpClientProxy <IAbpTenantAppService> proxy,
     IHttpContextAccessor httpContextAccessor,
     IDistributedCache <TenantConfiguration> cache)
 {
     Proxy = proxy;
     HttpContextAccessor = httpContextAccessor;
     Cache = cache;
 }
Ejemplo n.º 14
0
        private HttpClient GetClient()
        {
            if (client == null)
            {
                client = App.Config.HttpClientFactory.GetHttpClient(App.Config.DatabaseRequestTimeout);
            }

            return(client.GetHttpClient());
        }
Ejemplo 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;
 }
Ejemplo n.º 18
0
        public AntiForgeryAction(IHttpClientProxy client)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            _client = client;
        }
Ejemplo 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;
        }
Ejemplo 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;
 }
Ejemplo 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();
        }
Ejemplo 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);
        }
Ejemplo n.º 26
0
        public CreateSecretAction(IHttpClientProxy client, IAntiForgeryAction antiForgeryAction)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (antiForgeryAction == null)
            {
                throw new ArgumentNullException("antiForgeryAction");
            }

            _client            = client;
            _antiForgeryAction = antiForgeryAction;
        }
Ejemplo 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);
        }
Ejemplo n.º 28
0
        public SecretsListExtract(IHttpClientProxy client, string relativePath)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (relativePath == null)
            {
                throw new ArgumentNullException("relativePath");
            }

            _client       = client;
            _relativePath = relativePath;
        }
Ejemplo 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);
        }
Ejemplo 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);
            }
        }
Ejemplo n.º 31
0
 /// <inheritdoc />
 public ProcessInstanceTasksClient(IHttpClientProxy httpProxy)
 {
     this.httpProxy = httpProxy;
 }
 public ConnectionSettingsBuilder WithHttpClientProxy(IHttpClientProxy httpClientProxy)
 {
     _httpClientProxy = httpClientProxy;
     return this;
 }