internal PSKeyVaultKeyIdentityItem(Track2Sdk.KeyProperties keyProperties, VaultUriHelper vaultUriHelper, bool isHsm = false) { if (keyProperties == null) { throw new ArgumentNullException("keyProperties"); } if (keyProperties.Id == null || keyProperties.Name == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyProperties); } if (null != vaultUriHelper) { SetObjectIdentifier(vaultUriHelper, new Microsoft.Azure.KeyVault.KeyIdentifier(keyProperties.Id.ToString())); } Enabled = keyProperties.Enabled; Expires = keyProperties.ExpiresOn?.UtcDateTime; NotBefore = keyProperties.NotBefore?.UtcDateTime; Created = keyProperties.CreatedOn?.UtcDateTime; Updated = keyProperties.UpdatedOn?.UtcDateTime; RecoveryLevel = keyProperties.RecoveryLevel; Tags = keyProperties.Tags.ConvertToHashtable(); IsHsm = isHsm; }
private PSKeyVaultKey UpdateKey(KeyClient client, string keyName, string keyVersion, PSKeyVaultKeyAttributes keyAttributes) { KeyVaultKey keyBundle = null; // Update updatable properties KeyProperties keyProperties = new KeyProperties(_uriHelper.CreateaMagedHsmKeyUri(client.VaultUri, keyName, keyVersion)) { Enabled = keyAttributes.Enabled, ExpiresOn = keyAttributes.Expires, NotBefore = keyAttributes.NotBefore, ReleasePolicy = keyAttributes.ReleasePolicy?.ToKeyReleasePolicy() }; if (keyAttributes.Tags != null) { keyProperties.Tags.Clear(); foreach (KeyValuePair <string, string> entry in keyAttributes.TagsDirectionary) { keyProperties.Tags.Add(entry.Key, entry.Value); } } try { keyBundle = client.UpdateKeyProperties(keyProperties, keyAttributes.KeyOps?.Select(op => new KeyOperation(op))); } catch (Exception ex) { throw GetInnerException(ex); } return(new PSKeyVaultKey(keyBundle, this._uriHelper, isHsm: true)); }
private PSKeyVaultKey UpdateKey(KeyClient client, string keyName, string keyVersion, PSKeyVaultKeyAttributes keyAttributes) { KeyVaultKey keyBundle = client.GetKeyAsync(keyName, keyVersion).GetAwaiter().GetResult(); KeyProperties keyProperties = keyBundle.Properties; keyProperties.Enabled = keyAttributes.Enabled; keyProperties.ExpiresOn = keyAttributes.Expires; keyProperties.NotBefore = keyAttributes.NotBefore; if (keyAttributes.Tags != null) { keyProperties.Tags.Clear(); foreach (KeyValuePair <string, string> entry in keyAttributes.TagsDirectionary) { keyProperties.Tags.Add(entry.Key, entry.Value); } } try { keyBundle = client.UpdateKeyPropertiesAsync(keyProperties, keyAttributes.KeyOps?.Cast <KeyOperation>().ToList()) .GetAwaiter().GetResult(); } catch (Exception ex) { throw GetInnerException(ex); } return(new PSKeyVaultKey(keyBundle, this._uriHelper, isHsm: true)); }
public Track2Sdk.KeyProperties ToKeyProperties(string keyName, Track2Sdk.KeyProperties keyProperties = null) { if (null == keyProperties) { keyProperties = new Track2Sdk.KeyProperties(keyName); } keyProperties.ExpiresOn = this.Expires; keyProperties.NotBefore = this.NotBefore; keyProperties.Exportable = this.Exportable; keyProperties.Enabled = this.Enabled; if (this.Tags != null) { keyProperties.Tags.Clear(); foreach (KeyValuePair <string, string> entry in this.TagsDirectionary) { keyProperties.Tags.Add(entry.Key, entry.Value); } } keyProperties.ReleasePolicy = this.ReleasePolicy?.ToKeyReleasePolicy(); return(keyProperties); }
internal DeletedKey(KeyProperties properties = null) : base(properties) { }
/// <summary> /// Initializes a new instance of the <see cref="KeyVaultKey"/> class. /// </summary> /// <param name="name">The name of the key.</param> /// <exception cref="ArgumentException"><paramref name="name"/> is an empty string.</exception> /// <exception cref="ArgumentNullException"><paramref name="name"/> is null.</exception> public KeyVaultKey(string name) { Properties = new KeyProperties(name); }
internal KeyVaultKey(KeyProperties properties = null) { Properties = properties ?? new KeyProperties(); }
internal Key() { Properties = new KeyProperties(); }
/// <summary> /// Initializes a new instance of the <see cref="Keys.KeyVaultKey"/> for mocking purposes. /// </summary> /// <param name="properties">Sets the <see cref="Keys.KeyVaultKey.Properties"/> property, which provides the <see cref="Keys.KeyVaultKey.Id"/> and <see cref="Keys.KeyVaultKey.Name"/> properties.</param> /// <param name="key">Sets the <see cref="Keys.KeyVaultKey.Key"/> property, which provides the <see cref="Keys.KeyVaultKey.KeyType"/> and <see cref="Keys.KeyVaultKey.KeyOperations"/> properties.</param> /// <returns>A new instance of the <see cref="Keys.KeyVaultKey"/> for mocking purposes.</returns> public static KeyVaultKey KeyVaultKey(KeyProperties properties, JsonWebKey key) => new KeyVaultKey(properties) { Key = key, };