Ejemplo n.º 1
0
        private HttpClientServiceFactory()
        {
            //no configuration for Dektop
            _configuration = null;
            var identityServerHttpClient = new HttpClient();

            _coreHttpClient = new CoreHttpClient(
                new HttpClient()
                );

            _tokenResponseService = new IdentityServerService(
                new IdentityServerHttpClientSelector(
                    new List <IIdentityServerHttpClient>
            {
                { new ClientCredentialsHttpClient(identityServerHttpClient) },
                { new PasswordHttpClient(identityServerHttpClient) }
            }
                    ),
                new TokenResponseCacheManager(
                    new MemoryCache(
                        Options.Create(
                            new MemoryCacheOptions()
                            )
                        )
                    )
                );

            _requestMessageFactory = new HttpRequestMessageFactoryDesktop();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor of the <see cref="HttpClientServiceFactory" />.
        /// </summary>
        /// <param name="configuration">Application configuration properties.</param>
        /// <param name="coreHttpClient">An <see cref="ICoreHttpClient"/> implementation that will execute the HTTP requests.</param>
        /// <param name="requestMessageFactory">The <see cref="IHttpRequestMessageFactory"/> to get a new <see cref="HttpRequestMessage"/>.</param>
        /// <param name="tokenResponseService">The <see cref="IIdentityServerService"/> to retrieve a token, if required.</param>
        public HttpClientServiceFactory(IConfiguration configuration, ICoreHttpClient coreHttpClient, IHttpRequestMessageFactory requestMessageFactory, IIdentityServerService tokenResponseService)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (coreHttpClient == null)
            {
                throw new ArgumentNullException(nameof(coreHttpClient));
            }

            if (requestMessageFactory == null)
            {
                throw new ArgumentNullException(nameof(requestMessageFactory));
            }

            if (tokenResponseService == null)
            {
                throw new ArgumentNullException(nameof(tokenResponseService));
            }

            _configuration         = configuration;
            _coreHttpClient        = coreHttpClient;
            _tokenResponseService  = tokenResponseService;
            _requestMessageFactory = requestMessageFactory;
        }
 public IdentityServiceProvider(HttpClient httpClient, IHttpRequestMessageFactory httpRequestMessageFactory, IAppConfiguration appConfiguration, ILogger logger)
 {
     _httpClient = httpClient;
     _httpRequestMessageFactory = httpRequestMessageFactory;
     _appConfiguration          = appConfiguration;
     _logger = logger;
 }
Ejemplo n.º 4
0
 public IdPSearchServiceProvider(IAppConfiguration appConfig, ILogger logger, PolicyProvider policyProvider, HttpClient httpClient, IHttpRequestMessageFactory httpRequestMessageFactory)
 {
     _appConfig                 = appConfig;
     _logger                    = logger;
     _policyProvider            = policyProvider;
     _httpClient                = httpClient;
     _httpRequestMessageFactory = httpRequestMessageFactory;
 }
