Class SignedCloudEvent<T>
- Namespace
- Savvyio.EventDriven.Messaging.CloudEvents.Cryptography
- Assembly
- Savvyio.EventDriven.Messaging.dll
Provides a default implementation of the ISignedCloudEvent<T> interface.
public record SignedCloudEvent<T> : CloudEvent<T>, IEquatable<Acknowledgeable>, IEquatable<CloudEvent>, IEquatable<CloudEvent<T>>, ISignedCloudEvent<T>, ICloudEvent<T>, IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable, ISignedMessage<T>, IMessage<T>, IAcknowledgeable, IEquatable<SignedCloudEvent<T>> where T : IIntegrationEvent
Type Parameters
TThe type of the payload constraint to the IIntegrationEvent interface.
- Inheritance
-
CloudEvent<T>SignedCloudEvent<T>
- Implements
-
IEquatable<CloudEvent<T>>ICloudEvent<T>IMessage<T>
- Inherited Members
- Extension Methods
Examples
This example shows how to wrap a CloudEvent together with the signature that protects its serialized envelope.
using System;
using Savvyio;
using Savvyio.EventDriven;
using Savvyio.EventDriven.Messaging.CloudEvents;
using Savvyio.EventDriven.Messaging.CloudEvents.Cryptography;
using Savvyio.Messaging;
namespace ExampleApp;
public sealed class SignedCloudEventExample
{
public ISignedCloudEvent<MemberCreatedEvent> Create()
{
var message = new Message<MemberCreatedEvent>("msg-42", new Uri("https://api.example.com/members"), "members.created", new MemberCreatedEvent("MEM-42"));
var cloudEvent = message.ToCloudEvent();
return new SignedCloudEvent<MemberCreatedEvent>(cloudEvent, "signature-value");
}
}
public sealed record MemberCreatedEvent(string MemberId) : Request, IIntegrationEvent;
Constructors
SignedCloudEvent(ICloudEvent<T>, string)
Initializes a new instance of the SignedCloudEvent<T> class.
public SignedCloudEvent(ICloudEvent<T> message, string signature)
Parameters
messageICloudEvent<T>The cloud event to sign.
signaturestringThe cryptographic signature of the
message.
Exceptions
- ArgumentNullException
messagecannot be null - or -signaturecannot be null.- ArgumentException
signaturecannot be empty or consist only of white-space characters.
Properties
Signature
Gets the cryptographic signature of the message.
public string Signature { get; }
Property Value
- string
The cryptographic signature of the message.
See Also
ICloudEvent<T>