예제 #1
0
        /// <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();
        }
예제 #2
0
        /// <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;
        }