Exemplo n.º 1
0
        /// <summary>
        /// Internal constructor used by KeyVaultDataServiceClient
        /// </summary>
        /// <param name="clientSecret">secret returned from service</param>
        /// <param name="vaultUriHelper">helper class</param>
        internal Secret(Microsoft.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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Prints out secret values
        /// </summary>
        /// <param name="secret"> secret </param>
        private static void PrintoutSecret(Secret secret)
        {
            Console.Out.WriteLine("\n\tSecret ID: {0}\n\tSecret Value: {1}",
                secret.Id, secret.Value);

            var expiryDateStr = secret.Attributes.Expires.HasValue
                ? secret.Attributes.Expires.ToString()
                : "Never";

            var notBeforeStr = secret.Attributes.NotBefore.HasValue
                ? secret.Attributes.NotBefore.ToString()
                : UnixEpoch.EpochDate.ToString();

            Console.Out.WriteLine("Secret attributes: \n\tIs the key enabled: {0}\n\tExpiry date: {1}\n\tEnable date: {2}\n\tContent type: {3}",
                secret.Attributes.Enabled, expiryDateStr, notBeforeStr, secret.ContentType);

            PrintoutTags(secret.Tags);
        }