Ejemplo n.º 1
0
        /// <inheritdoc/>
        /// <remarks>
        /// This implementation calls <see cref="IsAuthenticatedCall"/> to determine whether or not a particular HTTP
        /// API call should be treated as an "authenticated" call. The behavior of this method depends on the result of
        /// that method, as shown in the following table.
        /// <list type="table">
        /// <listheader>
        /// <term><see cref="IsAuthenticatedCall"/></term>
        /// <description>Behavior</description>
        /// </listheader>
        /// <item>
        /// <description><see langword="true"/></description>
        /// <description>Authenticate <paramref name="requestMessage"/> using the <see cref="AuthenticatedCallsService"/> authentication service.</description>
        /// </item>
        /// <item>
        /// <description><see langword="false"/></description>
        /// <description>Authenticate <paramref name="requestMessage"/> using the <see cref="UnauthenticatedCallsService"/> authentication service.</description>
        /// </item>
        /// <item>
        /// <description><see langword="null"/></description>
        /// <description>Return without altering <paramref name="requestMessage"/> at all.</description>
        /// </item>
        /// </list>
        /// </remarks>
        public Task AuthenticateRequestAsync(HttpRequestMessage requestMessage, CancellationToken cancellationToken)
        {
            if (requestMessage == null)
            {
                throw new ArgumentNullException("requestMessage");
            }

            bool?authenticated = IsAuthenticatedCall(requestMessage);

            if (!authenticated.HasValue)
            {
                return(CompletedTask.Default);
            }

            if (authenticated.Value)
            {
                return(AuthenticatedCallsService.AuthenticateRequestAsync(requestMessage, cancellationToken));
            }
            else
            {
                return(UnauthenticatedCallsService.AuthenticateRequestAsync(requestMessage, cancellationToken));
            }
        }
Ejemplo n.º 2
0
 /// <inheritdoc/>
 /// <remarks>
 /// <para>The base implementation always uses <see cref="AuthenticatedCallsService"/> to provide the behavior
 /// for this method.</para>
 /// </remarks>
 /// <exception cref="InvalidOperationException">If a recursive call to this method is detected.</exception>
 public Task <Uri> GetBaseAddressAsync(string serviceType, string serviceName, string region, bool internalAddress, CancellationToken cancellationToken)
 {
     return(AuthenticatedCallsService.GetBaseAddressAsync(serviceType, serviceName, region, internalAddress, cancellationToken));
 }