Exemple #1
0
 /// <summary>
 /// Updates or clears the secret of a declared key in the <see cref="KeyStore"/>.
 /// </summary>
 /// <param name="m">The monitor to use.</param>
 /// <param name="key">The secret name to update.</param>
 /// <param name="secret">The secret to update. Null or empty clears the secret.</param>
 /// <param name="autoSave">False to not automatically saves the vault.</param>
 public void UpdateSecret(IActivityMonitor m, string key, string secret, bool autoSave = true)
 {
     if (_store.SetSecret(m, key, secret) &&
         autoSave &&
         IsKeyVaultOpened)
     {
         if (string.IsNullOrEmpty(secret))
         {
             _vaultContent.Remove(key);
         }
         DoSaveKeyVault(m);
     }
 }
Exemple #2
0
 public XWorldSecrets(Initializer initializer, SecretKeyStore keyStore) : base(initializer)
 {
     initializer.Reader.HandleAddRemoveClearChildren(
         new HashSet <object>(),
         b =>
     {
         string name        = b.HandleRequiredAttribute <string>("Name");
         string password    = b.HandleRequiredAttribute <string>("Value");
         string description = b.HandleRequiredAttribute <string>("Description");
         keyStore.DeclareSecretKey(name, desc => description, true, "World");
         keyStore.SetSecret(initializer.Monitor, name, password);
         return(name);
     }
         );
     initializer.Reader.WarnUnhandled();
 }
Exemple #3
0
 /// <summary>
 /// Updates or clears the secret of a declared key in the <see cref="KeyStore"/>.
 /// Returns true if secret has been changed, false otherwise.
 /// </summary>
 /// <param name="m">The monitor to use.</param>
 /// <param name="key">The secret name to update.</param>
 /// <param name="secret">The secret to update. Null or empty clears the secret.</param>
 /// <param name="autoSave">False to not automatically saves the vault.</param>
 /// <returns>True if secret has been changed, false otherwise.</returns>
 public bool UpdateSecret(IActivityMonitor m, string key, string secret, bool autoSave = true)
 {
     if (!_store.SetSecret(m, key, secret))
     {
         return(false);
     }
     if (autoSave && IsKeyVaultOpened)
     {
         if (string.IsNullOrEmpty(secret))
         {
             _vaultContent.Remove(key);
         }
         DoSaveKeyVault(m);
     }
     return(true);
 }