Exemplo n.º 1
0
        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 PSKeyVaultKeyAttributes(Track2Sdk.KeyVaultKey key)
 {
     Enabled = key.Properties.Enabled;
     // see https://docs.microsoft.com/en-us/dotnet/standard/datetime/converting-between-datetime-and-offset#conversions-from-datetimeoffset-to-datetime
     // time returned by key vault are UTC
     Expires         = key.Properties.ExpiresOn?.UtcDateTime;
     NotBefore       = key.Properties.NotBefore?.UtcDateTime;
     KeyType         = key.KeyType.ToString();
     KeyOps          = key.KeyOperations.Select(op => op.ToString()).ToArray();
     Created         = key.Properties.CreatedOn?.UtcDateTime;
     Updated         = key.Properties.UpdatedOn?.UtcDateTime;
     RecoveryLevel   = key.Properties.RecoveryLevel;
     Tags            = key.Properties.Tags?.ConvertToHashtable();
     Exportable      = key.Properties.Exportable;
     ReleasePolicy   = key.Properties.ReleasePolicy?.ToPSKeyReleasePolicy();
     RecoverableDays = key.Properties.RecoverableDays;
     Managed         = key.Properties.Managed;
 }
Exemplo n.º 3
0
        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);
        }