Пример #1
0
        public static void LogOut()
        {
            // TODO: Deauthenticate.
            string username = NSUserDefaults.StandardUserDefaults.StringForKey(UserNameKey);

            if (!String.IsNullOrEmpty(username))
            {
                KeychainHelpers.DeletePasswordForUsername(username, Constants.NTMOBILE_APPLICATION_ID, true);
                NSUserDefaults.StandardUserDefaults.RemoveObject(UserNameKey);
            }
        }
Пример #2
0
        public static Client GetClient()
        {
            string username = NSUserDefaults.StandardUserDefaults.StringForKey(UserNameKey);
            string password = KeychainHelpers.GetPasswordForUsername(username ?? String.Empty, Constants.NTMOBILE_APPLICATION_ID, true);

            if (String.IsNullOrWhiteSpace(username) || String.IsNullOrWhiteSpace(password))
            {
                return(null);
            }
            return(new Client(username, password));
        }
Пример #3
0
        public static bool Authenticate(string username, string password)
        {
            try {
                Client client = new Client(username, password);
                if (client == null)
                {
                    return(false);
                }
                string deviceId = UIDevice.CurrentDevice.IdentifierForVendor.AsString();
                var    data     = client.AuthenticateService.Authenticate(deviceId, "ios");
                SaveAppLoadData(data);

                NSUserDefaults.StandardUserDefaults.SetString(username, UserNameKey);
                KeychainHelpers.SetPasswordForUsername(username, password, Constants.NTMOBILE_APPLICATION_ID, SecAccessible.Always, true);
            }
            catch (CntResponseException ex) {
                Utility.ShowError(ex);
                return(false);
            }
            return(true);
        }