protected internal ContentSecurityPolicyOptionsDirectiveBuilder AllowHash(HashDirective hash, string base64HashValue) { if (string.IsNullOrWhiteSpace(base64HashValue)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(base64HashValue)); } if (!IsBase64String(base64HashValue)) { throw new FormatException($"The parameter {base64HashValue} is not a Bas64 string!"); } switch (hash) { case HashDirective.SHA256: return(Allow($"'SHA256-{base64HashValue}'")); case HashDirective.SHA384: return(Allow($"'SHA384-{base64HashValue}'")); case HashDirective.SHA512: return(Allow($"'SHA512-{base64HashValue}'")); default: throw new NotSupportedException($"The Hash [{hash.ToString()}] is not supported now!"); } }
public new FontSrcDirectiveBuilder AllowHash(HashDirective hash, string base64HashValue) => (FontSrcDirectiveBuilder)base.AllowHash(hash, base64HashValue);