private void WriteSecret( ExtensionVaultModule extensionModule, object secretToWrite) { // If NoClobber is selected, then check to see if it already exists. if (NoClobber) { var result = extensionModule.InvokeGetSecret( name: Name, vaultName: extensionModule.VaultName, cmdlet: this); if (result != null) { var msg = string.Format(CultureInfo.InvariantCulture, "A secret with name {0} already exists in vault {1}.", Name, extensionModule.VaultName); ThrowTerminatingError( new ErrorRecord( new PSInvalidOperationException(msg), "AddSecretAlreadyExists", ErrorCategory.ResourceExists, this)); } } // Add new secret to vault. extensionModule.InvokeSetSecret( name: Name, secret: secretToWrite, vaultName: extensionModule.VaultName, cmdlet: this); }
private InvokeResult TryInvokeAndWrite(ExtensionVaultModule extensionModule) { try { var result = extensionModule.InvokeGetSecret( name: Name, vaultName: extensionModule.VaultName, cmdlet: this); if (result != null) { WriteSecret(result); return(InvokeResult.Success); } } catch (Exception ex) { WriteError( new ErrorRecord( ex, "GetSecretException", ErrorCategory.InvalidOperation, this)); return(InvokeResult.FailedWithTerminatingError); } return(InvokeResult.Failed); }
private void WriteSecret( ExtensionVaultModule extensionModule, object secretToWrite) { // If NoClobber is selected, then check to see if it already exists. if (NoClobber && SecretExistsInVault( extensionModule: extensionModule, name: Name)) { var msg = string.Format(CultureInfo.InvariantCulture, SecretExistsError, Name, extensionModule.VaultName); ThrowTerminatingError( new ErrorRecord( new PSInvalidOperationException(msg), "SetSecretAlreadyExistsWithNoClobber", ErrorCategory.ResourceExists, this)); } // Add new secret to vault. extensionModule.InvokeSetSecret( name: Name, secret: secretToWrite, vaultName: extensionModule.VaultName, cmdlet: this); }
internal SecretVaultInfo( string name, ExtensionVaultModule vaultInfo) { VaultName = name; ModuleName = vaultInfo.ModuleName; ModulePath = vaultInfo.ModulePath; VaultParameters = vaultInfo.VaultParameters; IsDefault = vaultInfo.IsDefault; }
/// <summary> /// Initializes a new instance of ExtensionVaultModule from an existing instance. /// </summary> public ExtensionVaultModule( ExtensionVaultModule module) { VaultName = module.VaultName; ModuleName = module.ModuleName; ModuleExtensionName = module.ModuleExtensionName; ModulePath = module.ModulePath; VaultParameters = module.VaultParameters; IsDefault = module.IsDefault; }
internal SecretVaultInfo( string name, ExtensionVaultModule vaultInfo) { Name = name; ModuleName = vaultInfo.ModuleName; ModulePath = vaultInfo.ModulePath; VaultParametersName = vaultInfo.VaultParametersName; ImplementingTypeAssemblyName = vaultInfo.ImplementingTypeAssemblyName; ImplementingTypeName = vaultInfo.ImplementingTypeName; }
private bool SecretExistsInVault( ExtensionVaultModule extensionModule, string name) { var result = extensionModule.InvokeGetSecret( name: name, vaultName: extensionModule.VaultName, cmdlet: this); return(result != null); }
/// <summary> /// Initializes a new instance of ExtensionVaultModule from an existing instance. /// </summary> public ExtensionVaultModule( ExtensionVaultModule module) { VaultName = module.VaultName; ModuleName = module.ModuleName; ModuleExtensionName = module.ModuleExtensionName; ModulePath = module.ModulePath; Description = module.Description; VaultParameters = module.VaultParameters; IsDefault = module.IsDefault; SetSecretSupportsMetadata = module.SetSecretSupportsMetadata; }
private void WriteExtensionResults(ExtensionVaultModule extensionModule) { try { WriteResults( extensionModule.InvokeGetSecretInfo( filter: Name, vaultName: extensionModule.VaultName, cmdlet: this)); } catch (Exception ex) { WriteError( new ErrorRecord( ex, "GetSecretInfoException", ErrorCategory.InvalidOperation, this)); } }