public async Task <Tuple <string, string> > GetCredentials(string title, string details = "")
        {
            try
            {
                var current = GetCurrentViewController();
                if (current == null)
                {
                    throw new Exception("window.RootViewController is not set");
                }
                var loginEntry = new LoginEntryAlert(title, details);
                var result     = await loginEntry.GetCredentials(current);

                if (string.IsNullOrWhiteSpace(result.Item1) || string.IsNullOrWhiteSpace(result.Item2))
                {
                    result = await GetCredentials(title, "Invalid Credentials");
                }
                try
                {
                    if (!(await authenticator.CheckCredentails(result.Item1, result.Item2)))
                    {
                        throw new Exception("Invalid Credentials");
                    }
                }
                catch (Exception ex)
                {
                    result = await GetCredentials(title, $"Error: {ex.Message}");
                }
                return(result);
            }
            catch (TaskCanceledException)
            {
                authenticator.OnCancelled();
                return(null);
            }
        }
Beispiel #2
0
        public async Task <Tuple <string, string> > GetCredentials(string title, string details = "")
        {
            try
            {
                var current = GetCurrentViewController();
                if (current == null)
                {
                    throw new Exception("window.RootViewController is not set");
                }
                var loginEntry = new LoginEntryAlert(title, details);
                var result     = await loginEntry.GetCredentials(current);

                if (string.IsNullOrWhiteSpace(result.Item1) || string.IsNullOrWhiteSpace(result.Item2))
                {
                    result = await GetCredentials(title, "Invalid Credentials");
                }
                try
                {
                    var  oauth   = authenticator as OAuthPasswordAuthenticator;
                    bool success = false;
                    if (oauth != null)
                    {
                        success = await oauth.VerifyCredentials(result.Item1, result.Item2);
                    }

                    var basic = authenticator as BasicAuthAuthenticator;
                    if (basic != null)
                    {
                        success = await basic.CheckCredentails(result.Item1, result.Item2);
                    }
                    if (!success)
                    {
                        throw new Exception("Invalid Credentials");
                    }
                }
                catch (Exception ex)
                {
                    result = await GetCredentials(title, $"Error: {ex.Message}");
                }
                return(result);
            }
            catch (TaskCanceledException)
            {
                authenticator.OnCancelled();
                return(null);
            }
        }
Beispiel #3
0
        public async Task <Tuple <string, string> > GetCredentials(string title, string details = "", string url = "")
        {
            var current = GetCurrentViewController();

            if (current == null)
            {
                throw new Exception("window.RootViewController is not set");
            }
            var loginEntry = new LoginEntryAlert(title, details);
            var result     = await loginEntry.GetCredentials(current);

            if (string.IsNullOrWhiteSpace(result.Item1) || string.IsNullOrWhiteSpace(result.Item2))
            {
                result = await GetCredentials(title, "Invalid Credentials");
            }
            return(result);
        }