Exemple #1
0
        /// <summary>
        /// Handler for the page's back key events.  We use this to determine whether navigations
        /// away from this page are benign (such as going to the start screen) or actually meant
        /// to cancel the operation.
        /// </summary>
        void LoginPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
        {
            responseData   = "";
            responseStatus = WebAuthenticationStatus.UserCancel;

            authenticationFinished = true;
        }
Exemple #2
0
        private async Task <AppStartupStatus> EnsureAppCreatedAsync(CancellationToken cancelToken)
        {
            if (m_client.UseOnlineAuthModel &&
                !await m_client.EnsureUserIdentityAsync(cancelToken,
                                                        HealthVaultClient.HBIAuthPolicy))
            {
                return(AppStartupStatus.Failed);
            }

            // See if we have a cached ServiceInfo.
            ServiceInfo cachedInfo = await HealthVault.Foundation.ServiceInfo.Load();

            if (cachedInfo != null)
            {
                UpdateServiceInfo(cachedInfo);
            }

            WebAuthenticationStatus authStatus = await m_client.EnsureAppProvisionedAsync(cancelToken);

            if (cachedInfo == null || m_client.ServiceInfo.ServiceUrl != ServiceInfo.ServiceUrl)
            {
                UpdateServiceInfo(m_client.ServiceInfo);
                await m_client.ServiceInfo.Save();
            }

            return(WebAuthenticationStatusToStartupStatus(authStatus));
        }
 public static void OnAuthenticationFinished(string data, WebAuthenticationStatus status, uint error)
 {
     _responseData            = data;
     _responseStatus          = status;
     _responseErrorDetail     = error;
     AuthenticationInProgress = false;
     AuthenticateFinishedEvent.Set();
 }
        private void WebBrowserOnNavigationFailed(object sender, NavigationFailedEventArgs e)
        {
            var navigationException = e.Exception as WebBrowserNavigationException;

            _responseErrorDetail    = navigationException == null ? 0U : (uint)navigationException.StatusCode;
            _responseStatus         = WebAuthenticationStatus.ErrorHttp;
            _authenticationFinished = true;
            e.Handled = true;
            GoBack();
        }
        public static void OnAuthenticationFinished(string data, WebAuthenticationStatus status, uint error)
        {
            WebAuthenticationBroker.responseData        = data;
            WebAuthenticationBroker.responseStatus      = status;
            WebAuthenticationBroker.responseErrorDetail = error;

            WebAuthenticationBroker.AuthenticationInProgress = false;

            // Signal the waiting task that the authentication operation has finished.
            authenticateFinishedEvent.Set();
        }
Exemple #6
0
        private AppStartupStatus WebAuthenticationStatusToStartupStatus(WebAuthenticationStatus authStatus)
        {
            switch (authStatus)
            {
            default:
                return(AppStartupStatus.Failed);

            case WebAuthenticationStatus.Success:
                return(AppStartupStatus.Success);

            case WebAuthenticationStatus.UserCancel:
                return(AppStartupStatus.Cancelled);
            }
        }
Exemple #7
0
        /// <summary>
        /// Handler for the browser control's navigating event.  We use this to detect when login
        /// has completed.
        /// </summary>
        private void BrowserControl_Navigating(object sender, NavigatingEventArgs e)
        {
            if (e.Uri == WebAuthenticationBroker.EndUri)
            {
                responseData   = e.Uri.ToString();
                responseStatus = WebAuthenticationStatus.Success;

                authenticationFinished = true;

                // Navigate back now.
                browserControl.Source = new Uri("about:blank");
                NavigationService.GoBack();
            }
        }
Exemple #8
0
        /// <summary>
        /// Handler for the browser control's navigating event.  We use this to detect when login
        /// has completed.
        /// </summary>
        private void BrowserControl_Navigating(object sender, NavigatingEventArgs e)
        {
            //Updated to test only Absolute path as parameters will always be different
            if (e.Uri.AbsolutePath == WebviewAuthentication.EndUri.AbsolutePath)
            {
                responseData   = e.Uri.ToString();
                responseStatus = WebAuthenticationStatus.Success;

                authenticationFinished = true;

                // Navigate back now.
                browserControl.Source = new Uri("about:blank");
                NavigationService.GoBack();
            }
        }
        private void WebBrowserOnNavigating(object sender, NavigatingEventArgs e)
        {
            if (!e.Uri.Host.Equals("localhost"))
            {
                return;
            }
            e.Cancel = true;
            var pos         = e.Uri.Query.IndexOf("=", StringComparison.Ordinal);
            var messageCode = pos > -1 ? e.Uri.Query.Substring(pos + 1) : null;

            if (messageCode == null)
            {
                _responseErrorDetail = 1;
            }
            _responseData           = messageCode;
            _responseStatus         = WebAuthenticationStatus.Success;
            _authenticationFinished = true;
            GoBack();
        }
