public override void ExecuteCmdlet() { KeyBundle keyBundle; switch (ParameterSetName) { case CreateParameterSet: keyBundle = this.DataServiceClient.CreateKey( VaultName, Name, CreateKeyAttributes()); break; case ImportParameterSet: bool?importToHsm = null; keyBundle = this.DataServiceClient.ImportKey( VaultName, Name, CreateKeyAttributes(), CreateWebKeyFromFile(), string.IsNullOrEmpty(Destination) ? importToHsm : HsmDestination.Equals(Destination, StringComparison.OrdinalIgnoreCase)); break; default: throw new ArgumentException(Resources.BadParameterSetName); } this.WriteObject(keyBundle); }
internal KeyAttributes CreateKeyAttributes() { string keyType = string.Empty; if (!string.IsNullOrEmpty(Destination)) { keyType = (HsmDestination.Equals(Destination, StringComparison.OrdinalIgnoreCase)) ? JsonWebKeyType.RsaHsm : JsonWebKeyType.Rsa; } return(new KeyAttributes( !Disable.IsPresent, Expires, NotBefore, keyType, KeyOps)); }