Пример #1
0
        public async Task <bool> AddItemAsync(Epitech.Intra.SharedApp.Security.Credit credit)
        {
            return(await Task.Run(() => {
//				try {
                ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Forms.Context);
                ISharedPreferencesEditor editor = prefs.Edit();
                editor.PutString("Login", credit.Login);
                editor.PutString("Password", credit.Password);
                return editor.Commit();
//				} catch (System.Exception ex) {
//					return false;
//				}
            }));
        }
Пример #2
0
        public async Task <Epitech.Intra.SharedApp.Security.Credit> GetItemAsync()
        {
            return(await Task.Run(() => {
                Epitech.Intra.SharedApp.Security.Credit credit = new Epitech.Intra.SharedApp.Security.Credit();

                //				try {
                ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Forms.Context);
                credit.Login = prefs.GetString("Login", string.Empty);
                credit.Password = prefs.GetString("Password", string.Empty);
                if (credit.Login == string.Empty || credit.Password == string.Empty)
                {
                    return null;
                }
                //				} catch (System.Exception ex) {
                //					return null;
                //				}
                return credit;
            }));
        }
Пример #3
0
        static bool UpdateItem(Epitech.Intra.SharedApp.Security.Credit credit)
        {
            var securityRecord = new SecRecord(SecKind.GenericPassword)
            {
                Service            = "com.Epitech.uIntra",
                UseOperationPrompt = "Authentifiez-vous pour mettre à jours vos identifiants"
            };

            var recordUpdates = new SecRecord(SecKind.Identity)
            {
                ValueData = new NSString(credit.Login + "|" + credit.Password).Encode(NSStringEncoding.UTF8),
            };

            SecStatusCode status = SecStatusCode.ItemNotFound;

            UIApplication.SharedApplication.InvokeOnMainThread(() => {
                status = SecKeyChain.Update(securityRecord, recordUpdates);
            });

            return(status == SecStatusCode.Success);
        }
Пример #4
0
        static bool AddItem(Epitech.Intra.SharedApp.Security.Credit credit)
        {
            var secObject = new SecAccessControl(SecAccessible.AfterFirstUnlockThisDeviceOnly);

            if (secObject == null)
            {
                return(false);
            }

            var securityRecord = new SecRecord(SecKind.GenericPassword)
            {
                Service               = "com.Epitech.uIntra",
                ValueData             = new NSString(credit.Login + "|" + credit.Password).Encode(NSStringEncoding.UTF8),
                UseNoAuthenticationUI = true,
                AccessControl         = secObject,
            };

            SecStatusCode status = SecKeyChain.Add(securityRecord);

            return(status == SecStatusCode.Success);
        }
Пример #5
0
 public async Task <bool> UpdateItemAsync(Epitech.Intra.SharedApp.Security.Credit credit)
 {
     //return await Task.FromResult<bool> (UpdateItem (credit));
     return(await Task.Run(() => true));
 }
Пример #6
0
 public async Task <bool> AddItemAsync(Epitech.Intra.SharedApp.Security.Credit credit)
 {
     return(await Task.FromResult <bool> (AddItem (credit)));
 }