public Jwk CanonicalizeKey(Jwk key) { key.Kid = JsonEncodedText.Encode("kid"); key.Use = JwkUseValues.Sig; key.X5c.Add(new byte[0]); key.X5t = Base64Url.Decode("XOf1YEg_zFLX0PtGjiEVvjM1WsA"); key.X5tS256 = Base64Url.Decode("ZgPMqAT8BELhXwBa2nIT0OvdWtQCiF_g09nAyHhgCe0"); key.X5u = "https://example.com/jwks"; var json = key.Canonicalize(); var canonicalizedKey = Jwk.FromJson(Encoding.UTF8.GetString(json)); Assert.NotNull(canonicalizedKey); Assert.True(canonicalizedKey.Alg.EncodedUtf8Bytes.IsEmpty); Assert.True(canonicalizedKey.Kid.EncodedUtf8Bytes.IsEmpty); Assert.True(canonicalizedKey.Use.EncodedUtf8Bytes.IsEmpty); Assert.Empty(canonicalizedKey.X5c); Assert.Null(canonicalizedKey.X5t); Assert.Null(canonicalizedKey.X5tS256); Assert.Null(canonicalizedKey.X5u); return(canonicalizedKey); }
public Jwk CanonicalizeKey(Jwk key) { key.Kid = JsonEncodedText.Encode("kid"); key.Use = JwkUseValues.Sig; key.X5c.Add(new byte[0]); key.X5t = Encoding.UTF8.GetBytes("x5t"); key.X5tS256 = Encoding.UTF8.GetBytes("x5t#256"); key.X5u = "https://example.com/jwks"; var json = key.Canonicalize(); var canonicalizedKey = Jwk.FromJson(Encoding.UTF8.GetString(json)); Assert.NotNull(canonicalizedKey); Assert.True(canonicalizedKey.Alg.EncodedUtf8Bytes.IsEmpty); Assert.True(canonicalizedKey.Kid.EncodedUtf8Bytes.IsEmpty); Assert.True(canonicalizedKey.Use.EncodedUtf8Bytes.IsEmpty); Assert.Empty(canonicalizedKey.X5c); Assert.Null(canonicalizedKey.X5t); Assert.Null(canonicalizedKey.X5tS256); Assert.Null(canonicalizedKey.X5u); return(canonicalizedKey); }
public Jwk CanonicalizeKey(Jwk key) { key.Alg = SignatureAlgorithm.HmacSha256.Utf8Name; key.Kid = "kid"; key.Use = JwkUseNames.Sig.ToArray(); key.X5c.Add(new byte[0]); key.X5t = Encoding.UTF8.GetBytes("x5t"); key.X5tS256 = Encoding.UTF8.GetBytes("x5t#256"); key.X5u = "https://example.com/jwks"; var json = key.Canonicalize(); var canonicalizedKey = Jwk.FromJson(Encoding.UTF8.GetString(json)); Assert.NotNull(canonicalizedKey); Assert.Null(canonicalizedKey.Alg); Assert.Null(canonicalizedKey.Kid); Assert.Null(canonicalizedKey.Use); Assert.Empty(canonicalizedKey.X5c); Assert.Null(canonicalizedKey.X5t); Assert.Null(canonicalizedKey.X5tS256); Assert.Null(canonicalizedKey.X5u); return(canonicalizedKey); }