/// <summary> /// This will wipe out the pincode and associated data. /// </summary> public static void WipePincode() { AuthStorageHelper auth = AuthStorageHelper.GetAuthStorageHelper(); auth.DeletePincode(); auth.DeleteData(PinBackgroundedTimeKey); auth.DeleteData(PincodeRequired); PlatformAdapter.SendToCustomLogger("PincodeManager.WipePincode - Pincode wiped", LoggingLevel.Verbose); }
/// <summary> /// This will return true if a pincode is required before the app can be accessed. /// </summary> /// <returns></returns> public static bool IsPincodeRequired() { AuthStorageHelper auth = GetAuthStorageHelper(); // a flag is set if the timer was exceeded at some point. Automatically return true if the flag is set. bool required = auth.RetrieveData(PincodeRequired) != null; if (required) { PlatformAdapter.SendToCustomLogger("AuthStorageHelper.IsPincodeRequired - Pincode is required", LoggingLevel.Verbose); return(true); } if (IsPincodeSet()) { MobilePolicy policy = GetMobilePolicy(); if (policy != null) { string time = auth.RetrieveData(PinBackgroundedTimeKey); if (time != null) { DateTime previous = DateTime.Parse(time); DateTime current = DateTime.Now.ToUniversalTime(); TimeSpan diff = current.Subtract(previous); if (diff.Minutes >= policy.ScreenLockTimeout) { // flag that requires pincode to be entered in the future. Until the flag is deleted a pincode will be required. auth.PersistData(true, PincodeRequired, time); PlatformAdapter.SendToCustomLogger("AuthStorageHelper.IsPincodeRequired - Pincode is required", LoggingLevel.Verbose); return(true); } } } } // We aren't requiring pincode, so remove the flag. auth.DeleteData(PincodeRequired); PlatformAdapter.SendToCustomLogger("AuthStorageHelper.IsPincodeRequired - Pincode is not required", LoggingLevel.Verbose); return(false); }