SignedMessage<T> Class
Definition
- Namespace
- Savvyio.Messaging.Cryptography
- Assemblies
- Savvyio.Messaging.dll
Provides a default implementation of the ISignedMessage<T> interface.
public record SignedMessage<T> : Acknowledgeable, IEquatable<Acknowledgeable>, ISignedMessage<T>, IMessage<T>, IAcknowledgeable, IEquatable<SignedMessage<T>> where T : IRequest
Type Parameters
TThe type of the payload constraint to the IRequest interface.
- Inheritance
-
SignedMessage<T>
- Implements
-
IMessage<T>
- Inherited Members
- Extension Methods
Examples
Attach a signature to an existing IMessage<T> envelope using MessageExtensions.Sign<T>. SignedMessage<T> carries both the original message and the computed signature so the consumer can verify integrity before dispatching.
using System;
using Savvyio;
using Savvyio.Messaging;
using Savvyio.Messaging.Cryptography;
namespace ExampleApp;
public sealed class SignedMessageExample
{
public void SignAndVerify()
{
var message = new Message<CreateOrderCommand>(
"msg-42",
new Uri("urn:orders"),
"orders.create",
new CreateOrderCommand("ORD-42"));
var signed = new SignedMessage<CreateOrderCommand>(message, "hmac-signature-value");
Console.WriteLine($"Message {signed.Id} signed with: {signed.Signature}");
}
}
public sealed record CreateOrderCommand(string OrderId) : Request;
Constructors
| Name | Description |
|---|---|
| SignedMessage(IMessage<T>, string) | Initializes a new instance of the SignedMessage<T> class. |
Properties
| Name | Description |
|---|---|
| Data | Gets the payload of the message. |
| Id | Gets the identifier of the message. When combined with Source, this enables deduplication. |
| Signature | Gets the cryptographic signature of the message. |
| Source | Gets the context that describes the origin of the message. When combined with Id, this enables deduplication. |
| Time | Gets the time, expressed as the Coordinated Universal Time (UTC), at which this message was generated. |
| Type | Gets the type that describes the type of event related to the originating occurrence. |