Ejemplo n.º 5
0
    internal HttpClientService(ICoreHttpClient coreHttpClient, IHttpRequestMessageFactory requestMessageFactory, IIdentityServerService accessTokenService)
    {
        _coreHttpClient        = coreHttpClient;
        _requestMessageFactory = requestMessageFactory;
        _accessTokenService    = accessTokenService;

        Headers = new HttpClientServiceHeaders();
    }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RequestProcessor"/> class.
        /// </summary>
        /// <param name="httpClient">An implementation of the <see cref="HttpClient"/> class.</param>
        /// <param name="httpRequestMessageFactory">The <see cref="IHttpRequestMessageFactory"/>.</param>
        /// <param name="responseHeaderMapper">The <see cref="IResponseHeaderMapper"/>.</param>
        /// <exception cref="ArgumentNullException">The value of '<paramref name="httpClient"/>', '<paramref name="httpRequestMessageFactory"/>' and '<paramref name="responseHeaderMapper"/>' cannot be null. </exception>
        public RequestProcessor([NotNull] HttpClient httpClient, [NotNull] IHttpRequestMessageFactory httpRequestMessageFactory, [NotNull] IResponseHeaderMapper responseHeaderMapper)
        {
            if (httpClient == null)
            {
                throw new ArgumentNullException(nameof(httpClient));
            }

            if (httpRequestMessageFactory == null)
            {
                throw new ArgumentNullException(nameof(httpRequestMessageFactory));
            }

            if (responseHeaderMapper == null)
            {
                throw new ArgumentNullException(nameof(responseHeaderMapper));
            }

            this.HttpClient = httpClient;
            this.httpRequestMessageFactory = httpRequestMessageFactory;
            this.responseHeaderMapper      = responseHeaderMapper;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GoogleRequestProcessor"/> class.
        /// </summary>
        /// <param name="httpClient">The <see cref="HttpClient"/>.</param>
        /// <param name="authorizationContextConfiguration">The <see cref="IAuthorizationContextConfiguration"/>.</param>
        /// <param name="requestMessageFactory">The <see cref="IHttpRequestMessageFactory"/> that creates <see cref="HttpRequestMessage"/> instances from an <see cref="object"/>.</param>
        /// <param name="responseHeaderMapper">The <see cref="IResponseHeaderMapper"/>.</param>
        /// <exception cref="ArgumentNullException">The value of '<paramref name="authorizationContextConfiguration"/>', '<paramref name="httpClient"/>', '<paramref name="requestMessageFactory"/>' and '<paramref name="responseHeaderMapper"/>' cannot be null. </exception>
        public GoogleRequestProcessor([NotNull] HttpClient httpClient, [NotNull] IAuthorizationContextConfiguration authorizationContextConfiguration, [NotNull] IHttpRequestMessageFactory requestMessageFactory, [NotNull] IResponseHeaderMapper responseHeaderMapper)
            : base(httpClient, requestMessageFactory, responseHeaderMapper)
        {
            if (authorizationContextConfiguration == null)
            {
                throw new ArgumentNullException(nameof(authorizationContextConfiguration));
            }

            this.HttpClient.BaseAddress = authorizationContextConfiguration.BaseUrl;
        }
Ejemplo n.º 8
0
        public ProviderManagerFlow(
            ILogger <ProviderManagerFlow> logger,
            IMessageDumper messageDumper,

            HttpClientManager httpClientManager,
            IHttpRequestMessageFactory httpRequestMessageFactory,
            ITranslationDistributer translationDistributer
            )
        {
            this.logger                    = logger;
            this.messageDumper             = messageDumper;
            this.httpClientManager         = httpClientManager;
            this.httpRequestMessageFactory = httpRequestMessageFactory;
            this.translationDistributer    = translationDistributer;
            createHttpRequestBlock
                = new TransformManyBlock <MessageContext <TranslationsRequest>, MessageContext <HttpRequestMessage> >(
                      CreateHttpRequestHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            execHttpRequestBlock
                = new TransformManyBlock <MessageContext <HttpRequestMessage>, MessageContext <HttpResponseMessage> >(
                      ExecHttpRequestHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            parseHttpResponseBlock
                = new TransformManyBlock <MessageContext <HttpResponseMessage>, MessageContext <string> >(
                      ParseHttpResponseHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            broadcastResponseBlock = new BroadcastBlock <MessageContext <string> >(t => t);

            dumpResponseBlock
                = new ActionBlock <MessageContext <string> >(
                      DumpResponseHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            deserializeResponseBlock
                = new TransformManyBlock <MessageContext <string>, MessageContext <Translation> >(
                      DeserializeResponseHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            translationDistributerBlock
                = new ActionBlock <MessageContext <Translation> >(
                      TranslationDistributerHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            createHttpRequestBlock.LinkTo(execHttpRequestBlock);
            execHttpRequestBlock.LinkTo(parseHttpResponseBlock);

            parseHttpResponseBlock.LinkTo(broadcastResponseBlock);

            broadcastResponseBlock.LinkTo(dumpResponseBlock);
            broadcastResponseBlock.LinkTo(deserializeResponseBlock);
            deserializeResponseBlock.LinkTo(translationDistributerBlock);
        }
Ejemplo n.º 9
0
 public AuthenticationHandler(AuthenticationConfiguration configuration, IHttpRequestMessageFactory httpRequestMessageFactory)
 {
     this.authenticationHandler     = new HttpAuthentication(configuration);
     this.httpRequestMessageFactory = httpRequestMessageFactory;
 }
Ejemplo n.º 10
0
        public FeedSubscriberFlow(
            ILogger <FeedManager> logger,
            IOptions <FeedSubscriberOptions> options,
            IMessageDumper messageDumper,
            TranslationSubscriptionCollection subscriptions,

            HttpClientManager httpClientManager,
            IHttpRequestMessageFactory httpRequestMessageFactory,
            IProviderAdapter providerAdapter,
            IFeedManager feedManager
            )
        {
            this.logger                    = logger;
            this.options                   = options.Value;
            this.messageDumper             = messageDumper;
            this.subscriptions             = subscriptions;
            this.httpClientManager         = httpClientManager;
            this.httpRequestMessageFactory = httpRequestMessageFactory;
            this.providerAdapter           = providerAdapter;
            this.feedManager               = feedManager;

            // Flow 1
            translationCreateRequestBlock
                = new TransformManyBlock <MessageContext <TranslationRequest, TranslationSubscription>,
                                          MessageContext <HttpRequestMessage, TranslationSubscription> >(
                      TranslationCreateRequestHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 2
            translationExecRequestBlock
                = new TransformManyBlock <MessageContext <HttpRequestMessage, TranslationSubscription>,
                                          MessageContext <HttpResponseMessage, TranslationSubscription> >(
                      TranslationExecRequestHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 3
            translationCheckHashBlock
                = new TransformManyBlock <MessageContext <HttpResponseMessage, TranslationSubscription>,
                                          MessageContext <string, TranslationSubscription> >(
                      TranslationCheckHashHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 4
            translationParseResponseBlock
                = new TransformManyBlock <MessageContext <string, TranslationSubscription>,
                                          MessageContext <Translation, TranslationSubscription> >(
                      TranslationMessageParseHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 5
            translationDumpBlock
                = new TransformManyBlock <MessageContext <Translation, TranslationSubscription>,
                                          MessageContext <Translation, TranslationSubscription> >(
                      TranslationDumpHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 6
            translationRouterBlock
                = new BroadcastBlock <MessageContext <Translation> >(t => t);

            // Flow 7-1
            translationToAdapterBlock
                = new ActionBlock <MessageContext <Translation> >(
                      TranslationToAdapterHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 7-2
            translationSubscriptionBlock
                = new ActionBlock <MessageContext <Translation> >(
                      TranslationSubscriptionHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            translationCreateRequestBlock.LinkTo(translationExecRequestBlock);
            translationExecRequestBlock.LinkTo(translationCheckHashBlock);
            translationCheckHashBlock.LinkTo(translationParseResponseBlock);
            translationParseResponseBlock.LinkTo(translationDumpBlock);
            translationDumpBlock.LinkTo(translationRouterBlock);
            translationRouterBlock.LinkTo(translationToAdapterBlock);
            translationRouterBlock.LinkTo(translationSubscriptionBlock);
        }