internal PSKeyVaultKey(Track2Sdk.KeyVaultKey key, VaultUriHelper vaultUriHelper) { if (key == null) { throw new ArgumentNullException("key"); } if (key.Key == null || key.Properties == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyBundle); } SetObjectIdentifier(vaultUriHelper, new Microsoft.Azure.KeyVault.KeyIdentifier(key.Id.ToString())); Key = key.Key.ToTrack1JsonWebKey(); Attributes = new PSKeyVaultKeyAttributes( key.Properties.Enabled, /// see https://docs.microsoft.com/en-us/dotnet/standard/datetime/converting-between-datetime-and-offset#conversions-from-datetimeoffset-to-datetime key.Properties.ExpiresOn?.UtcDateTime, // time returned by key vault are UTC key.Properties.NotBefore?.UtcDateTime, key.KeyType.ToString(), key.KeyOperations.Select(op => op.ToString()).ToArray(), key.Properties.CreatedOn?.UtcDateTime, key.Properties.UpdatedOn?.UtcDateTime, key.Properties.RecoveryLevel, key.Properties.Tags ); Enabled = key.Properties.Enabled; Expires = key.Properties.ExpiresOn?.UtcDateTime; NotBefore = key.Properties.NotBefore?.UtcDateTime; Created = key.Properties.CreatedOn?.UtcDateTime; Updated = key.Properties.UpdatedOn?.UtcDateTime; RecoveryLevel = key.Properties.RecoveryLevel; Tags = key.Properties.Tags.ConvertToHashtable(); }
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; }
internal PSKeyVaultKey(Microsoft.Azure.KeyVault.Models.KeyBundle keyBundle, VaultUriHelper vaultUriHelper) { if (keyBundle == null) { throw new ArgumentNullException("keyBundle"); } if (keyBundle.Key == null || keyBundle.Attributes == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyBundle); } SetObjectIdentifier(vaultUriHelper, keyBundle.KeyIdentifier); Key = keyBundle.Key; Attributes = new PSKeyVaultKeyAttributes( keyBundle.Attributes.Enabled, keyBundle.Attributes.Expires, keyBundle.Attributes.NotBefore, keyBundle.Key.Kty, keyBundle.Key.KeyOps.ToArray(), keyBundle.Attributes.Created, keyBundle.Attributes.Updated, keyBundle.Attributes.RecoveryLevel, keyBundle.Tags); Enabled = keyBundle.Attributes.Enabled; Expires = keyBundle.Attributes.Expires; NotBefore = keyBundle.Attributes.NotBefore; Created = keyBundle.Attributes.Created; Updated = keyBundle.Attributes.Updated; RecoveryLevel = keyBundle.Attributes.RecoveryLevel; Tags = (keyBundle.Tags == null) ? null : keyBundle.Tags.ConvertToHashtable(); }
internal KeyIdentityItem(Azure.KeyVault.Models.KeyItem keyItem, VaultUriHelper vaultUriHelper) { if (keyItem == null) { throw new ArgumentNullException("keyItem"); } if (keyItem.Attributes == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyAttributes); } if (keyItem.Identifier == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyIdentifier); } SetObjectIdentifier(vaultUriHelper, keyItem.Identifier); Enabled = keyItem.Attributes.Enabled; Expires = keyItem.Attributes.Expires; NotBefore = keyItem.Attributes.NotBefore; Created = keyItem.Attributes.Created; Updated = keyItem.Attributes.Updated; RecoveryLevel = keyItem.Attributes.RecoveryLevel; Tags = (keyItem.Tags == null) ? null : keyItem.Tags.ConvertToHashtable(); // the PurgeDisabled field was deprecated, but is kept in the // PSH SDK until the first breaking-change release. PurgeDisabled = false; }
internal KeyBundle(Azure.KeyVault.Models.KeyBundle keyBundle, VaultUriHelper vaultUriHelper) { if (keyBundle == null) { throw new ArgumentNullException("keyBundle"); } if (keyBundle.Key == null || keyBundle.Attributes == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyBundle); } SetObjectIdentifier(vaultUriHelper, keyBundle.KeyIdentifier); Key = keyBundle.Key; Attributes = new KeyAttributes( keyBundle.Attributes.Enabled, keyBundle.Attributes.Expires, keyBundle.Attributes.NotBefore, keyBundle.Key.Kty, keyBundle.Key.KeyOps.ToArray(), keyBundle.Attributes.Created, keyBundle.Attributes.Updated, keyBundle.Attributes.RecoveryLevel, keyBundle.Tags); }
internal KeyIdentityItem(Azure.KeyVault.Models.KeyItem keyItem, VaultUriHelper vaultUriHelper) { if (keyItem == null) { throw new ArgumentNullException("keyItem"); } if (keyItem.Attributes == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyAttributes); } if (keyItem.Identifier == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyIdentifier); } SetObjectIdentifier(vaultUriHelper, keyItem.Identifier); Enabled = keyItem.Attributes.Enabled; Expires = keyItem.Attributes.Expires; NotBefore = keyItem.Attributes.NotBefore; Created = keyItem.Attributes.Created; Updated = keyItem.Attributes.Updated; PurgeDisabled = keyItem.Attributes.PurgeDisabled; Tags = (keyItem.Tags == null) ? null : keyItem.Tags.ConvertToHashtable(); }
/// <summary> /// Internal constructor used by KeyVaultDataServiceClient /// </summary> /// <param name="secret">secret returned from service</param> /// <param name="vaultUriHelper">helper class</param> internal PSKeyVaultSecret(Azure.KeyVault.Models.SecretBundle secret, VaultUriHelper vaultUriHelper) { if (secret == null) { throw new ArgumentNullException("secret"); } SetObjectIdentifier(vaultUriHelper, secret.SecretIdentifier); if (secret.Value != null) { SecretValue = secret.Value.ConvertToSecureString(); } Attributes = new PSKeyVaultSecretAttributes( secret.Attributes.Enabled, secret.Attributes.Expires, secret.Attributes.NotBefore, secret.Attributes.Created, secret.Attributes.Updated, secret.ContentType, secret.Attributes.RecoveryLevel, secret.Tags); Enabled = secret.Attributes.Enabled; Expires = secret.Attributes.Expires; NotBefore = secret.Attributes.NotBefore; Created = secret.Attributes.Created; Updated = secret.Attributes.Updated; ContentType = secret.ContentType; Tags = (secret.Tags == null) ? null : secret.Tags.ConvertToHashtable(); }
internal CertificateIssuerIdentityItem(CertificateIssuerItem issuerItem, VaultUriHelper vaultUriHelper) { if (issuerItem == null) throw new ArgumentNullException("issuerItem"); Name = new CertificateIssuerIdentifier(issuerItem.Id).Name; IssuerProvider = issuerItem.Provider; }
internal CertificateIssuerIdentityItem(CertificateIssuerItem issuerItem, VaultUriHelper vaultUriHelper) { if (issuerItem == null) { throw new ArgumentNullException("issuerItem"); } Name = new CertificateIssuerIdentifier(issuerItem.Id).Name; IssuerProvider = issuerItem.Provider; }
internal void SetObjectIdentifier(VaultUriHelper vaultUriHelper, Client.ObjectIdentifier identifier) { if (vaultUriHelper == null) { throw new ArgumentNullException("vaultUriHelper"); } VaultName = vaultUriHelper.GetVaultName(identifier.Identifier); Name = identifier.Name; Version = identifier.Version; }
internal void SetObjectIdentifier(VaultUriHelper vaultUriHelper, Client.ObjectIdentifier identifier) { if (vaultUriHelper == null) { throw new ArgumentNullException("vaultUriHelper"); } VaultName = vaultUriHelper.GetVaultName(identifier.Identifier); Name = identifier.Name; Version = identifier.Version; }
/// <summary> /// Internal constructor used by KeyVaultDataServiceClient /// </summary> /// <param name="clientSecret">secret returned from service</param> /// <param name="vaultUriHelper">helper class</param> internal Secret(Client.Secret clientSecret, VaultUriHelper vaultUriHelper) { if (clientSecret == null) { throw new ArgumentNullException("clientSecret"); } SetObjectIdentifier(vaultUriHelper, new Client.SecretIdentifier(clientSecret.Id)); SecretValue = clientSecret.SecureValue; Id = clientSecret.Id; }
/// <summary> /// Internal constructor used by KeyVaultDataServiceClient /// </summary> /// <param name="clientSecret">secret returned from service</param> /// <param name="vaultUriHelper">helper class</param> internal Secret(Client.Secret clientSecret, VaultUriHelper vaultUriHelper) { if (clientSecret == null) { throw new ArgumentNullException("clientSecret"); } SetObjectIdentifier(vaultUriHelper, new Client.SecretIdentifier(clientSecret.Id)); SecretValue = clientSecret.SecureValue; Id = clientSecret.Id; }
internal void SetObjectIdentifier(VaultUriHelper vaultUriHelper, Azure.KeyVault.ObjectIdentifier identifier) { if (vaultUriHelper == null) throw new ArgumentNullException("vaultUriHelper"); if (identifier == null) throw new ArgumentNullException("identifier"); VaultName = vaultUriHelper.GetVaultName(identifier.Identifier); Name = identifier.Name; Version = identifier.Version; Id = identifier.Identifier; }
internal PSKeyVaultCertificate(CertificateBundle certificateBundle, VaultUriHelper vaultUriHelper) { if (certificateBundle == null) { throw new ArgumentNullException(nameof(certificateBundle)); } if (certificateBundle.CertificateIdentifier == null) { throw new ArgumentException(Resources.InvalidKeyIdentifier); } SetObjectIdentifier(vaultUriHelper, certificateBundle.CertificateIdentifier); // VaultName formatted incorrect in certificateBundle var vaultUri = new Uri(certificateBundle.CertificateIdentifier.Vault); VaultName = vaultUri.Host.Split('.').First(); if (certificateBundle.Cer != null) { Certificate = new X509Certificate2(certificateBundle.Cer); Thumbprint = Certificate.Thumbprint; } if (certificateBundle.KeyIdentifier != null) { KeyId = certificateBundle.KeyIdentifier.Identifier; } if (certificateBundle.SecretIdentifier != null) { SecretId = certificateBundle.SecretIdentifier.Identifier; } if (certificateBundle.Attributes != null) { Created = certificateBundle.Attributes.Created; Expires = certificateBundle.Attributes.Expires; NotBefore = certificateBundle.Attributes.NotBefore; Enabled = certificateBundle.Attributes.Enabled; Updated = certificateBundle.Attributes.Updated; RecoveryLevel = certificateBundle.Attributes.RecoveryLevel; } if (certificateBundle.Tags != null) { Tags = (Hashtable)certificateBundle.Tags; } }
internal SecretIdentityItem(Client.SecretItem clientSecretItem, VaultUriHelper vaultUriHelper) { if (clientSecretItem == null) { throw new ArgumentNullException("clientSecretItem"); } if (String.IsNullOrEmpty(clientSecretItem.Id)) { throw new ArgumentException(Resources.InvalidSecretUri); } SetObjectIdentifier(vaultUriHelper, new Client.SecretIdentifier(clientSecretItem.Id)); Id = clientSecretItem.Id; }
internal SecretIdentityItem(Client.SecretItem clientSecretItem, VaultUriHelper vaultUriHelper) { if (clientSecretItem == null) { throw new ArgumentNullException("clientSecretItem"); } if (String.IsNullOrEmpty(clientSecretItem.Id)) { throw new ArgumentException(Resources.InvalidSecretUri); } SetObjectIdentifier(vaultUriHelper, new Client.SecretIdentifier(clientSecretItem.Id)); Id = clientSecretItem.Id; }
internal void SetObjectIdentifier(VaultUriHelper vaultUriHelper, Microsoft.Azure.KeyVault.ObjectIdentifier identifier) { if (vaultUriHelper == null) { throw new ArgumentNullException("vaultUriHelper"); } if (identifier == null) { throw new ArgumentNullException("identifier"); } VaultName = vaultUriHelper.GetVaultName(identifier.Identifier); Name = identifier.Name; Version = identifier.Version; Id = identifier.Identifier; }
/// <summary> /// Internal constructor used by KeyVaultDataServiceClient /// </summary> /// <param name="secret">secret returned from service</param> /// <param name="vaultUriHelper">helper class</param> internal Secret(Azure.KeyVault.Secret secret, VaultUriHelper vaultUriHelper) { if (secret == null) throw new ArgumentNullException("secret"); SetObjectIdentifier(vaultUriHelper, secret.SecretIdentifier); if (secret.Value != null) SecretValue = secret.Value.ConvertToSecureString(); Attributes = new SecretAttributes( secret.Attributes.Enabled, secret.Attributes.Expires, secret.Attributes.NotBefore, secret.Attributes.Created, secret.Attributes.Updated, secret.ContentType, secret.Tags); }
internal CertificateIdentityItem(CertificateItem certItem, VaultUriHelper vaultUriHelper) { if (certItem == null) throw new ArgumentNullException("certItem"); if (certItem.Attributes == null) throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyAttributes); if (certItem.Identifier == null) throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyIdentifier); SetObjectIdentifier(vaultUriHelper, certItem.Identifier); Enabled = certItem.Attributes.Enabled; Expires = certItem.Attributes.Expires; NotBefore = certItem.Attributes.NotBefore; Created = certItem.Attributes.Created; Updated = certItem.Attributes.Updated; Tags = (certItem.Tags == null) ? null : certItem.Tags.ConvertToHashtable(); }
internal SecretIdentityItem(Microsoft.Azure.KeyVault.SecretItem secretItem, VaultUriHelper vaultUriHelper) { if (secretItem == null) throw new ArgumentNullException("secretItem"); if (secretItem.Attributes == null) throw new ArgumentException(KeyVaultProperties.Resources.InvalidSecretAttributes); if (secretItem.Identifier == null) throw new ArgumentException(KeyVaultProperties.Resources.InvalidSecretIdentifier); SetObjectIdentifier(vaultUriHelper, secretItem.Identifier); Enabled = secretItem.Attributes.Enabled; Expires = secretItem.Attributes.Expires; NotBefore = secretItem.Attributes.NotBefore; Created = secretItem.Attributes.Created; Updated = secretItem.Attributes.Updated; ContentType = secretItem.ContentType; Tags = (secretItem.Tags == null) ? null : secretItem.Tags.ConvertToHashtable(); }
internal KeyIdentityItem(Azure.KeyVault.Models.KeyItem keyItem, VaultUriHelper vaultUriHelper) { if (keyItem == null) throw new ArgumentNullException("keyItem"); if (keyItem.Attributes == null) throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyAttributes); if (keyItem.Identifier == null) throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyIdentifier); SetObjectIdentifier(vaultUriHelper, keyItem.Identifier); Enabled = keyItem.Attributes.Enabled; Expires = keyItem.Attributes.Expires; NotBefore = keyItem.Attributes.NotBefore; Created = keyItem.Attributes.Created; Updated = keyItem.Attributes.Updated; Tags = (keyItem.Tags == null) ? null : keyItem.Tags.ConvertToHashtable(); }
internal KeyBundle(Azure.KeyVault.KeyBundle keyBundle, VaultUriHelper vaultUriHelper) { if (keyBundle == null) throw new ArgumentNullException("keyBundle"); if (keyBundle.Key == null || keyBundle.Attributes == null) throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyBundle); SetObjectIdentifier(vaultUriHelper,keyBundle.KeyIdentifier); Key = keyBundle.Key; Attributes = new KeyAttributes( keyBundle.Attributes.Enabled, keyBundle.Attributes.Expires, keyBundle.Attributes.NotBefore, keyBundle.Key.Kty, keyBundle.Key.KeyOps, keyBundle.Attributes.Created, keyBundle.Attributes.Updated, keyBundle.Tags); }
/// <summary> /// Internal constructor used by KeyVaultDataServiceClient /// </summary> /// <param name="secret">secret returned from service</param> /// <param name="vaultUriHelper">helper class</param> internal Secret(Azure.KeyVault.Secret secret, VaultUriHelper vaultUriHelper) { if (secret == null) { throw new ArgumentNullException("secret"); } SetObjectIdentifier(vaultUriHelper, secret.SecretIdentifier); if (secret.Value != null) { SecretValue = secret.Value.ConvertToSecureString(); } Attributes = new SecretAttributes( secret.Attributes.Enabled, secret.Attributes.Expires, secret.Attributes.NotBefore, secret.Attributes.Created, secret.Attributes.Updated, secret.ContentType, secret.Tags); }
internal PSDeletedKeyVaultKey(DeletedKey deletedKey, VaultUriHelper vaultUriHelper, bool isHsm = false) { if (deletedKey == null) { throw new ArgumentNullException("deletedKey"); } if (deletedKey.Key == null || deletedKey.Properties == null) { throw new ArgumentException(Resources.InvalidKeyBundle); } SetObjectIdentifier(vaultUriHelper, new Microsoft.Azure.KeyVault.KeyIdentifier(deletedKey.Id.ToString())); Key = deletedKey.Key.ToTrack1JsonWebKey(); KeySize = JwkHelper.ConvertToRSAKey(Key)?.KeySize; Attributes = new PSKeyVaultKeyAttributes( deletedKey.Properties.Enabled, // see https://docs.microsoft.com/en-us/dotnet/standard/datetime/converting-between-datetime-and-offset#conversions-from-datetimeoffset-to-datetime deletedKey.Properties.ExpiresOn?.UtcDateTime, // time returned by key vault are UTC deletedKey.Properties.NotBefore?.UtcDateTime, deletedKey.KeyType.ToString(), deletedKey.KeyOperations.Select(op => op.ToString()).ToArray(), deletedKey.Properties.CreatedOn?.UtcDateTime, deletedKey.Properties.UpdatedOn?.UtcDateTime, deletedKey.Properties.RecoveryLevel, deletedKey.Properties.Tags ); Enabled = deletedKey.Properties.Enabled; Expires = deletedKey.Properties.ExpiresOn?.UtcDateTime; NotBefore = deletedKey.Properties.NotBefore?.UtcDateTime; Created = deletedKey.Properties.CreatedOn?.UtcDateTime; Updated = deletedKey.Properties.UpdatedOn?.UtcDateTime; RecoveryLevel = deletedKey.Properties.RecoveryLevel; Tags = deletedKey.Properties.Tags.ConvertToHashtable(); ScheduledPurgeDate = deletedKey.ScheduledPurgeDate?.UtcDateTime; DeletedDate = deletedKey.DeletedOn?.UtcDateTime; IsHsm = isHsm; }
internal KeyBundle(Client.KeyBundle clientKeyBundle, VaultUriHelper vaultUriHelper) { if (clientKeyBundle == null) { throw new ArgumentNullException("clientKeyBundle"); } if (clientKeyBundle.Key == null || clientKeyBundle.Attributes == null) { throw new ArgumentException(Resources.InvalidKeyBundle); } SetObjectIdentifier(vaultUriHelper, new Client.KeyIdentifier(clientKeyBundle.Key.Kid)); Key = clientKeyBundle.Key; Attributes = new KeyAttributes( clientKeyBundle.Attributes.Enabled, clientKeyBundle.Attributes.Expires, clientKeyBundle.Attributes.NotBefore, clientKeyBundle.Key.Kty, clientKeyBundle.Key.KeyOps); Id = clientKeyBundle.Key.Kid; }
internal KeyIdentityItem(Client.KeyItem clientKeyItem, VaultUriHelper vaultUriHelper) { if (clientKeyItem == null) { throw new ArgumentNullException("clientKeyItem"); } if (String.IsNullOrEmpty(clientKeyItem.Kid) || clientKeyItem.Attributes == null) { throw new ArgumentException(Resources.InvalidKeyBundle); } SetObjectIdentifier(vaultUriHelper, new Client.KeyIdentifier(clientKeyItem.Kid)); var attribute = new KeyAttributes( clientKeyItem.Attributes.Enabled, clientKeyItem.Attributes.Expires, clientKeyItem.Attributes.NotBefore); Enabled = attribute.Enabled; Expires = attribute.Expires; NotBefore = attribute.NotBefore; Id = clientKeyItem.Kid; }
internal KeyBundle(Client.KeyBundle clientKeyBundle, VaultUriHelper vaultUriHelper) { if (clientKeyBundle == null) { throw new ArgumentNullException("clientKeyBundle"); } if (clientKeyBundle.Key == null || clientKeyBundle.Attributes == null) { throw new ArgumentException(Resources.InvalidKeyBundle); } SetObjectIdentifier(vaultUriHelper, new Client.KeyIdentifier(clientKeyBundle.Key.Kid)); Key = clientKeyBundle.Key; Attributes = new KeyAttributes( clientKeyBundle.Attributes.Enabled, clientKeyBundle.Attributes.Expires, clientKeyBundle.Attributes.NotBefore, clientKeyBundle.Key.Kty, clientKeyBundle.Key.KeyOps); Id = clientKeyBundle.Key.Kid; }
internal PSKeyVaultKey(Track1Sdk.KeyBundle keyBundle, VaultUriHelper vaultUriHelper, bool isHsm = false) : base(keyBundle, isHsm) { if (keyBundle == null) { throw new ArgumentNullException("keyBundle"); } if (keyBundle.Key == null || keyBundle.Attributes == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyBundle); } SetObjectIdentifier(vaultUriHelper, keyBundle.KeyIdentifier); // Key properties Key = keyBundle.Key; // Quick access for key properties KeySize = JwkHelper.ConvertToRSAKey(Key)?.KeySize; // Key additional properties Attributes = new PSKeyVaultKeyAttributes(keyBundle); }
internal KeyIdentityItem(Client.KeyItem clientKeyItem, VaultUriHelper vaultUriHelper) { if (clientKeyItem == null) { throw new ArgumentNullException("clientKeyItem"); } if (String.IsNullOrEmpty(clientKeyItem.Kid) || clientKeyItem.Attributes == null) { throw new ArgumentException(Resources.InvalidKeyBundle); } SetObjectIdentifier(vaultUriHelper, new Client.KeyIdentifier(clientKeyItem.Kid)); var attribute = new KeyAttributes( clientKeyItem.Attributes.Enabled, clientKeyItem.Attributes.Expires, clientKeyItem.Attributes.NotBefore); Enabled = attribute.Enabled; Expires = attribute.Expires; NotBefore = attribute.NotBefore; Id = clientKeyItem.Kid; }
internal PSKeyVaultKey(Track2Sdk.KeyVaultKey key, VaultUriHelper vaultUriHelper, bool isHsm) : base(key?.Properties, null, isHsm) { if (key == null) { throw new ArgumentNullException("key"); } if (key.Key == null || key.Properties == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidKeyBundle); } // Set Id, Name, Version and VaultName SetObjectIdentifier(vaultUriHelper, new Microsoft.Azure.KeyVault.KeyIdentifier(key.Id.ToString())); // Key properties Key = key.Key.ToTrack1JsonWebKey(); // Quick access for key properties KeySize = JwkHelper.ConvertToRSAKey(Key)?.KeySize; // Key additional properties Attributes = new PSKeyVaultKeyAttributes(key); }
internal SecretIdentityItem(Azure.KeyVault.Models.SecretItem secretItem, VaultUriHelper vaultUriHelper) { if (secretItem == null) { throw new ArgumentNullException("secretItem"); } if (secretItem.Attributes == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidSecretAttributes); } if (secretItem.Identifier == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidSecretIdentifier); } SetObjectIdentifier(vaultUriHelper, secretItem.Identifier); Enabled = secretItem.Attributes.Enabled; Expires = secretItem.Attributes.Expires; NotBefore = secretItem.Attributes.NotBefore; Created = secretItem.Attributes.Created; Updated = secretItem.Attributes.Updated; ContentType = secretItem.ContentType; Tags = (secretItem.Tags == null) ? null : secretItem.Tags.ConvertToHashtable(); }
/// <summary> /// Internal constructor used by KeyVaultDataServiceClient /// </summary> /// <param name="managedStorageAccountBundleListItem">managed storage bundle returned from service</param> /// <param name="vaultUriHelper">helper class</param> internal ManagedStorageAccountListItem(Azure.KeyVault.Models.StorageAccountItem managedStorageAccountBundleListItem, VaultUriHelper vaultUriHelper) { if (managedStorageAccountBundleListItem == null) { throw new ArgumentNullException("managedStorageAccountBundleListItem"); } if (vaultUriHelper == null) { throw new ArgumentNullException("vaultUriHelper"); } var identifier = new StorageAccountIdentifier(managedStorageAccountBundleListItem.Id); Id = identifier.Identifier; VaultName = vaultUriHelper.GetVaultName(identifier.Identifier); AccountName = identifier.Name; AccountResourceId = managedStorageAccountBundleListItem.ResourceId; Attributes = managedStorageAccountBundleListItem.Attributes == null ? null : new ManagedStorageAccountAttributes(managedStorageAccountBundleListItem.Attributes.Enabled, managedStorageAccountBundleListItem.Attributes.Created, managedStorageAccountBundleListItem.Attributes.Updated); Tags = managedStorageAccountBundleListItem.Tags == null ? null : managedStorageAccountBundleListItem.Tags.ConvertToHashtable(); }
/// <summary> /// Internal constructor used by KeyVaultDataServiceClient /// </summary> /// <param name="deletedSecret">secret returned from service</param> /// <param name="vaultUriHelper">helper class</param> internal PSDeletedKeyVaultSecret(Azure.KeyVault.Models.DeletedSecretBundle deletedSecret, VaultUriHelper vaultUriHelper) { if (deletedSecret == null) { throw new ArgumentNullException("secret"); } if (deletedSecret.Attributes == null) { throw new ArgumentException(Resources.InvalidSecretAttributes); } if (deletedSecret.SecretIdentifier == null) { throw new ArgumentException(Resources.InvalidSecretIdentifier); } SetObjectIdentifier(vaultUriHelper, deletedSecret.SecretIdentifier); if (deletedSecret.Value != null) { SecretValue = deletedSecret.Value.ConvertToSecureString(); } Enabled = deletedSecret.Attributes.Enabled; Expires = deletedSecret.Attributes.Expires; NotBefore = deletedSecret.Attributes.NotBefore; Created = deletedSecret.Attributes.Created; Updated = deletedSecret.Attributes.Updated; ContentType = deletedSecret.ContentType; Tags = (deletedSecret.Tags == null) ? null : deletedSecret.Tags.ConvertToHashtable(); Attributes = new PSKeyVaultSecretAttributes( deletedSecret.Attributes.Enabled, deletedSecret.Attributes.Expires, deletedSecret.Attributes.NotBefore, deletedSecret.Attributes.Created, deletedSecret.Attributes.Updated, deletedSecret.ContentType, deletedSecret.Attributes.RecoveryLevel, deletedSecret.Tags); ScheduledPurgeDate = deletedSecret.ScheduledPurgeDate; DeletedDate = deletedSecret.DeletedDate; }
internal ManagedStorageSasDefinitionListItem(Azure.KeyVault.Models.SasDefinitionItem storageSasDefinitionItem, VaultUriHelper vaultUriHelper) { if (storageSasDefinitionItem == null) { throw new ArgumentNullException("storageSasDefinitionItem"); } if (vaultUriHelper == null) { throw new ArgumentNullException("vaultUriHelper"); } var identifier = new SasDefinitionIdentifier(storageSasDefinitionItem.Id); Id = identifier.Identifier; VaultName = vaultUriHelper.GetVaultName(identifier.Identifier); Name = identifier.Name; Attributes = storageSasDefinitionItem.Attributes == null ? null : new ManagedStorageSasDefinitionAttributes(storageSasDefinitionItem.Attributes.Enabled, storageSasDefinitionItem.Attributes.Created, storageSasDefinitionItem.Attributes.Updated); Tags = storageSasDefinitionItem.Tags == null ? null : storageSasDefinitionItem.Tags.ConvertToHashtable(); Sid = storageSasDefinitionItem.SecretId; AccountName = identifier.StorageAccount; }
internal PSDeletedKeyVaultCertificateIdentityItem(DeletedCertificateItem certItem, VaultUriHelper vaultUriHelper) : base(certItem, vaultUriHelper) { ScheduledPurgeDate = certItem.ScheduledPurgeDate; DeletedDate = certItem.DeletedDate; }
internal PSDeletedKeyVaultManagedStorageSasDefinition(Microsoft.Azure.KeyVault.Models.DeletedSasDefinitionBundle deletedSasDefinitionBundle, VaultUriHelper vaultUriHelper) { if (deletedSasDefinitionBundle == null) { throw new ArgumentNullException(nameof(deletedSasDefinitionBundle)); } if (deletedSasDefinitionBundle.Attributes == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidManagedStorageObjectAttributes); } if (deletedSasDefinitionBundle.Id == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidStorageSasDefinitionIdentifier); } var identifier = new Microsoft.Azure.KeyVault.SasDefinitionIdentifier(deletedSasDefinitionBundle.Id); SetObjectIdentifier(vaultUriHelper, identifier); Attributes = deletedSasDefinitionBundle.Attributes == null ? null : new PSKeyVaultManagedStorageSasDefinitionAttributes(deletedSasDefinitionBundle.Attributes); Tags = deletedSasDefinitionBundle.Tags == null ? null : deletedSasDefinitionBundle.Tags.ConvertToHashtable(); Sid = deletedSasDefinitionBundle.SecretId; TemplateUri = deletedSasDefinitionBundle.TemplateUri; SasType = deletedSasDefinitionBundle.SasType; ValidityPeriod = deletedSasDefinitionBundle.ValidityPeriod; AccountName = identifier.StorageAccount; ScheduledPurgeDate = deletedSasDefinitionBundle.ScheduledPurgeDate; DeletedDate = deletedSasDefinitionBundle.DeletedDate; }
internal PSDeletedKeyVaultKey(Azure.KeyVault.Models.DeletedKeyBundle deletedKeyBundle, VaultUriHelper vaultUriHelper) { if (deletedKeyBundle == null) { throw new ArgumentNullException("keyItem"); } if (deletedKeyBundle.Attributes == null) { throw new ArgumentException(Resources.InvalidKeyAttributes); } if (deletedKeyBundle.KeyIdentifier == null) { throw new ArgumentException(Resources.InvalidKeyIdentifier); } SetObjectIdentifier(vaultUriHelper, deletedKeyBundle.KeyIdentifier); Key = deletedKeyBundle.Key; Attributes = new PSKeyVaultKeyAttributes( deletedKeyBundle.Attributes.Enabled, deletedKeyBundle.Attributes.Expires, deletedKeyBundle.Attributes.NotBefore, deletedKeyBundle.Key.Kty, deletedKeyBundle.Key.KeyOps.ToArray(), deletedKeyBundle.Attributes.Created, deletedKeyBundle.Attributes.Updated, deletedKeyBundle.Attributes.RecoveryLevel, deletedKeyBundle.Tags); Enabled = deletedKeyBundle.Attributes.Enabled; Expires = deletedKeyBundle.Attributes.Expires; NotBefore = deletedKeyBundle.Attributes.NotBefore; Created = deletedKeyBundle.Attributes.Created; Updated = deletedKeyBundle.Attributes.Updated; RecoveryLevel = deletedKeyBundle.Attributes.RecoveryLevel; Tags = (deletedKeyBundle.Tags == null) ? null : deletedKeyBundle.Tags.ConvertToHashtable(); ScheduledPurgeDate = deletedKeyBundle.ScheduledPurgeDate; DeletedDate = deletedKeyBundle.DeletedDate; }
internal PSDeletedKeyVaultManagedStorageSasDefinitionIdentityItem(Azure.KeyVault.Models.DeletedSasDefinitionItem deletedSasDefinitionItem, VaultUriHelper vaultUriHelper) : base(deletedSasDefinitionItem, vaultUriHelper) { ScheduledPurgeDate = deletedSasDefinitionItem.ScheduledPurgeDate; DeletedDate = deletedSasDefinitionItem.DeletedDate; }
internal PSDeletedKeyVaultManagedStorageAccount(Azure.KeyVault.Models.DeletedStorageBundle deletedStorageAccountBundle, VaultUriHelper vaultUriHelper) { if (deletedStorageAccountBundle == null) { throw new ArgumentNullException(nameof(deletedStorageAccountBundle)); } if (deletedStorageAccountBundle.Attributes == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidManagedStorageObjectAttributes); } if (deletedStorageAccountBundle.Id == null) { throw new ArgumentException(KeyVaultProperties.Resources.InvalidManagedStorageAccountIdentifier); } SetObjectIdentifier(vaultUriHelper, new Azure.KeyVault.StorageAccountIdentifier(deletedStorageAccountBundle.Id)); AccountName = this.Name; AccountResourceId = deletedStorageAccountBundle.ResourceId; ActiveKeyName = deletedStorageAccountBundle.ActiveKeyName; AutoRegenerateKey = deletedStorageAccountBundle.AutoRegenerateKey; RegenerationPeriod = string.IsNullOrWhiteSpace(deletedStorageAccountBundle.RegenerationPeriod) ? (TimeSpan?)null : XmlConvert.ToTimeSpan(deletedStorageAccountBundle.RegenerationPeriod); Attributes = deletedStorageAccountBundle.Attributes == null ? null : new PSKeyVaultManagedStorageAccountAttributes(deletedStorageAccountBundle.Attributes); Tags = deletedStorageAccountBundle.Tags == null ? null : deletedStorageAccountBundle.Tags.ConvertToHashtable(); ScheduledPurgeDate = deletedStorageAccountBundle.ScheduledPurgeDate; DeletedDate = deletedStorageAccountBundle.DeletedDate; }
/// <summary> /// Internal constructor used by KeyVaultDataServiceClient /// </summary> /// <param name="managedStorageAccountBundleListItem">managed storage bundle returned from service</param> /// <param name="vaultUriHelper">helper class</param> internal PSKeyVaultManagedStorageAccountIdentityItem(Azure.KeyVault.Models.StorageAccountItem managedStorageAccountBundleListItem, VaultUriHelper vaultUriHelper) { if (managedStorageAccountBundleListItem == null) { throw new ArgumentNullException(nameof(managedStorageAccountBundleListItem)); } if (vaultUriHelper == null) { throw new ArgumentNullException(nameof(vaultUriHelper)); } SetObjectIdentifier(vaultUriHelper, managedStorageAccountBundleListItem.Identifier); AccountName = this.Name; AccountResourceId = managedStorageAccountBundleListItem.ResourceId; Attributes = managedStorageAccountBundleListItem.Attributes == null ? null : new PSKeyVaultManagedStorageAccountAttributes(managedStorageAccountBundleListItem.Attributes); Tags = managedStorageAccountBundleListItem.Tags == null ? null : managedStorageAccountBundleListItem.Tags.ConvertToHashtable(); }