コード例 #1
0
        protected async override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var client = new HawkClient(this.credentialsCallback);

            if (this.normalizationCallback != null)
            {
                client.ApplicationSpecificData = this.normalizationCallback(request);
            }

            await client.CreateClientAuthorizationAsync(request);

            var response = await base.SendAsync(request, cancellationToken);

            if (!await client.AuthenticateAsync(response))
            {
                throw new SecurityException("Invalid Mac and/or hash. Response possibly tampered.");
            }

            bool isValidAppSpecificData = this.verificationCallback == null ||
                                          this.verificationCallback(response, client.WebApiSpecificData);

            if (!isValidAppSpecificData)
            {
                throw new SecurityException("Invalid Application Specific Data");
            }

            return(response);
        }
        protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var client = new HawkClient(options);
            await client.CreateClientAuthorizationAsync(new WebApiRequestMessage(request));

            var response = await base.SendAsync(request, cancellationToken);
            var responseMessage = new WebApiResponseMessage(response);

            if (!await client.AuthenticateAsync(responseMessage))
                throw new SecurityException("Invalid Mac and/or hash. Response possibly tampered.");

            return response;
        }
コード例 #3
0
        protected async override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var client = new HawkClient(options);
            await client.CreateClientAuthorizationAsync(new WebApiRequestMessage(request));

            var response = await base.SendAsync(request, cancellationToken);

            var responseMessage = new WebApiResponseMessage(response);

            if (!await client.AuthenticateAsync(responseMessage))
            {
                throw new SecurityException("Invalid Mac and/or hash. Response possibly tampered.");
            }

            return(response);
        }