/// <summary>
        /// Processes an authentication request by a popup window.
        /// </summary>
        /// <param name="userIdentityPageBase">The base URI upon which user identity pages are created.</param>
        /// <param name="request">The incoming authentication request.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// A task that completes with the asynchronous operation.
        /// </returns>
        internal static async Task ProcessAuthenticationAsync(Uri userIdentityPageBase, IAuthenticationRequest request, CancellationToken cancellationToken)
        {
            Requires.NotNull(userIdentityPageBase, "userIdentityPageBase");
            Requires.NotNull(request, "request");

            var window = new CheckIdWindow(userIdentityPageBase, request);

            IHostFactories hostFactories    = new DefaultOpenIdHostFactories();
            bool           isRPDiscoverable = await request.IsReturnUrlDiscoverableAsync(hostFactories, cancellationToken) == RelyingPartyDiscoveryResult.Success;

            window.discoverableYesLabel.Visibility = isRPDiscoverable ? Visibility.Visible : Visibility.Collapsed;
            window.discoverableNoLabel.Visibility  = isRPDiscoverable ? Visibility.Collapsed : Visibility.Visible;

            bool?result = window.ShowDialog();

            // If the user pressed Esc or cancel, just send a negative assertion.
            if (!result.HasValue || !result.Value)
            {
                request.IsAuthenticated = false;
                return;
            }

            request.IsAuthenticated = window.tabControl1.SelectedItem == window.positiveTab;
            if (request.IsAuthenticated.Value)
            {
                request.ClaimedIdentifier = window.claimedIdentifierBox.Text;
                request.LocalIdentifier   = window.localIdentifierBox.Text;
            }
        }
		/// <summary>
		/// Processes an authentication request by a popup window.
		/// </summary>
		/// <param name="userIdentityPageBase">The base URI upon which user identity pages are created.</param>
		/// <param name="request">The incoming authentication request.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <returns>
		/// A task that completes with the asynchronous operation.
		/// </returns>
		internal static async Task ProcessAuthenticationAsync(Uri userIdentityPageBase, IAuthenticationRequest request, CancellationToken cancellationToken) {
			Requires.NotNull(userIdentityPageBase, "userIdentityPageBase");
			Requires.NotNull(request, "request");

			var window = new CheckIdWindow(userIdentityPageBase, request);

			IHostFactories hostFactories = new DefaultOpenIdHostFactories();
			bool isRPDiscoverable = await request.IsReturnUrlDiscoverableAsync(hostFactories, cancellationToken) == RelyingPartyDiscoveryResult.Success;
			window.discoverableYesLabel.Visibility = isRPDiscoverable ? Visibility.Visible : Visibility.Collapsed;
			window.discoverableNoLabel.Visibility = isRPDiscoverable ? Visibility.Collapsed : Visibility.Visible;

			bool? result = window.ShowDialog();

			// If the user pressed Esc or cancel, just send a negative assertion.
			if (!result.HasValue || !result.Value) {
				request.IsAuthenticated = false;
				return;
			}

			request.IsAuthenticated = window.tabControl1.SelectedItem == window.positiveTab;
			if (request.IsAuthenticated.Value) {
				request.ClaimedIdentifier = window.claimedIdentifierBox.Text;
				request.LocalIdentifier = window.localIdentifierBox.Text;
			}
		}
		/// <summary>
		/// Processes an authentication request by a popup window.
		/// </summary>
		/// <param name="provider">The OpenID Provider host.</param>
		/// <param name="request">The incoming authentication request.</param>
		internal static void ProcessAuthentication(HostedProvider provider, IAuthenticationRequest request) {
			Contract.Requires(provider != null);
			Contract.Requires(request != null);

			var window = new CheckIdWindow(provider, request);
			bool? result = window.ShowDialog();

			// If the user pressed Esc or cancel, just send a negative assertion.
			if (!result.HasValue || !result.Value) {
				request.IsAuthenticated = false;
				return;
			}

			request.IsAuthenticated = window.tabControl1.SelectedItem == window.positiveTab;
			if (request.IsAuthenticated.Value) {
				request.ClaimedIdentifier = window.claimedIdentifierBox.Text;
				request.LocalIdentifier = window.localIdentifierBox.Text;
			}
		}
        /// <summary>
        /// Processes an authentication request by a popup window.
        /// </summary>
        /// <param name="provider">The OpenID Provider host.</param>
        /// <param name="request">The incoming authentication request.</param>
        internal static void ProcessAuthentication(HostedProvider provider, IAuthenticationRequest request)
        {
            Contract.Requires(provider != null);
            Contract.Requires(request != null);

            var  window = new CheckIdWindow(provider, request);
            bool?result = window.ShowDialog();

            // If the user pressed Esc or cancel, just send a negative assertion.
            if (!result.HasValue || !result.Value)
            {
                request.IsAuthenticated = false;
                return;
            }

            request.IsAuthenticated = window.tabControl1.SelectedItem == window.positiveTab;
            if (request.IsAuthenticated.Value)
            {
                request.ClaimedIdentifier = window.claimedIdentifierBox.Text;
                request.LocalIdentifier   = window.localIdentifierBox.Text;
            }
        }