in Vault/Explorer/ContentType.cs [128:166]
public static string FromRawValue(this ContentType contentType, string rawValue)
{
if (rawValue == null) return null;
switch (contentType)
{
case ContentType.None:
case ContentType.Text:
case ContentType.Csv:
case ContentType.Tsv:
case ContentType.Xml:
case ContentType.Json:
case ContentType.Certificate:
case ContentType.Pkcs12:
case ContentType.KeyVaultSecret:
case ContentType.KeyVaultCertificate:
case ContentType.KeyVaultLink:
return rawValue;
case ContentType.Pkcs12Base64:
case ContentType.Base64:
return Encoding.UTF8.GetString(Convert.FromBase64String(rawValue));
case ContentType.JsonGZipBase64:
// Decode (base64) and decompress the secret raw value
var decoded = Convert.FromBase64String(rawValue);
using (var input = new MemoryStream(decoded))
{
using (var output = new MemoryStream())
{
using (var gz = new GZipStream(input, CompressionMode.Decompress, true))
{
gz.CopyTo(output);
}
return Encoding.UTF8.GetString(output.ToArray());
}
}
default:
throw new ArgumentException($"Invalid ContentType {contentType}");
}
}