public override void WriteTo() { var key = SymmetricJwk.GenerateKey(256, SignatureAlgorithm.HmacSha256); key.Kid = "kid1"; key.KeyOps.Add("sign"); key.Use = JwkUseNames.Sig.ToArray(); key.X5t = Base64Url.Decode("dGhpcyBpcyBhIFNIQTEgdGVzdCE"); key.X5tS256 = Base64Url.Decode("dGhpcyBpcyBhIFNIQTI1NiB0ZXN0ISAgICAgICAgICAgIA"); key.X5u = "https://example.com"; key.X5c.Add(Convert.FromBase64String("MIIDQjCCAiqgAwIBAgIGATz/FuLiMA0GCSqGSIb3DQEBBQUAMGIxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDTzEPMA0GA1UEBxMGRGVudmVyMRwwGgYDVQQKExNQaW5nIElkZW50aXR5IENvcnAuMRcwFQYDVQQDEw5CcmlhbiBDYW1wYmVsbDAeFw0xMzAyMjEyMzI5MTVaFw0xODA4MTQyMjI5MTVaMGIxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDTzEPMA0GA1UEBxMGRGVudmVyMRwwGgYDVQQKExNQaW5nIElkZW50aXR5IENvcnAuMRcwFQYDVQQDEw5CcmlhbiBDYW1wYmVsbDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL64zn8/QnHYMeZ0LncoXaEde1fiLm1jHjmQsF/449IYALM9if6amFtPDy2yvz3YlRij66s5gyLCyO7ANuVRJx1NbgizcAblIgjtdf/u3WG7K+IiZhtELto/A7Fck9Ws6SQvzRvOE8uSirYbgmj6He4iO8NCyvaK0jIQRMMGQwsU1quGmFgHIXPLfnpnfajr1rVTAwtgV5LEZ4Iel+W1GC8ugMhyr4/p1MtcIM42EA8BzE6ZQqC7VPqPvEjZ2dbZkaBhPbiZAS3YeYBRDWm1p1OZtWamT3cEvqqPpnjL1XyW+oyVVkaZdklLQp2Btgt9qr21m42f4wTw+Xrp6rCKNb0CAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAh8zGlfSlcI0o3rYDPBB07aXNswb4ECNIKG0CETTUxmXl9KUL+9gGlqCz5iWLOgWsnrcKcY0vXPG9J1r9AqBNTqNgHq2G03X09266X5CpOe1zFo+Owb1zxtp3PehFdfQJ610CDLEaS9V9Rqp17hCyybEpOGVwe8fnk+fbEL2Bo3UPGrpsHzUoaGpDftmWssZkhpBJKVMJyf/RuP2SmmaIzmnw9JiSlYhzo4tpzd5rFXhjRbg4zW9C+2qok+2+qDM1iJ684gPHMIY8aLWrdgQTxkumGmTqgawR+N5MDtdPTEQ0XfIBc2cJEUyMTY5MPvACWpkA6SdS4xSvdXK3IVfOWA==")); using (var bufferWriter = new PooledByteBufferWriter()) { key.Serialize(bufferWriter); var json = Encoding.UTF8.GetString(bufferWriter.WrittenSpan.ToArray()); Assert.Contains("\"kid\":\"kid1\"", json); Assert.Contains("\"key_ops\":[\"sign\"]", json); Assert.Contains("\"use\":\"sig\"", json); Assert.Contains("\"x5t\":\"dGhpcyBpcyBhIFNIQTEgdGVzdCE\"", json); Assert.Contains("\"x5t#S256\":\"dGhpcyBpcyBhIFNIQTI1NiB0ZXN0ISAgICAgICAgICAgIA\"", json); #if NETCOREAPP Assert.Contains("\"x5u\":\"" + JsonEncodedText.Encode("https://example.com", Constants.JsonEncoder) + "\"", json); Assert.Contains("\"x5c\":[\"" + JsonEncodedText.Encode("MIIDQjCCAiqgAwIBAgIGATz/FuLiMA0GCSqGSIb3DQEBBQUAMGIxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDTzEPMA0GA1UEBxMGRGVudmVyMRwwGgYDVQQKExNQaW5nIElkZW50aXR5IENvcnAuMRcwFQYDVQQDEw5CcmlhbiBDYW1wYmVsbDAeFw0xMzAyMjEyMzI5MTVaFw0xODA4MTQyMjI5MTVaMGIxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDTzEPMA0GA1UEBxMGRGVudmVyMRwwGgYDVQQKExNQaW5nIElkZW50aXR5IENvcnAuMRcwFQYDVQQDEw5CcmlhbiBDYW1wYmVsbDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL64zn8/QnHYMeZ0LncoXaEde1fiLm1jHjmQsF/449IYALM9if6amFtPDy2yvz3YlRij66s5gyLCyO7ANuVRJx1NbgizcAblIgjtdf/u3WG7K+IiZhtELto/A7Fck9Ws6SQvzRvOE8uSirYbgmj6He4iO8NCyvaK0jIQRMMGQwsU1quGmFgHIXPLfnpnfajr1rVTAwtgV5LEZ4Iel+W1GC8ugMhyr4/p1MtcIM42EA8BzE6ZQqC7VPqPvEjZ2dbZkaBhPbiZAS3YeYBRDWm1p1OZtWamT3cEvqqPpnjL1XyW+oyVVkaZdklLQp2Btgt9qr21m42f4wTw+Xrp6rCKNb0CAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAh8zGlfSlcI0o3rYDPBB07aXNswb4ECNIKG0CETTUxmXl9KUL+9gGlqCz5iWLOgWsnrcKcY0vXPG9J1r9AqBNTqNgHq2G03X09266X5CpOe1zFo+Owb1zxtp3PehFdfQJ610CDLEaS9V9Rqp17hCyybEpOGVwe8fnk+fbEL2Bo3UPGrpsHzUoaGpDftmWssZkhpBJKVMJyf/RuP2SmmaIzmnw9JiSlYhzo4tpzd5rFXhjRbg4zW9C+2qok+2+qDM1iJ684gPHMIY8aLWrdgQTxkumGmTqgawR+N5MDtdPTEQ0XfIBc2cJEUyMTY5MPvACWpkA6SdS4xSvdXK3IVfOWA==", Constants.JsonEncoder) + "\"]", json); #else Assert.Contains("\"x5u\":\"" + JsonEncodedText.Encode("https://example.com") + "\"", json); Assert.Contains("\"x5c\":[\"" + JsonEncodedText.Encode("MIIDQjCCAiqgAwIBAgIGATz/FuLiMA0GCSqGSIb3DQEBBQUAMGIxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDTzEPMA0GA1UEBxMGRGVudmVyMRwwGgYDVQQKExNQaW5nIElkZW50aXR5IENvcnAuMRcwFQYDVQQDEw5CcmlhbiBDYW1wYmVsbDAeFw0xMzAyMjEyMzI5MTVaFw0xODA4MTQyMjI5MTVaMGIxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDTzEPMA0GA1UEBxMGRGVudmVyMRwwGgYDVQQKExNQaW5nIElkZW50aXR5IENvcnAuMRcwFQYDVQQDEw5CcmlhbiBDYW1wYmVsbDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL64zn8/QnHYMeZ0LncoXaEde1fiLm1jHjmQsF/449IYALM9if6amFtPDy2yvz3YlRij66s5gyLCyO7ANuVRJx1NbgizcAblIgjtdf/u3WG7K+IiZhtELto/A7Fck9Ws6SQvzRvOE8uSirYbgmj6He4iO8NCyvaK0jIQRMMGQwsU1quGmFgHIXPLfnpnfajr1rVTAwtgV5LEZ4Iel+W1GC8ugMhyr4/p1MtcIM42EA8BzE6ZQqC7VPqPvEjZ2dbZkaBhPbiZAS3YeYBRDWm1p1OZtWamT3cEvqqPpnjL1XyW+oyVVkaZdklLQp2Btgt9qr21m42f4wTw+Xrp6rCKNb0CAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAh8zGlfSlcI0o3rYDPBB07aXNswb4ECNIKG0CETTUxmXl9KUL+9gGlqCz5iWLOgWsnrcKcY0vXPG9J1r9AqBNTqNgHq2G03X09266X5CpOe1zFo+Owb1zxtp3PehFdfQJ610CDLEaS9V9Rqp17hCyybEpOGVwe8fnk+fbEL2Bo3UPGrpsHzUoaGpDftmWssZkhpBJKVMJyf/RuP2SmmaIzmnw9JiSlYhzo4tpzd5rFXhjRbg4zW9C+2qok+2+qDM1iJ684gPHMIY8aLWrdgQTxkumGmTqgawR+N5MDtdPTEQ0XfIBc2cJEUyMTY5MPvACWpkA6SdS4xSvdXK3IVfOWA==") + "\"]", json); #endif Assert.Contains("\"k\":\"" + Encoding.UTF8.GetString(Base64Url.Encode(key.K)) + "\"", json); } }
public void Descriptor_FullCapacity() { var payload = new JwtPayload(); for (int i = 0; i < 256; i++) { payload.Add(i.ToString(), i); } // TODO : SymmetricJwk.GenerateKey(EncryptionAlgorithm.Aes128CbcHmacSha256) var descriptor = new JweDescriptor(SymmetricJwk.GenerateKey(256), KeyManagementAlgorithm.Dir, EncryptionAlgorithm.A128CbcHS256, CompressionAlgorithm.Def) { Payload = new JwsDescriptor(SymmetricJwk.GenerateKey(SignatureAlgorithm.HS256), SignatureAlgorithm.HS256) { Payload = payload } }; for (int i = 0; i < 256; i++) { descriptor.Payload.TryGetClaim(i.ToString(), out var member); Assert.Equal(JwtValueKind.Int32, member.Type); Assert.Equal(i.ToString(), member.Name.ToString()); Assert.Equal(i, (int)member.Value); } PooledByteBufferWriter writer = new PooledByteBufferWriter(); var context = new EncodingContext(writer, null, 0, false); descriptor.Encode(context); }
/// <summary> /// Gets a string representation for the current value appropriate to the node type. /// </summary> /// <returns>A string representation for the current value appropriate to the node type.</returns> public override string ToString() { // Special case for string; don't quote it. if (this is JsonValue) { if (this is JsonValue <string> jsonString) { return(jsonString.Value); } if (this is JsonValue <JsonElement> jsonElement && jsonElement.Value.ValueKind == JsonValueKind.String) { return(jsonElement.Value.GetString() !); } } using (var output = new PooledByteBufferWriter(JsonSerializerOptions.BufferSizeDefault)) { using (var writer = new Utf8JsonWriter(output, new JsonWriterOptions { Indented = true })) { WriteTo(writer); } return(JsonHelpers.Utf8GetString(output.WrittenMemory.ToArray())); } }
public static async Task SerializeAsync(Stream stream, IEnumerable <Document> documents, CancellationToken cancellationToken = default) { using var buffer = new PooledByteBufferWriter(stream); // ReSharper disable once UseAwaitUsing using var writer = new Utf8JsonWriter(buffer); writer.WriteStartArray(); foreach (var document in documents) { writer.WriteStartObject(); foreach (var(key, attributeValue) in document) { writer.WritePropertyName(key); WriteAttributeValue(buffer, writer, in attributeValue); if (buffer.ShouldFlush(writer)) { await buffer.FlushAsync(writer, cancellationToken).ConfigureAwait(false); } } writer.WriteEndObject(); } writer.WriteEndArray(); await buffer.FlushAsync(writer, cancellationToken).ConfigureAwait(false); }
/// <inheritsdoc /> public override void Encode(EncodingContext context) { using var bufferWriter = new PooledByteBufferWriter(); var ctx = new EncodingContext(bufferWriter, context); Payload.Encode(ctx); EncryptToken(bufferWriter.WrittenSpan, context); }
public string Serialize(T value) { using (PooledByteBufferWriter output = new PooledByteBufferWriter(Options.DefaultBufferSize)) using (Utf8JsonWriter writer = new Utf8JsonWriter(output, WriterOptions)) { Serialize(writer, value); return(Encoding.UTF8.GetString(output.WrittenMemory.Span)); } }
private void WriteValue(Utf8JsonWriter writer, PooledByteBufferWriter bufferWriter, StringAttributeValue attributeValue) { writer.WriteStringValue(attributeValue.Value); if (bufferWriter.ShouldFlush(writer)) { bufferWriter.FlushAsync(writer); } }
private async ValueTask WriteValueAsync(Utf8JsonWriter writer, PooledByteBufferWriter bufferWriter, StringAttributeValue attributeValue) { writer.WriteStringValue(attributeValue.Value); if (bufferWriter.ShouldFlush(writer)) { await bufferWriter.FlushAsync(writer).ConfigureAwait(false); } }
public byte[] SerializeToUtf8Bytes(T value) { using (PooledByteBufferWriter output = new PooledByteBufferWriter(Options.DefaultBufferSize)) using (Utf8JsonWriter writer = new Utf8JsonWriter(output, WriterOptions)) { Serialize(writer, value); return(output.WrittenMemory.ToArray()); } }
/// <summary> /// Converts the current instance to string in JSON format. /// </summary> /// <param name="options">Options to control the serialization behavior.</param> /// <returns>JSON representation of current instance.</returns> public string ToJsonString(JsonSerializerOptions?options = null) { using var output = new PooledByteBufferWriter(JsonSerializerOptions.BufferSizeDefault); using (var writer = new Utf8JsonWriter(output, options == null ? default(JsonWriterOptions) : options.GetWriterOptions())) { WriteTo(writer, options); } return(JsonHelpers.Utf8GetString(output.WrittenMemory.ToArray())); }
public static string Serialize(Document document) { using var buffer = new PooledByteBufferWriter(); using var writer = new Utf8JsonWriter(buffer); WriteDocument(buffer, writer, document); writer.Flush(); return(Encoding.UTF8.GetString(buffer.WrittenMemory.Span)); }
public ArraySegment <byte> SerializeToJsonBytes <T>(T body) { using var bufferWriter = new PooledByteBufferWriter(bytesPool, serializerOptions.DefaultBufferSize); using var writer = new Utf8JsonWriter(bufferWriter, writerOptions); JsonSerializer.Serialize(writer, body, serializerOptions); var bytes = bufferWriter.WrittenMemory.ToArray(); return(new ArraySegment <byte>(bytes)); }
private void WriteData(Utf8JsonWriter writer, PooledByteBufferWriter bufferWriter) { writer.WriteStartObject(); for (var i = 0; i < 100; i++) { writer.WritePropertyName($"test_i"); WriteValue(writer, bufferWriter, _listInput[i].AsStringAttribute()); } writer.WriteEndObject(); }
private async ValueTask WriteDataAsync(Utf8JsonWriter writer, PooledByteBufferWriter bufferWriter) { writer.WriteStartObject(); for (var i = 0; i < 100; i++) { writer.WritePropertyName($"test_i"); await WriteValueAsync(writer, bufferWriter, _listInput[i].AsStringAttribute()).ConfigureAwait(false); } writer.WriteEndObject(); }
public async Task <long> AsyncBenchmark() { await using var stream = new MemoryStream(); using var bufferWriter = new PooledByteBufferWriter(stream, 160 * 1024); await using var writer = new Utf8JsonWriter(bufferWriter); await WriteDataAsync(writer, bufferWriter).ConfigureAwait(false); await bufferWriter.FlushAsync(writer).ConfigureAwait(false); return(stream.Length); }
private static void Main() { Console.WriteLine("Starting..."); writer.EnableHeaderCaching = false; writer.IgnoreTokenValidation = false; using (var buffer = new PooledByteBufferWriter()) { while (true) { writer.WriteToken(jwsDescriptor, buffer); } } }
private static void WriteDocument(PooledByteBufferWriter buffer, Utf8JsonWriter writer, Document document) { writer.WriteStartObject(); foreach (var(key, attributeValue) in document) { writer.WritePropertyName(key); WriteAttributeValue(buffer, writer, in attributeValue); } writer.WriteEndObject(); }
public void WriteTo(JwtProperty property, string expected) { using (var bufferWriter = new PooledByteBufferWriter()) { using (var writer = new Utf8JsonWriter(bufferWriter)) { writer.WriteStartObject(); property.WriteTo(writer); writer.WriteEndObject(); } Assert.Equal(expected, Encoding.UTF8.GetString(bufferWriter.WrittenSpan.ToArray())); } }
private static byte[] WriteCoreBytes <TValue>(TValue value, Type inputType, JsonSerializerOptions?options) { if (options == null) { options = JsonSerializerOptions.s_defaultOptions; } using (var output = new PooledByteBufferWriter(options.DefaultBufferSize)) { using (var writer = new Utf8JsonWriter(output, options.GetWriterOptions())) { WriteCore <TValue>(writer, value, inputType, options); } return(output.WrittenMemory.ToArray()); } }
public void Encode() { var descriptor = new JwsDescriptor(); var context = new EncodingContext(new JsonHeaderCache(), 60, true); using (var bufferWriter = new PooledByteBufferWriter()) { descriptor.Encode(context, bufferWriter); var reader = new JwtReader(); var result = reader.TryReadToken(bufferWriter.WrittenSpan, TokenValidationPolicy.NoValidation); Assert.True(result.Succedeed); Assert.NotNull(result.Token); Assert.True(result.Token.ExpirationTime.HasValue); Assert.True(result.Token.IssuedAt.HasValue); } }
public void EncodeEmpty() { var descriptor = new JwsDescriptor(Jwk.None, SignatureAlgorithm.None); using (var bufferWriter = new PooledByteBufferWriter()) { var context = new EncodingContext(bufferWriter, new LruJwtHeaderCache(), 60, true); descriptor.Encode(context); var result = Jwt.TryParse(bufferWriter.WrittenSpan, TokenValidationPolicy.NoValidation, out var jwt); Assert.True(result); Assert.NotNull(jwt); Assert.True(jwt.Payload.ContainsClaim("exp")); Assert.True(jwt.Payload.ContainsClaim("iat")); jwt.Dispose(); } }
private static string Serialize <TValue>(TValue value, Type inputType, JsonSerializerOptions?options) { if (options == null) { options = JsonSerializerOptions.s_defaultOptions; } using (var output = new PooledByteBufferWriter(options.DefaultBufferSize)) { using (var writer = new Utf8JsonWriter(output, options.GetWriterOptions())) { WriteCore(writer, value, inputType, options); } return(JsonReaderHelper.TranscodeHelper(output.WrittenMemory.Span)); } }
public static string Serialize(IEnumerable <Document> documents) { using var buffer = new PooledByteBufferWriter(); using var writer = new Utf8JsonWriter(buffer); writer.WriteStartArray(); foreach (var document in documents) { WriteDocument(buffer, writer, document); } writer.WriteEndArray(); writer.Flush(); return(Encoding.UTF8.GetString(buffer.WrittenMemory.Span)); }
public void Setup() { _result = new JsonMessage { message = "Hello, World!" }; _oldPatternOptions = new JsonSerializerOptions(); _newPatternInfo = JsonContext.Default.JsonMessage; _sourceGenBufferWriter = new PooledByteBufferWriter(16 * 1024); _sourceGenMemoryStream = new MemoryStream(); _sourceGenWriterBufferWriter = new Utf8JsonWriter(_sourceGenBufferWriter); _sourceGenWriterMemoryStream = new Utf8JsonWriter(_sourceGenMemoryStream); _writerBufferWriter = new PooledByteBufferWriter(16 * 1024); _writerMemoryStream = new MemoryStream(); _writerWBufferWriter = new Utf8JsonWriter(_writerBufferWriter); _writerWMemoryStream = new Utf8JsonWriter(_writerMemoryStream); }
protected override async Task SerializeToStreamAsync(Stream stream, TransportContext?context) { if (_pooledContentStream?.Length > 0) { await _pooledContentStream.CopyToAsync(stream).ConfigureAwait(false); return; } // Pooled buffer may seems redundant while reviewing current method, but when passed to json writer it completely changes the write logic. // Instead of reallocating new in-memory arrays when json size grows and Flush is not called explicitly - it now uses pooled buffer. // With proper flushing logic amount of buffer growths/copies should be zero and amount of memory allocations should be zero as well. using var bufferWriter = new PooledByteBufferWriter(stream); await using var writer = new Utf8JsonWriter(bufferWriter, JsonWriterOptions); var ddbWriter = new DdbWriter(writer, bufferWriter); await WriteDataAsync(ddbWriter).ConfigureAwait(false); await ddbWriter.FlushAsync().ConfigureAwait(false); }
public void Descriptor_AllKindOfObject() { var descriptor = new JweDescriptor(SymmetricJwk.GenerateKey(256), KeyManagementAlgorithm.Dir, EncryptionAlgorithm.A128CbcHS256, CompressionAlgorithm.Def) { Payload = new JwsDescriptor(SymmetricJwk.GenerateKey(SignatureAlgorithm.HS256), SignatureAlgorithm.HS256) { Header = new JwtHeader { { "H1", "value1" }, { "H2", new Dictionary <string, object> { { "prop1", "value2" } } }, { "H3", 123L }, { "H4", new Fake { Inner = new Fake { Value = "Inner1", Inner = new Fake { Value = "Inner2" } }, Value = "Inner0" } }, { "H5", new [] { "a", "b", "c" } }, { "H6", new [] { new object(), new object(), "abc", 123 } }, { "H7", true }, { "H8", false }, }, Payload = new JwtPayload { { "P1", "value1" }, { "P2", new Dictionary <string, object> { { "prop1", "value2" } } }, { "P3", 123L }, { "P4", new Fake { Inner = new Fake { Value = "Inner1", Inner = new Fake { Value = "Inner2" } }, Value = "Inner0" } }, { "P5", new [] { "a", "b", "c" } }, { "P6", new [] { new object(), new object(), "abc", 123 } }, { "P7", true }, { "P8", false }, } } }; Assert.True(descriptor.Payload.TryGetClaim("P1", out var claim)); Assert.Equal(JwtValueKind.String, claim.Type); Assert.True(descriptor.Payload.TryGetClaim("P2", out claim)); Assert.Equal(JwtValueKind.Object, claim.Type); Assert.True(descriptor.Payload.TryGetClaim("P3", out claim)); Assert.Equal(JwtValueKind.Int64, claim.Type); Assert.True(descriptor.Payload.TryGetClaim("P4", out claim)); Assert.Equal(JwtValueKind.Object, claim.Type); Assert.True(descriptor.Payload.TryGetClaim("P5", out claim)); Assert.Equal(JwtValueKind.Array, claim.Type); Assert.True(descriptor.Payload.TryGetClaim("P6", out claim)); Assert.Equal(JwtValueKind.Array, claim.Type); Assert.True(descriptor.Payload.TryGetClaim("P7", out claim)); Assert.Equal(JwtValueKind.True, claim.Type); Assert.True(descriptor.Payload.TryGetClaim("P8", out claim)); Assert.Equal(JwtValueKind.False, claim.Type); Assert.True(descriptor.Payload.Header.TryGetValue("alg", out var jwsHeaderParameter)); Assert.Equal(JwtValueKind.JsonEncodedString, jwsHeaderParameter.Type); Assert.True(descriptor.Payload.Header.TryGetValue("kid", out jwsHeaderParameter)); Assert.Equal(JwtValueKind.JsonEncodedString, jwsHeaderParameter.Type); Assert.True(descriptor.Payload.Header.TryGetValue("H1", out jwsHeaderParameter)); Assert.Equal(JwtValueKind.String, jwsHeaderParameter.Type); Assert.True(descriptor.Payload.Header.TryGetValue("H2", out jwsHeaderParameter)); Assert.Equal(JwtValueKind.Object, jwsHeaderParameter.Type); Assert.True(descriptor.Payload.Header.TryGetValue("H3", out jwsHeaderParameter)); Assert.Equal(JwtValueKind.Int64, jwsHeaderParameter.Type); Assert.True(descriptor.Payload.Header.TryGetValue("H4", out jwsHeaderParameter)); Assert.Equal(JwtValueKind.Object, jwsHeaderParameter.Type); Assert.True(descriptor.Payload.Header.TryGetValue("H5", out jwsHeaderParameter)); Assert.Equal(JwtValueKind.Array, jwsHeaderParameter.Type); Assert.True(descriptor.Payload.Header.TryGetValue("H6", out jwsHeaderParameter)); Assert.Equal(JwtValueKind.Array, jwsHeaderParameter.Type); Assert.True(descriptor.Payload.Header.TryGetValue("H7", out jwsHeaderParameter)); Assert.Equal(JwtValueKind.True, jwsHeaderParameter.Type); Assert.True(descriptor.Payload.Header.TryGetValue("H8", out jwsHeaderParameter)); Assert.Equal(JwtValueKind.False, jwsHeaderParameter.Type); Assert.True(descriptor.Header.TryGetValue("kid", out var jweHeaderParameter)); Assert.True(descriptor.Header.TryGetValue("alg", out jweHeaderParameter)); Assert.Equal(KeyManagementAlgorithm.Dir.Name, ((JsonEncodedText)jweHeaderParameter.Value)); Assert.True(descriptor.Header.TryGetValue("enc", out jweHeaderParameter)); Assert.Equal(EncryptionAlgorithm.A128CbcHS256.Name, ((JsonEncodedText)jweHeaderParameter.Value)); Assert.True(descriptor.Header.TryGetValue("zip", out jweHeaderParameter)); Assert.Equal(CompressionAlgorithm.Def.Name, (JsonEncodedText)jweHeaderParameter.Value); PooledByteBufferWriter writer = new PooledByteBufferWriter(); var context = new EncodingContext(writer, null, 0, false); descriptor.Encode(context); }
internal DdbWriter(Utf8JsonWriter jsonJsonWriter, PooledByteBufferWriter bufferWriter) { JsonWriter = jsonJsonWriter; BufferWriter = bufferWriter; }
private static void WriteAttributeValue(PooledByteBufferWriter buffer, Utf8JsonWriter writer, in AttributeValue attributeValue)