private async void LoadHsmState() { var id = SystemIdentification.GetSystemIdForPublisher(); DeviceId.Text = id.Source == SystemIdentificationSource.Tpm ? "TPM" : "Other"; var userService = DrxServiceProvider.GetServiceProvider().GetService <UserService>(); if (await userService.IsMachineGenuineDit()) { HsmState.Text = "Enabled"; HsmDisableReason.Text = "N/A"; } else { HsmState.Text = "Disabled"; HsmDisableReason.Text = "Non-genuine machine"; } }
private async void DocumentPropertiesDialog_OnPrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { var deferral = args.GetDeferral(); var securityLevel = (DrxSecurityLevel)((IValueConverter)Resources["IntToEnumConverter"]).ConvertBack(SecurityLevelComboBox.SelectedIndex, typeof(DrxSecurityLevel), null, string.Empty); var userService = DrxServiceProvider.GetServiceProvider().GetService <UserService>(); var notAuthorised = !await userService.IsMachineGenuineDit() && securityLevel >= DrxSecurityLevel.StormVault; var notEncrypted = securityLevel >= DrxSecurityLevel.Secret && !Document.Encrypted; // Don't allow enabling HSM unless we're genuine DIT if (notAuthorised || notEncrypted) { if (notAuthorised) { ErrorBlock.Text = "Not authorised to use this security level."; } else if (notEncrypted) { ErrorBlock.Text = "Document must be encrypted to elevate to this level."; } args.Cancel = true; ErrorBlock.Visibility = Visibility.Visible; deferral.Complete(); return; } Document.Title = TitleTextBox.Text; Document.TimeStamp = DatePicker.Date.GetValueOrDefault(DateTimeOffset.UtcNow); Document.SecurityLevel = securityLevel; if (Document.IsHighSecurity()) { Document.Encrypted = true; } deferral.Complete(); }
private async Task SetupApplication() { // load await SetLoadingStatus(10, "Instantiating services."); var services = DrxServiceProvider.GetServiceProvider(); _logger = services.GetService <ILoggerFactory>().CreateLogger("Splash Screen"); await SetLoadingStatus(20, "Instantiating app providers."); try { const string secret = "8e68d797-a057-472e-838c-d65348f801d4"; AppCenter.Start(secret, typeof(Analytics)); AppCenter.Start(secret, typeof(Distribute)); AppCenter.Start(secret, typeof(Crashes)); } catch (Exception e) { _logger.LogCritical(e, "Exception when initialising App Center."); } await SetLoadingStatus(30, "Loading document stores."); // Init the file store var storeService = services.GetService <StoreService>(); await storeService.Initialise(); // Get the names - this is used for voice commands // TODO: this should be set more dynamically elsewhere var defaultStore = storeService.GetDefaultStore(); if (defaultStore != null) { var names = defaultStore.GetDocuments().Select(s => s.ToString()); // Load voice commands await SetLoadingStatus(40, "Loading voice commands."); await InstallVoiceCommands(names); } // Everything done await SetLoadingStatus(100, "Load complete."); if (_loadState) { await RestoreApplicationState(); } // dismiss await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { var page = new MainPage(); _rootFrame = new Frame { Content = page }; Window.Current.Content = _rootFrame; page.HandleCommand(_command); }); }