internal static PolicyResult DeserializePolicyResult(JsonElement element) { Optional <PolicyModification> xMsPolicyResult = default; Optional <string> xMsPolicyTokenHash = default; Optional <JsonWebKey> xMsPolicySigner = default; Optional <string> xMsPolicy = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("x-ms-policy-result")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } xMsPolicyResult = new PolicyModification(property.Value.GetString()); continue; } if (property.NameEquals("x-ms-policy-token-hash")) { xMsPolicyTokenHash = property.Value.GetString(); continue; } if (property.NameEquals("x-ms-policy-signer")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } xMsPolicySigner = JsonWebKey.DeserializeJsonWebKey(property.Value); continue; } if (property.NameEquals("x-ms-policy")) { xMsPolicy = property.Value.GetString(); continue; } } return(new PolicyResult(xMsPolicyResult, xMsPolicyTokenHash.Value, xMsPolicySigner.Value, xMsPolicy.Value)); }
/// <summary> /// Create a PolicyModificationResult type for mocking purposes. /// </summary> /// <param name="policyModification">The policy Modification which has occurred.</param> /// <param name="policyHash">The SHA256 hash of the policy token which was modified</param> /// <param name="signer">The signer which was used to sign the token which modified the policy.</param> /// <returns></returns> public static PolicyModificationResult PolicyModificationResult(PolicyModification policyModification, string policyHash, AttestationSigner signer) { JsonWebKey jwk = JwkFromAttestationSigner(signer); return(new PolicyModificationResult(policyModification, policyHash, jwk, null)); }