public static string RetrievePinCodeHash() { var policy = AuthStorageHelper.GetMobilePolicy(); if (policy?.PincodeHash != null) { return(policy.PincodeHash); } return(string.Empty); }
/// <summary> /// This method will launch the pincode screen if the policy requires it. /// If determined that no pincode screen is required, the flag requiring the pincode will be cleared. /// </summary> public static async void LaunchPincodeScreen() { var frame = Window.Current.Content as Frame; if (frame != null && typeof(PincodeDialog) != frame.SourcePageType) { await frame.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SDKServiceLocator.Get <ILoggingService>().Log(" Launching Pincode Screen", LoggingLevel.Information); Account account = AccountManager.GetAccount(); if (account != null) { PincodeOptions options = null; bool required = AuthStorageHelper.IsPincodeRequired(); if (account.Policy != null && !IsPincodeSet()) { options = new PincodeOptions(PincodeOptions.PincodeScreen.Create, account, ""); } else if (required) { MobilePolicy policy = AuthStorageHelper.GetMobilePolicy(); if (account.Policy != null) { if (policy.ScreenLockTimeout < account.Policy.ScreenLockTimeout) { policy.ScreenLockTimeout = account.Policy.ScreenLockTimeout; AuthStorageHelper.GetAuthStorageHelper().PersistPincode(policy); } if (policy.PinLength < account.Policy.PinLength) { options = new PincodeOptions(PincodeOptions.PincodeScreen.Create, account, ""); } else { options = new PincodeOptions(PincodeOptions.PincodeScreen.Locked, account, ""); } } else { options = new PincodeOptions(PincodeOptions.PincodeScreen.Locked, account, ""); } } if (options != null) { // As per MSDN documentation (https://msdn.microsoft.com/en-us/library/windows/apps/hh702394.aspx) // the second param of Frame.Navigate must be a basic type otherwise Suspension manager will crash // when serializing frame's state. So we serialize custom object using Json and pass that as the // second param to avoid this crash. frame.Navigate(typeof(PincodeDialog), PincodeOptions.ToJson(options)); } } }); } }
public static void StartIdleTimer() { if (IsPincodeSet()) { var policy = AuthStorageHelper.GetMobilePolicy(); if (policy != null) { IdleTimer.Interval = TimeSpan.FromMinutes(policy.ScreenLockTimeout); if (IdleTimer.IsEnabled) { IdleTimer.Stop(); } SavePinTimer(); IdleTimer.Start(); } } }
public static void TriggerBackgroundedPinTimer() { Account account = AccountManager.GetAccount(); MobilePolicy policy = AuthStorageHelper.GetMobilePolicy(); bool required = AuthStorageHelper.IsPincodeRequired(); if (account != null) { if (required || (policy == null && account.Policy != null)) { LaunchPincodeScreen(); } } else if (!required) { AuthStorageHelper.ClearPinTimer(); } }