public override SecretInformation[] GetSecretInfo( string filter, string vaultName, IReadOnlyDictionary <string, object> parameters, out Exception error) { string azkVaultName = (string)parameters["AZKVaultName"]; string subscriptionId = (string)parameters["SubscriptionId"]; // Ensure user is logged in to required Azure subscription. if (!CheckAzureSubscriptionLogIn( subscriptionId: subscriptionId, error: out error)) { return(new SecretInformation[0]); } var results = PowerShellInvoker.InvokeScript( script: EnumerateSecretsScript, args: new object[] { filter, azkVaultName }, error: out error); var list = new List <SecretInformation>(results.Count); foreach (dynamic result in results) { list.Add( new SecretInformation( name: result.Name, type: SecretType.SecureString, vaultName: vaultName)); } return(list.ToArray()); }
public override bool SetSecret( string name, object secret, string vaultName, IReadOnlyDictionary <string, object> parameters, out Exception error) { if (!(secret is SecureString)) { error = new ArgumentException("The secret must be of type SecureString."); return(false); } string azkVaultName = (string)parameters["AZKVaultName"]; string subscriptionId = (string)parameters["SubscriptionId"]; // Ensure user is logged in to required Azure subscription. if (!CheckAzureSubscriptionLogIn( subscriptionId: subscriptionId, error: out error)) { return(false); } // Add the secret PowerShellInvoker.InvokeScript( script: SetSecretScript, args: new object[] { name, secret, azkVaultName }, error: out error); return(error == null); }
public override bool RemoveSecret( string name, string vaultName, IReadOnlyDictionary <string, object> parameters, out Exception error) { string azkVaultName = (string)parameters["AZKVaultName"]; string subscriptionId = (string)parameters["SubscriptionId"]; // Ensure user is logged in to required Azure subscription. if (!CheckAzureSubscriptionLogIn( subscriptionId: subscriptionId, error: out error)) { return(false); } // Remove the secret PowerShellInvoker.InvokeScript( script: RemoveSecretScript, args: new object[] { name, azkVaultName }, error: out error); return(error == null); }
public override object GetSecret( string name, string vaultName, IReadOnlyDictionary <string, object> parameters, out Exception error) { string azkVaultName = (string)parameters["AZKVaultName"]; string subscriptionId = (string)parameters["SubscriptionId"]; // Ensure user is logged in to required Azure subscription. if (!CheckAzureSubscriptionLogIn( subscriptionId: subscriptionId, error: out error)) { return(false); } var results = PowerShellInvoker.InvokeScript( script: GetSecretScript, args: new object[] { name, azkVaultName }, error: out error); return(results.Count > 0 ? results[0].BaseObject : null); }