Exemple #10
0
        /// <summary>
        /// Handler for the browser control's navigation failed event.  We use this to detect errors
        /// </summary>
        private void BrowserControl_NavigationFailed(object sender, NavigationFailedEventArgs e)
        {
            WebBrowserNavigationException navEx = e.Exception as WebBrowserNavigationException;

            if (navEx != null)
            {
                // Pass along the provided error information.
                responseErrorDetail = (uint)navEx.StatusCode;
            }
            else
            {
                // No error information available.
                responseErrorDetail = 0;
            }
            responseStatus = WebAuthenticationStatus.ErrorHttp;

            authenticationFinished = true;
            e.Handled = true;

            // Navigate back now.
            browserControl.Source = new Uri("about:blank");
            NavigationService.GoBack();
        }
 internal WebAuthenticationResult(string response, uint errorDetail, WebAuthenticationStatus responseStatus)
 {
     ResponseData        = response;
     ResponseErrorDetail = errorDetail;
     ResponseStatus      = responseStatus;
 }
        private AppStartupStatus WebAuthenticationStatusToStartupStatus(WebAuthenticationStatus authStatus)
        {
            switch (authStatus)
            {
                default:
                    return AppStartupStatus.Failed;

                case WebAuthenticationStatus.Success:
                    return AppStartupStatus.Success;

                case WebAuthenticationStatus.UserCancel:
                    return AppStartupStatus.Cancelled;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpotifyWebAuthenticationBrokerException"/> class.
 /// </summary>
 /// <param name="reason">The reason.</param>
 public SpotifyWebAuthenticationBrokerException(WebAuthenticationStatus reason)
     : base($"Authorization exception with reason '{reason}' has occurred.")
 {
     this.Reason = reason;
 }
 public WebAuthenticationResult(string data, WebAuthenticationStatus status, uint error)
 {
     ResponseData = data;
     ResponseStatus = status;
     ResponseErrorDetail = error;
 }
 internal WebAuthenticationResult(string responseData, uint errorDetail, WebAuthenticationStatus status)
 {
     _responseData = responseData;
     _responseErrorDetail = errorDetail;
     _responseStatus = status;
 }
 /// <summary>Constructs a new instance of the class and set its properties by the specified result.</summary>
 public SerializableWebAuthResult(WebAuthenticationResult result)
 {
     this.ResponseData        = result.ResponseData;
     this.ResponseErrorDetail = result.ResponseErrorDetail;
     this.ResponseStatus      = result.ResponseStatus;
 }
        private static async Task <AdnWebAuthenticationResult> AuthenticateAsyncTask(
            WebAuthenticationOptions options,
            Uri startUri,
            Uri endUri)
        {
            TaskCompletionSource <int> tcs = new TaskCompletionSource <int>();

            WebAuthenticationStatus responseStatus = WebAuthenticationStatus.Success;

            string responseData = "";

            Popup popUp = new Popup
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,

                Width  = 800,
                Height = Window.Current.Bounds.Height
            };

            var webAuthView = new AdnWebAuthView
            {
                Width  = Window.Current.Bounds.Width,
                Height = Window.Current.Bounds.Height
            };

            webAuthView.CancelledEvent += (s, e) =>
            {
                responseStatus = WebAuthenticationStatus.UserCancel;

                popUp.IsOpen = false;

                tcs.TrySetResult(1);
            };

            webAuthView.UriChangedEvent += (s, e) =>
            {
                if (e != null)
                {
                    if (e.Uri.AbsoluteUri.StartsWith(
                            endUri.AbsoluteUri,
                            StringComparison.OrdinalIgnoreCase))
                    {
                        responseStatus = WebAuthenticationStatus.Success;
                        responseData   = e.Uri.AbsoluteUri;

                        popUp.IsOpen = false;

                        tcs.TrySetResult(1);
                    }
                }
            };

            webAuthView.NavFailedEvent += (s, e) =>
            {
                if (e.Uri.AbsoluteUri.StartsWith(
                        endUri.AbsoluteUri,
                        StringComparison.OrdinalIgnoreCase))
                {
                    responseStatus = WebAuthenticationStatus.Success;
                    responseData   = e.Uri.AbsoluteUri;
                }
                else
                {
                    responseStatus = WebAuthenticationStatus.ErrorHttp;
                    responseData   = e.Uri.AbsoluteUri;
                }

                popUp.IsOpen = false;

                tcs.TrySetResult(1);
            };

            popUp.Child  = webAuthView;
            popUp.IsOpen = true;
            webAuthView.Navigate(startUri);

            await tcs.Task;

            return(new AdnWebAuthenticationResult
            {
                ResponseStatus = responseStatus,
                ResponseData = responseData
            });
        }
 public AuthResult(WebAuthenticationStatus status)
 {
     Status = status;
 }
Exemple #19
0
 public async Task <bool> RequestFlickrAuthorizationComplete(WebAuthenticationStatus ResponseStatus, string ResponseData, uint ResponseErrorDetail)
 {
     return(await _fvm.RequestFlickrAuthorizationComplete(ResponseStatus, ResponseData, ResponseErrorDetail));
 }
 public AuthResult(WebAuthenticationStatus status)
 {
     Status = status;
 }
        /// <summary>
        /// Handler for the page's back key events.  We use this to determine whether navigations
        /// away from this page are benign (such as going to the start screen) or actually meant
        /// to cancel the operation.
        /// </summary>
        void LoginPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
        {
            responseData = "";
            responseStatus = WebAuthenticationStatus.UserCancel;

            authenticationFinished = true;
        }
        /// <summary>
        /// Handler for the browser control's navigation failed event.  We use this to detect errors
        /// </summary>
        private void BrowserControl_NavigationFailed(object sender, NavigationFailedEventArgs e)
        {
            WebBrowserNavigationException navEx = e.Exception as WebBrowserNavigationException;

            if (navEx != null)
            {
                // Pass along the provided error information.
                responseErrorDetail = (uint)navEx.StatusCode;
            }
            else
            {
                // No error information available.
                responseErrorDetail = 0;
            }
            responseStatus = WebAuthenticationStatus.ErrorHttp;

            authenticationFinished = true;
            e.Handled = true;

            // Navigate back now.
            browserControl.Source = new Uri("about:blank");
            NavigationService.GoBack();
        }
        /// <summary>
        /// Handler for the browser control's navigating event.  We use this to detect when login
        /// has completed.
        /// </summary>
        private void BrowserControl_Navigating(object sender, NavigatingEventArgs e)
        {
            //Updated to test only Absolute path as parameters will always be different
            if (e.Uri.AbsolutePath == WebAuthenticationBroker.EndUri.AbsolutePath)
            {
                responseData = e.Uri.ToString();
                responseStatus = WebAuthenticationStatus.Success;

                authenticationFinished = true;

                // Navigate back now.
                browserControl.Source = new Uri("about:blank");
                NavigationService.GoBack();
            }
        }
 /// <summary>Constructs a new instance of the class and set its properties by the specified result.</summary>
 public SerializableWebAuthResult(WebAuthenticationResult result)
 {
     this.ResponseData = result.ResponseData;
     this.ResponseErrorDetail = result.ResponseErrorDetail;
     this.ResponseStatus = result.ResponseStatus;
 }
 private void LoginPageOnBackKeyPress(object sender, CancelEventArgs e)
 {
     _responseData           = string.Empty;
     _responseStatus         = WebAuthenticationStatus.UserCancel;
     _authenticationFinished = true;
 }
        /// <summary>
        /// Handler for the browser control's navigating event.  We use this to detect when login
        /// has completed.
        /// </summary>
        private void BrowserControl_Navigating(object sender, NavigatingEventArgs e)
        {
            if (e.Uri == WebAuthenticationBroker.EndUri)
            {
                responseData = e.Uri.ToString();
                responseStatus = WebAuthenticationStatus.Success;

                authenticationFinished = true;

                // Navigate back now.
                browserControl.Source = new Uri("about:blank");
                NavigationService.GoBack();
            }
        }
Exemple #27
0
 public ApiAuthException(WebAuthenticationStatus authenticationStatus)
 {
     AuthenticationStatus = authenticationStatus;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpotifyUwpAuthorizationException"/> class.
 /// </summary>
 /// <param name="reason">The reason.</param>
 public SpotifyUwpAuthorizationException(WebAuthenticationStatus reason) : base($"Authorization exception with reason {reason} has occurred.")
 {
     this.Reason = reason;
 }
        public static void OnAuthenticationFinished(string data, WebAuthenticationStatus status, uint error)
        {
            WebAuthenticationBroker.responseData = data;
            WebAuthenticationBroker.responseStatus = status;
            WebAuthenticationBroker.responseErrorDetail = error;

            WebAuthenticationBroker.AuthenticationInProgress = false;

            // Signal the waiting task that the authentication operation has finished.
            authenticateFinishedEvent.Set();
        }
Exemple #30
0
 internal WebAuthenticationResult(string responseData, uint responseErrorDetail, WebAuthenticationStatus status)
 {
     ResponseData        = responseData;
     ResponseErrorDetail = responseErrorDetail;
     ResponseStatus      = status;
 }
 public WebAuthenticationResult(string data, WebAuthenticationStatus status, uint error)
 {
     ResponseData        = data;
     ResponseStatus      = status;
     ResponseErrorDetail = error;
 }
 public WebAuthenticationResult(string?responseData, uint responseErrorDetail, WebAuthenticationStatus responseStatus)
 {
     ResponseData        = responseData;
     ResponseErrorDetail = responseErrorDetail;
     ResponseStatus      = responseStatus;
 }
 public ApiAuthException(WebAuthenticationStatus authenticationStatus)
 {
     AuthenticationStatus = authenticationStatus;
 }