Exemplo n.º 1
0
 private void ApplicationOnCreateCustomLogonParameterStore(object sender, CreateCustomLogonParameterStoreEventArgs e)
 {
     if (SecuritySystem.LogonParameters is XpandLogonParameters && ((IModelOptionsAuthentication)Application.Model.Options).Athentication.AutoAthentication.Enabled)
     {
         var encryptedSettingsStorage = new EncryptedSettingsStorage();
         e.Storage = encryptedSettingsStorage;
         _logonParametersFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), CaptionHelper.ApplicationModel.Title);
         if (!Directory.Exists(_logonParametersFilePath))
         {
             Directory.CreateDirectory(_logonParametersFilePath);
         }
         var path = Path.Combine(_logonParametersFilePath, LogonParametersFile);
         if (File.Exists(path))
         {
             var readAllBytes = File.ReadAllBytes(path);
             try{
                 encryptedSettingsStorage.SetContents(readAllBytes);
             }
             catch (CryptographicException cryptographicException) {
                 Tracing.Tracer.LogError(cryptographicException);
                 File.Delete(path);
             }
         }
         e.Handled = true;
     }
 }
Exemplo n.º 2
0
 private void ApplicationOnCreateCustomLogonParameterStore(object sender, CreateCustomLogonParameterStoreEventArgs e)
 {
     if (SecuritySystem.LogonParameters is XpandLogonParameters)
     {
         var encryptedSettingsStorage = new EncryptedSettingsStorage();
         e.Storage = encryptedSettingsStorage;
         _logonParametersFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), CaptionHelper.ApplicationModel.Title);
         if (!Directory.Exists(_logonParametersFilePath))
         {
             Directory.CreateDirectory(_logonParametersFilePath);
         }
         var path = Path.Combine(_logonParametersFilePath, "LogonParameters.bin");
         if (File.Exists(path))
         {
             var readAllBytes = File.ReadAllBytes(path);
             encryptedSettingsStorage.SetContents(readAllBytes);
         }
         e.Handled = true;
     }
 }