Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
NeuroLedgerModule.cs
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Threading;
5using System.Threading.Tasks;
6using System.Xml;
7using Waher.Events;
29
31{
35 [Singleton]
37 {
38 private const string DefaultDataProtectionAgreementTemplate = "25e2a2b5-4184-5cc8-a824-8b9e562c081b@legal.waher.se";
39 private static NeuroLedgerModule instance = null;
40
41 private NeuroLedgerClient client = null;
42 private NeuroLedgerProvider provider = null;
43 private HttpResource synchronizationResource;
44 private readonly ManualResetEvent p2pInitiationComplete = new ManualResetEvent(false);
45 private EndpointSecurity e2eEncryption;
46 private XmppServerlessMessaging serverlessMessaging;
47 private bool disposeE2eEncryption = false;
48 private bool started = false;
49 private bool presenceSent = false;
50
55 {
56 }
57
61 public async Task Start()
62 {
63 instance = this;
64
65 this.provider = Ledger.Provider as NeuroLedgerProvider;
66 if (this.provider is null)
67 return;
68
69 try
70 {
71 Database.ObjectInserted += Database_ObjectInserted;
72 Database.ObjectUpdated += Database_ObjectUpdated;
73 Database.ObjectDeleted += Database_ObjectDeleted;
74 Database.CollectionCleared += this.Database_CollectionCleared;
75 Database.CollectionRepaired += Database_CollectionRepaired;
76
77 RosterConfiguration.OnGetGroupSuggestions += this.RosterConfiguration_OnGetGroupSuggestions;
78
79 Gateway.OnAfterBackup += this.AfterBackup;
80
81 Gateway.XmppClient.EntityHashFunction = Security.HashFunction.SHA256;
82 Gateway.XmppClient.EntityNode = "http://waher.se/NL";
83 Gateway.XmppClient.SetTag("ShowE2E", true);
84
85 List<ISniffer> P2PSniffers = new List<ISniffer>();
87 bool HasSniffers = false;
88
89 foreach (ISniffer Sniffer in Gateway.XmppClient.Sniffers)
90 {
91 HasSniffers = true;
92
93 XmlFileSniffer = Sniffer as XmlFileSniffer;
94 if (!(XmlFileSniffer is null))
95 {
96 XmlFileSniffer = new XmlFileSniffer(Path.Combine(Gateway.AppDataFolder, "UPnP", "UPnP Log %YEAR%-%MONTH%-%DAY%T%HOUR%.xml"),
97 Path.Combine(Gateway.AppDataFolder, "Transforms", "SnifferXmlToHtml.xslt"), 7, BinaryPresentationMethod.ByteCount);
98
99 P2PSniffers.Add(XmlFileSniffer);
100 }
101 }
102
103 Gateway.XmppClient.OnStateChanged += this.XmppClient_OnStateChanged;
104
105 this.p2pInitiationComplete.Reset();
106 this.serverlessMessaging = new XmppServerlessMessaging("Neuro-Ledger", Gateway.XmppClient.FullJID,
107 (ushort)await RuntimeSettings.GetAsync("NL.P2P.LocalPort", 0),
108 (ushort)await RuntimeSettings.GetAsync("NL.P2P.ExternalPort", 0), P2PSniffers.ToArray());
109 this.serverlessMessaging.Network.OnStateChange += this.P2PNetwork_OnStateChange;
110 this.serverlessMessaging.OnNewXmppClient += this.ServerlessMessaging_OnNewXmppClient;
111 this.serverlessMessaging.OnResynch += this.ServerlessMessaging_OnResynch;
112
113 await Semaphores.BeginWrite("XMPP.E2E");
114 try
115 {
116 if (Gateway.XmppClient.TryGetTag("E2E", out object Obj) && Obj is EndpointSecurity EndpointSecurity)
117 this.e2eEncryption = EndpointSecurity;
118 else
119 {
120 this.e2eEncryption = new EndpointSecurity(Gateway.XmppClient, this.serverlessMessaging, 128);
121 Gateway.XmppClient.SetTag("E2E", this.e2eEncryption);
122 this.disposeE2eEncryption = true;
123 }
124 }
125 finally
126 {
127 await Semaphores.EndWrite("XMPP.E2E");
128 }
129
130 this.e2eEncryption.PeerUnavailable += this.E2eEncryption_PeerUnavailable;
131
132 Gateway.AvatarClient.E2E = this.e2eEncryption;
133
134 if (HasSniffers)
135 {
136 ChunkCounter Counter = new ChunkCounter(true, Gateway.XmppClient, false);
137 Gateway.XmppClient.OnReceiveText += Counter.ShortenChunks;
138 Gateway.XmppClient.OnInformation += Counter.RemoveChunkMessage;
139 Gateway.XmppClient.OnDisposed += Counter.Client_OnDisposed;
140
141 Counter = new ChunkCounter(false, Gateway.XmppClient, false);
142 Gateway.XmppClient.OnTransmitText += Counter.ShortenChunks;
143 Gateway.XmppClient.OnDisposed += Counter.Client_OnDisposed;
144 }
145
146 if (!(Gateway.HttpxProxy is null))
147 {
149 Gateway.HttpxProxy.ServerlessMessaging = this.serverlessMessaging;
150
152 Gateway.HttpxProxy.DefaultHttpxClient.E2e = this.e2eEncryption;
153 }
154
155 if (!(Gateway.HttpxServer is null))
156 Gateway.HttpxServer.RequiresE2e = true;
157
158 Gateway.ContractsClient.PetitionForIdentityReceived += this.ContractsClient_PetitionForIdentityReceived;
159
160 this.client = new NeuroLedgerClient(Gateway.XmppClient, this.e2eEncryption, Gateway.HttpServer, this.provider);
161 this.synchronizationResource = Gateway.HttpServer.Register(new SynchronizationResource("/NL/Synchronize", this.client, "User"));
162
163 this.p2pInitiationComplete.WaitOne(60000);
164
165 this.started = true;
166 Log.Informational("Neuro-Ledger successfully started.");
167
168 if (!(Gateway.XmppClient is null) && Gateway.XmppClient.State == XmppState.Connected)
169 {
170 if (!this.presenceSent)
171 await this.SetPresence();
172
173 await this.CheckContracts();
174 }
175 }
176 catch (Exception ex)
177 {
178 Log.Exception(ex);
179 }
180 }
181
182 private async Task ContractsClient_PetitionForIdentityReceived(object Sender, LegalIdentityPetitionEventArgs e)
183 {
185 {
186 bool Accept = !(Id.State == IdentityState.Compromised || Id.State == IdentityState.Rejected);
188
189 List<KeyValuePair<string, object>> Tags = new List<KeyValuePair<string, object>>()
190 {
191 new KeyValuePair<string, object>("RequestorFullJid", e.RequestorFullJid),
192 new KeyValuePair<string, object>("Provider", e.RequestorIdentity.Provider)
193 };
194
195 foreach (Property P in e.RequestorIdentity.Properties)
196 Tags.Add(new KeyValuePair<string, object>(P.Name, P.Value));
197
198 Log.Informational("Legal ID petitioned.", e.RequestedIdentityId, e.RequestedIdentityId, "IdPetition", Tags.ToArray());
199 }
200 else
202 }
203
204 private Task RosterConfiguration_OnGetGroupSuggestions(object Sender, SuggestionEventArgs e)
205 {
207 {
208 foreach (string Collection in NeuroLedgerProvider.Collections)
209 e.AddSuggestion(Collection);
210 }
211
212 return Task.CompletedTask;
213 }
214
218 public async Task Stop()
219 {
220 instance = null;
221 this.started = false;
222
223 if (!(this.client is null))
224 {
225 this.client.Dispose();
226 this.client = null;
227
228 if (this.disposeE2eEncryption)
229 {
230 this.e2eEncryption?.Dispose();
232 };
233
234 this.e2eEncryption = null;
235
236 if (!(this.serverlessMessaging is null))
237 {
238 await this.serverlessMessaging.DisposeAsync();
239 this.serverlessMessaging = null;
240 }
241
242 Gateway.OnAfterBackup -= this.AfterBackup;
243
244 RosterConfiguration.OnGetGroupSuggestions -= this.RosterConfiguration_OnGetGroupSuggestions;
245
246 Database.ObjectInserted -= Database_ObjectInserted;
247 Database.ObjectUpdated -= Database_ObjectUpdated;
248 Database.ObjectDeleted -= Database_ObjectDeleted;
249 Database.CollectionCleared -= this.Database_CollectionCleared;
250 Database.CollectionRepaired -= Database_CollectionRepaired;
251
252 Gateway.XmppClient.OnStateChanged -= this.XmppClient_OnStateChanged;
253
254 Gateway.ContractsClient.PetitionForIdentityReceived -= this.ContractsClient_PetitionForIdentityReceived;
255
256 Gateway.HttpServer.Unregister(this.synchronizationResource);
257 this.synchronizationResource = null;
258 }
259 }
260
261 private Task CheckContracts()
262 {
263 return this.CheckContracts(null);
264 }
265
266 private async Task CheckContracts(object P)
267 {
268 Contract Dpa;
269
270 if (!string.IsNullOrEmpty(LedgerConfiguration.Instance.DataProtectionAgreementId))
271 {
272 if (Gateway.ContractsClient is null)
273 {
274 Gateway.ScheduleEvent(this.CheckContracts, DateTime.Now.AddMinutes(1), null);
275 return;
276 }
277 else
279 }
280 else
281 {
282 try
283 {
284 string Xml = File.ReadAllText(Path.Combine(Gateway.AppDataFolder, "Contracts", "BlockSubscription.xml"));
285 XmlDocument Doc = new XmlDocument()
286 {
287 PreserveWhitespace = true
288 };
289 Doc.LoadXml(Xml);
290
291 ParsedContract Parsed = await Contract.Parse(Doc.DocumentElement, Gateway.ContractsClient, true);
292 Contract Template = Parsed.Contract;
293
294 string TemplateId = await RuntimeSettings.GetAsync("NL.DPA.TemplateId", DefaultDataProtectionAgreementTemplate);
295 if (string.IsNullOrEmpty(TemplateId))
296 {
297 Template = await Gateway.ContractsClient.CreateContractAsync(Template.ForMachines, Template.ForHumans,
298 Template.Roles, Template.Parts, Template.Parameters, Template.Visibility, Template.PartsMode, Template.Duration,
299 Template.ArchiveRequired, Template.ArchiveOptional, Template.SignAfter, Template.SignBefore, true);
300
301 await RuntimeSettings.SetAsync("NL.DPA.TemplateId", TemplateId = Template.ContractId);
302 }
303
304 Dpa = await Gateway.ContractsClient.CreateContractAsync(TemplateId, new Part[0],
305 new Parameter[]
306 {
307 new StringParameter()
308 {
309 Name = "Source",
310 Value = Gateway.XmppClient.BareJID
311 }
312 },
313 ContractVisibility.Public, ContractParts.Open, Template.Duration, Template.ArchiveRequired,
314 Template.ArchiveOptional, null, null, false);
315 }
316 catch (Exception ex)
317 {
318 Log.Error("Unable to create Data Protection Smart Contract.",
319 new KeyValuePair<string, object>("Message", ex.Message));
320 return;
321 }
322
323 LedgerConfiguration.Instance.DataProtectionAgreementId = Dpa.ContractId;
325 }
326
327 bool GeneratorSigned = false;
328
329 if (!(Dpa?.ClientSignatures is null))
330 {
332 {
333 if (Signature.Role == "Generator")
334 {
335 GeneratorSigned = true;
336 break;
337 }
338 }
339 }
340
341 if (!GeneratorSigned)
342 {
343 await Gateway.RequestContractSignature(Dpa, "Generator", "Data Protection Agreement required to be signed by " +
344 "designated parties before they can access blocks generated by the Neuro-Ledger on this machine.");
345 }
346 }
347
348 private static readonly Dictionary<Type, bool> processInLedger = new Dictionary<Type, bool>();
349
350 private static async Task<bool> Process(object Object)
351 {
352 Type T = Object.GetType();
353 bool Result;
354
355 lock (processInLedger)
356 {
357 if (processInLedger.TryGetValue(T, out Result))
358 return Result;
359 }
360
362 {
364 Result = Serializer.ArchiveObjects;
365 }
366 else
367 Result = false;
368
369 lock (processInLedger)
370 {
371 processInLedger[T] = Result;
372 }
373
374 return Result;
375 }
376
377 private static async void Database_ObjectInserted(object Sender, ObjectEventArgs e)
378 {
379 try
380 {
381 if (!await Process(e.Object))
382 return;
383
385 await Ledger.NewEntry(Obj);
386 }
387 catch (Exception ex)
388 {
389 Log.Exception(ex);
390 }
391 }
392
393 private static async void Database_ObjectUpdated(object Sender, ObjectEventArgs e)
394 {
395 try
396 {
397 if (!await Process(e.Object))
398 return;
399
401 await Ledger.UpdatedEntry(Obj);
402 }
403 catch (Exception ex)
404 {
405 Log.Exception(ex);
406 }
407 }
408
409 private static async void Database_ObjectDeleted(object Sender, ObjectEventArgs e)
410 {
411 try
412 {
413 if (!await Process(e.Object))
414 return;
415
417 await Ledger.DeletedEntry(Obj);
418 }
419 catch (Exception ex)
420 {
421 Log.Exception(ex);
422 }
423 }
424
425 private async Task Database_CollectionCleared(object Sender, CollectionEventArgs e)
426 {
427 try
428 {
429 string Collection = e.Collection;
430
431 if (Array.IndexOf(this.provider.Collections, Collection) >= 0)
432 await Ledger.ClearedCollection(Collection);
433 }
434 catch (Exception ex)
435 {
436 Log.Exception(ex);
437 }
438 }
439
440 private async Task XmppClient_OnStateChanged(object Sender, XmppState NewState)
441 {
442 try
443 {
444 if (Gateway.XmppClient is null)
445 return;
446
447 switch (NewState)
448 {
449 case XmppState.RequestingSession:
450 if (!(this.serverlessMessaging is null))
451 this.serverlessMessaging.FullJid = Gateway.XmppClient.FullJID;
452 break;
453
454 case XmppState.Connected:
455 foreach (RosterItem Item in Gateway.XmppClient.Roster)
456 {
459 }
460
461 await this.CheckContracts();
462 break;
463 }
464 }
465 catch (Exception ex)
466 {
467 Log.Exception(ex);
468 }
469 }
470
471 private Task ServerlessMessaging_OnNewXmppClient(object Sender, PeerConnectionEventArgs e)
472 {
473 XmppClient Client = e.Client;
475 HttpxClient HttpxClient = new HttpxClient(Client, this.e2eEncryption, 32768)
476 {
477 PostResource = Gateway.HttpxProxy.PostResource
478 };
480 bool Sniffers = false;
481
482 HttpxServer.RequiresE2e = true;
483
484 Client.SetTag("HttpxServer", HttpxServer);
485 Client.SetTag("HttpxClient", HttpxClient);
486 Client.SetTag("ShowE2E", false);
487 Client.SetTag("ExpectedSender", e.RemoteJid.ToLower());
488
489 Client.OnValidateSender += this.PeerClient_OnValidateSender;
490 Client.OnDisposed += this.P2PClient_OnDisposed;
491
492 this.e2eEncryption.RegisterHandlers(Client);
493
494 try
495 {
496 foreach (ISniffer Sniffer in Gateway.XmppClient.Sniffers)
497 {
498 Sniffers = true;
499
500 XmlFileSniffer = Sniffer as XmlFileSniffer;
501 if (!(XmlFileSniffer is null) && Types.TryGetModuleParameter("AppData", out object Obj) && Obj is string AppDataFolder)
502 {
503 XmlFileSniffer = new XmlFileSniffer(AppDataFolder + "XMPP" + Path.DirectorySeparatorChar +
504 e.RemoteJid + Path.DirectorySeparatorChar + "XMPP Log %YEAR%-%MONTH%-%DAY%T%HOUR%.xml",
505 AppDataFolder + "Transforms" + Path.DirectorySeparatorChar + "SnifferXmlToHtml.xslt",
506 7, BinaryPresentationMethod.ByteCount);
507
508 Client.Add(XmlFileSniffer);
509 }
510 else
511 Client.Add(Sniffer);
512 }
513 }
514 catch (Exception ex)
515 {
516 Log.Exception(ex);
517 }
518
519 if (Sniffers)
520 {
521 ChunkCounter Counter = new ChunkCounter(true, Client, true);
522 Client.OnReceiveText += Counter.ShortenChunks;
523 Client.OnInformation += Counter.RemoveChunkMessage;
524 Client.OnDisposed += Counter.Client_OnDisposed;
525
526 Counter = new ChunkCounter(false, Client, true);
527 Client.OnTransmitText += Counter.ShortenChunks;
528 Client.OnDisposed += Counter.Client_OnDisposed;
529 }
530
531 return Task.CompletedTask;
532 }
533
534 private Task ServerlessMessaging_OnResynch(object Sender, ResynchEventArgs e)
535 {
536 this.e2eEncryption?.SynchronizeE2e(e.RemoteFullJid, (Sender2, e2) =>
537 {
538 e.Done(e2.Ok);
539 return Task.CompletedTask;
540 });
541
542 return Task.CompletedTask;
543 }
544
545 private Task PeerClient_OnValidateSender(object Sender, ValidateSenderEventArgs e)
546 {
547 if (!e.Client.TryGetTag("ExpectedSender", out object Obj) || !(Obj is string s) || string.Compare(e.From, s, true) != 0)
548 e.Reject();
549
550 return Task.CompletedTask;
551 }
552
553 private Task P2PClient_OnDisposed(object Sender, EventArgs e)
554 {
555 if (Sender is XmppClient Client)
556 {
557 this.e2eEncryption?.UnregisterHandlers(Client);
558
559 if (Client.TryGetTag("HttpxServer", out object Obj) && Obj is IDisposable Disposable)
560 Disposable.Dispose();
561
562 if (Client.TryGetTag("HttpxClient", out Obj) && Obj is IDisposable Disposable2)
563 Disposable2.Dispose();
564 }
565
566 return Task.CompletedTask;
567 }
568
569 private async Task P2PNetwork_OnStateChange(object _, PeerToPeerNetworkState NewState)
570 {
571 if (this.serverlessMessaging is null)
572 return;
573
574 try
575 {
576 PeerToPeerNetwork P2P = this.serverlessMessaging.Network;
577
578 switch (NewState)
579 {
580 case PeerToPeerNetworkState.Ready:
581 Log.Informational("Gateway available on Peer-to-Peer network: " + P2P.ExternalEndpoint.ToString());
582
583 P2P.DesiredLocalPort = (ushort)P2P.LocalEndpoint.Port;
584 P2P.DesiredExternalPort = (ushort)P2P.ExternalEndpoint.Port;
585
586 await RuntimeSettings.SetAsync("NL.P2P.LocalPort", P2P.LocalEndpoint.Port);
587 await RuntimeSettings.SetAsync("NL.P2P.ExternalPort", P2P.ExternalEndpoint.Port);
588
589 if (this.started && Gateway.XmppClient.State == XmppState.Connected)
590 await this.SetPresence();
591
592 this.p2pInitiationComplete.Set();
593 break;
594
595 case PeerToPeerNetworkState.Error:
596 P2P.DesiredLocalPort = 0;
597 P2P.DesiredExternalPort = 0;
598
599 this.p2pInitiationComplete.Set();
600 break;
601 }
602 }
603 catch (Exception ex)
604 {
605 Log.Exception(ex);
606 }
607 }
608
609 private Task E2eEncryption_PeerUnavailable(object Sender, PresenceEventArgs e)
610 {
611 this.serverlessMessaging?.RemovePeerAddresses(e.From);
612 return Task.CompletedTask;
613 }
614
619 {
620 get { return instance?.serverlessMessaging; }
621 }
622
627 {
628 get { return instance?.e2eEncryption; }
629 }
630
631 private async Task SetPresence()
632 {
633 if (!(Gateway.XmppClient is null) && this.started)
634 {
636 this.presenceSent = true;
637 }
638 }
639
640 private async Task AfterBackup(object Sender, EventArgs e)
641 {
642 try
643 {
644 this.e2eEncryption.GenerateNewKey();
645 await this.SetPresence();
646 }
647 catch (Exception ex)
648 {
649 Log.Exception(ex);
650 }
651 }
652
653 private static Task Database_CollectionRepaired(object Sender, CollectionEventArgs e)
654 {
655 return LedgerConfiguration.Instance?.Database_CollectionRepaired(Sender, e) ?? Task.CompletedTask;
656 }
657
661 public static Task ProcessBlockRequest(Networking.HTTP.HeaderFields.HttpFieldAccept Accept, HttpResponse Response, BlockReference Ref)
662 {
663 return instance.client.ProcessBlockRequest(Accept, Response, Ref);
664 }
665
666 }
667}
Static class managing the application event log. Applications and services log events on this static ...
Definition: Log.cs:13
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Definition: Log.cs:1647
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:682
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
Definition: Log.cs:334
Static class managing the runtime environment of the IoT Gateway.
Definition: Gateway.cs:126
static HttpxProxy HttpxProxy
HTTPX Proxy resource
Definition: Gateway.cs:3315
static HttpServer HttpServer
HTTP Server
Definition: Gateway.cs:3299
static string AppDataFolder
Application data folder.
Definition: Gateway.cs:2369
static async Task RequestContractSignature(Contract Contract, string Role, string Purpose)
Requests the operator to sign a smart contract.
Definition: Gateway.cs:4405
static ContractsClient ContractsClient
XMPP Contracts Client, if such a compoent is available on the XMPP broker.
Definition: Gateway.cs:4375
static HttpxServer HttpxServer
HTTPX Server
Definition: Gateway.cs:3307
static DateTime ScheduleEvent(ScheduledEventCallback Callback, DateTime When, object State)
Schedules a one-time event.
Definition: Gateway.cs:3452
static XmppClient XmppClient
XMPP Client connection of gateway.
Definition: Gateway.cs:3187
Event arguments for suggestion event handlers.
void AddSuggestion(string Suggestion)
Adds a suggestion.
ISniffer[] Sniffers
Registered sniffers.
virtual void Add(ISniffer Sniffer)
ICommunicationLayer.Add
Base class for all HTTP resources.
Definition: HttpResource.cs:23
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:21
HttpResource Register(HttpResource Resource)
Registers a resource with the server.
Definition: HttpServer.cs:1287
bool Unregister(HttpResource Resource)
Unregisters a resource from the server.
Definition: HttpServer.cs:1438
Manages a peer-to-peer network that can receive connections from outside of a NAT-enabled firewall.
IPEndPoint ExternalEndpoint
External IP Endpoint.
ushort DesiredExternalPort
Desired external port number. If 0, a dynamic port number will be assigned.
Outputs sniffed data to an XML file.
Represents a digital signature on a contract.
Contains the definition of a contract
Definition: Contract.cs:22
static Task< ParsedContract > Parse(XmlDocument Xml)
Validates a contract XML Document, and returns the contract definition in it.
Definition: Contract.cs:397
Parameter[] Parameters
Defined parameters for the smart contract.
Definition: Contract.cs:267
Duration? ArchiveRequired
Requied time to archive a signed smart contract, after it becomes obsolete.
Definition: Contract.cs:202
ClientSignature[] ClientSignatures
Client signatures of the contract.
Definition: Contract.cs:309
HumanReadableText[] ForHumans
Human-readable contents of the contract.
Definition: Contract.cs:300
Duration? ArchiveOptional
Optional time to archive a signed smart contract, after it becomes obsolete, and after its required a...
Definition: Contract.cs:211
XmlElement ForMachines
Machine-readable contents of the contract.
Definition: Contract.cs:276
Role[] Roles
Roles defined in the smart contract.
Definition: Contract.cs:240
DateTime? SignAfter
Signatures will only be accepted after this point in time.
Definition: Contract.cs:166
ContractParts PartsMode
How parts are defined in the smart contract.
Definition: Contract.cs:249
string ContractId
Contract identity
Definition: Contract.cs:65
Part[] Parts
Defined parts for the smart contract.
Definition: Contract.cs:258
Duration? Duration
Duration of the contract. Is counted from the time it is signed by the required parties.
Definition: Contract.cs:193
DateTime? SignBefore
Signatures will only be accepted until this point in time.
Definition: Contract.cs:175
ContractVisibility Visibility
Contrat Visibility
Definition: Contract.cs:184
Task PetitionIdentityResponseAsync(string LegalId, string PetitionId, string RequestorFullJid, bool Response)
Sends a response to a petition for information about a legal identity. When a petition is received,...
Task< Contract > GetContractAsync(string ContractId)
Gets a contract
Task< Contract > CreateContractAsync(XmlElement ForMachines, HumanReadableText[] ForHumans, Role[] Roles, Part[] Parts, Parameter[] Parameters, ContractVisibility Visibility, ContractParts PartsMode, Duration? Duration, Duration? ArchiveRequired, Duration? ArchiveOptional, DateTime? SignAfter, DateTime? SignBefore, bool CanActAsTemplate)
Creates a new contract.
Abstract base class for contractual parameters
Definition: Parameter.cs:17
Contains information about a parsed contract.
Class defining a part in a contract
Definition: Part.cs:30
Abstract base class of signatures
Definition: Signature.cs:10
String-valued contractual parameter
string Id
ID attribute of message stanza.
Event arguments for presence events.
string From
From where the presence was received.
Event arguments for sender validation events.
string From
From where the stanza was received.
void Reject()
Called from an event handler to reject the sender.
IEndToEndEncryption E2e
Optional end-to-end encryption interface to use in requests.
Definition: HttpxClient.cs:87
XmppServerlessMessaging ServerlessMessaging
Serverless messaging manager.
Definition: HttpxProxy.cs:107
HttpxClient DefaultHttpxClient
Default HTTPX client.
Definition: HttpxProxy.cs:141
Task ProcessBlockRequest(HTTP.HeaderFields.HttpFieldAccept Accept, HTTP.HttpResponse Response, BlockReference Ref)
TODO
Class managing end-to-end encryption.
virtual void RegisterHandlers(XmppClient Client)
Registers XMPP stanza handlers
virtual void UnregisterHandlers(XmppClient Client)
Unregisters XMPP stanza handlers
Task SynchronizeE2e(string FullJID, EventHandlerAsync< IqResultEventArgs > Callback)
Synchronizes End-to-End Encryption and Peer-to-Peer connectivity parameters with a remote entity.
void GenerateNewKey()
Generates new local keys.
virtual void Dispose()
IDisposable.Dispose
XmppClient Client
XMPP client, if aquired, or null otherwise.
Peer connection event arguments.
string RemoteFullJid
JID of the remote end-point.
Class managing peer-to-peer serveless XMPP communication.
PeerToPeerNetwork Network
Peer-to-peer network.
async Task RemovePeerAddresses(string FullJID)
Removes a JID from the recognized set of JIDs.
Maintains information about an item in the roster.
Definition: RosterItem.cs:75
string BareJid
Bare JID of the roster item.
Definition: RosterItem.cs:276
PendingSubscription PendingSubscription
If there's a pending unanswered presence subscription or unsubscription request made to the contact.
Definition: RosterItem.cs:291
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Definition: XmppClient.cs:59
XmppState State
Current state of connection.
Definition: XmppClient.cs:985
Task RequestPresenceSubscription(string BareJid)
Requests subscription of presence information from a contact.
Definition: XmppClient.cs:4919
bool RemoveTag(string TagName)
Removes a tag from the client.
Definition: XmppClient.cs:7223
void SetTag(string TagName, object Tag)
Sets a tag value.
Definition: XmppClient.cs:7249
Task SetPresence()
Sets the presence of the connection. Add a CustomPresenceXml event handler to add custom presence XML...
Definition: XmppClient.cs:4776
bool TryGetTag(string TagName, out object Tag)
Tries to get a tag from the client. Tags can be used to attached application specific objects to the ...
Definition: XmppClient.cs:7207
RosterItem[] Roster
Items in the roster.
Definition: XmppClient.cs:4671
Event arguments for collection events.
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:19
static async Task Update(object Object)
Updates an object in the database.
Definition: Database.cs:626
static Task< GenericObject > Generalize(object Object)
Creates a generalized representation of an object.
Definition: Database.cs:1678
Static interface for ledger persistence. In order to work, a ledger provider has to be assigned to it...
Definition: Ledger.cs:14
static async Task DeletedEntry(object Object)
Deletes an entry in the ledger.
Definition: Ledger.cs:180
static ILedgerProvider Provider
Registered ledger provider.
Definition: Ledger.cs:83
static async Task NewEntry(object Object)
Adds an entry to the ledger.
Definition: Ledger.cs:118
static async Task ClearedCollection(string Collection)
Clears a collection in the ledger.
Definition: Ledger.cs:211
static async Task UpdatedEntry(object Object)
Updates an entry in the ledger.
Definition: Ledger.cs:149
string[] Collections
Array of collections archived in the ledger.
Task< ObjectSerializer > GetObjectSerializerEx(object Object)
Gets the object serializer corresponding to a specific object.
Contains a reference to a block in the ledger.
Event arguments for database object events.
Generic object. Contains a sequence of properties.
Serializes a class, taking into account attributes defined in Attributes.
bool ArchiveObjects
If objects of this type can be archived.
Static class that dynamically manages types and interfaces available in the runtime environment.
Definition: Types.cs:14
static bool TryGetModuleParameter(string Name, out object Value)
Tries to get a module parameter value.
Definition: Types.cs:583
Static class managing persistent settings.
static async Task< string > GetAsync(string Key, string DefaultValue)
Gets a string-valued setting.
static async Task< bool > SetAsync(string Key, string Value)
Sets a string-valued setting.
Static class of application-wide semaphores that can be used to order access to editable objects.
Definition: Semaphores.cs:16
static Task EndWrite(string Key)
Ends a writing session of the semaphore identified by Key . Must be called once for each call to Begi...
Definition: Semaphores.cs:102
static async Task< Semaphore > BeginWrite(string Key)
Waits until the semaphore identified by Key is ready for writing. Each call to BeginWrite must be fo...
Definition: Semaphores.cs:90
static Task ProcessBlockRequest(Networking.HTTP.HeaderFields.HttpFieldAccept Accept, HttpResponse Response, BlockReference Ref)
TODO
static XmppServerlessMessaging ServerlessMessaging
TODO
string DataProtectionAgreementId
Data Protection Agreement to use before allowing access to the Neuro-Ledger.
static LedgerConfiguration Instance
Current instance of configuration.
Allows operators to manually start network synchronization.
Interface for sniffers. Sniffers can be added to ICommunicationLayer classes to eavesdrop on communic...
Definition: ISniffer.cs:11
Interface for late-bound modules loaded at runtime.
Definition: IModule.cs:9
PeerToPeerNetworkState
State of Peer-to-peer network.
BinaryPresentationMethod
How binary data is to be presented.
IdentityState
Lists recognized legal identity states.
ContractParts
How the parts of the contract are defined.
Definition: Part.cs:9
ContractVisibility
Visibility types for contracts.
Definition: Enumerations.cs:58
Availability
Resource availability.
Definition: Availability.cs:7
XmppState
State of XMPP connection.
Definition: XmppState.cs:7
PendingSubscription
Pending subscription states.
Definition: RosterItem.cs:54