Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ContractOrchestratorService.cs
1using System.Data;
2using System.Globalization;
3using System.Reflection;
4using System.Text;
5using EDaler;
20using NeuroFeatures;
31
33{
34 [Singleton]
35 internal class ContractOrchestratorService : LoadableService, IContractOrchestratorService
36 {
37
38 private readonly IAuthenticationService authenticationService = ServiceRef.Provider.GetRequiredService<IAuthenticationService>();
39
40 public ContractOrchestratorService()
41 {
42 }
43
44 public override Task Load(bool IsResuming, CancellationToken CancellationToken)
45 {
46 if (this.BeginLoad(IsResuming, CancellationToken))
47 {
48 ServiceRef.XmppService.ConnectionStateChanged += this.Contracts_ConnectionStateChanged;
49 ServiceRef.XmppService.PetitionForPeerReviewIdReceived += this.Contracts_PetitionForPeerReviewIdReceived;
50 ServiceRef.XmppService.PetitionForIdentityReceived += this.Contracts_PetitionForIdentityReceived;
51 ServiceRef.XmppService.PetitionForSignatureReceived += this.Contracts_PetitionForSignatureReceived;
52 ServiceRef.XmppService.PetitionedIdentityResponseReceived += this.Contracts_PetitionedIdentityResponseReceived;
53 ServiceRef.XmppService.PetitionedPeerReviewIdResponseReceived += this.Contracts_PetitionedPeerReviewResponseReceived;
54 ServiceRef.XmppService.SignaturePetitionResponseReceived += this.Contracts_SignaturePetitionResponseReceived;
55 ServiceRef.XmppService.ContractProposalReceived += this.Contracts_ContractProposalRecieved;
56
57 this.EndLoad(true);
58 }
59
60 return Task.CompletedTask;
61 }
62
63 public override Task Unload()
64 {
65 if (this.BeginUnload())
66 {
67 ServiceRef.XmppService.ConnectionStateChanged -= this.Contracts_ConnectionStateChanged;
68 ServiceRef.XmppService.PetitionForPeerReviewIdReceived -= this.Contracts_PetitionForPeerReviewIdReceived;
69 ServiceRef.XmppService.PetitionForIdentityReceived -= this.Contracts_PetitionForIdentityReceived;
70 ServiceRef.XmppService.PetitionForSignatureReceived -= this.Contracts_PetitionForSignatureReceived;
71 //ServiceRef.XmppService.PetitionForContractReceived -= this.Contract_Pe
72 ServiceRef.XmppService.PetitionedIdentityResponseReceived -= this.Contracts_PetitionedIdentityResponseReceived;
73 ServiceRef.XmppService.PetitionedPeerReviewIdResponseReceived -= this.Contracts_PetitionedPeerReviewResponseReceived;
74 ServiceRef.XmppService.SignaturePetitionResponseReceived -= this.Contracts_SignaturePetitionResponseReceived;
75 ServiceRef.XmppService.ContractProposalReceived -= this.Contracts_ContractProposalRecieved;
76
77 this.EndUnload();
78 }
79
80 return Task.CompletedTask;
81 }
82
83 #region Event Handlers
84
85 private async Task Contracts_PetitionForPeerReviewIdReceived(object? Sender, SignaturePetitionEventArgs e)
86 {
87 try
88 {
90
91 if (Identity?.Properties is not null)
92 {
93 foreach (Property Property in Identity.Properties)
94 {
95 switch (Property.Name)
96 {
129 break;
130
131 default:
132 byte[] Signature = await ServiceRef.XmppService.Sign(e.ContentToSign, SignWith.LatestApprovedId);
133
134 await ServiceRef.XmppService.SendPetitionSignatureResponse(e.SignatoryIdentityId, e.ContentToSign, Signature,
135 e.PetitionId, e.RequestorFullJid, false);
136
137 return;
138 }
139 }
140
141 PetitionPeerReviewNavigationArgs Args = new(Identity, e.RequestorFullJid, e.SignatoryIdentityId, e.PetitionId,
143
145 }
146 }
147 catch (Exception ex)
148 {
149 ServiceRef.LogService.LogException(ex);
150 }
151 }
152
153 private async Task Contracts_PetitionForIdentityReceived(object? Sender, LegalIdentityPetitionEventArgs e)
154 {
155 try
156 {
157 LegalIdentity Identity;
158
159 if (e.RequestedIdentityId == ServiceRef.TagProfile.LegalIdentity?.Id)
160 Identity = ServiceRef.TagProfile.LegalIdentity;
161 else
162 {
163 (bool Succeeded, LegalIdentity? LegalId) = await ServiceRef.NetworkService.TryRequest(() => ServiceRef.XmppService.GetLegalIdentity(e.RequestedIdentityId));
164
165 if (!Succeeded || LegalId is null)
166 return;
167
168 Identity = LegalId;
169 }
170
171 if (Identity is null)
172 {
173 ServiceRef.LogService.LogWarning("Identity is missing or cannot be retrieved, ignore.",
174 new KeyValuePair<string, object?>("Type", this.GetType().Name),
175 new KeyValuePair<string, object?>("Method", nameof(Contracts_PetitionForIdentityReceived)));
176
177 return;
178 }
179
180 if (Identity.State == IdentityState.Compromised ||
181 Identity.State == IdentityState.Rejected)
182 {
183 await ServiceRef.NetworkService.TryRequest(() =>
184 {
185 return ServiceRef.XmppService.SendPetitionIdentityResponse(
187 });
188 }
189 else
190 {
191 Identity = e.RequestorIdentity;
192
193 if (Identity is not null)
194 {
196 await ServiceRef.Provider.GetRequiredService<IPopupService>().PopAsync();
197 //await ServiceRef.NotificationService.NewEvent(Event);
198 await ServiceRef.NavigationService.GoToAsync(nameof(PetitionIdentityPage), new PetitionIdentityNavigationArgs(
200 NotificationIntent Intent = CreateIdentityPetitionNotificationIntent(e);
201 await this.MarkPetitionNotificationConsumedAsync(Intent);
202 }
203 }
204 }
205 catch (Exception ex)
206 {
207 ServiceRef.LogService.LogException(ex);
208 }
209 }
210
211 private async Task Contracts_PetitionForSignatureReceived(object? Sender, SignaturePetitionEventArgs e)
212 {
213 try
214 {
215 LegalIdentity Identity;
216
217 if (e.SignatoryIdentityId == ServiceRef.TagProfile.LegalIdentity?.Id)
218 Identity = ServiceRef.TagProfile.LegalIdentity;
219 else
220 {
221 (bool Succeeded, LegalIdentity? LegalId) = await ServiceRef.NetworkService.TryRequest(() => ServiceRef.XmppService.GetLegalIdentity(e.SignatoryIdentityId));
222 if (!Succeeded || LegalId is null)
223 return;
224
225 Identity = LegalId;
226 }
227
228 if (Identity is null)
229 {
230 ServiceRef.LogService.LogWarning("Identity is missing or cannot be retrieved, ignore.",
231 new KeyValuePair<string, object?>("Type", this.GetType().Name),
232 new KeyValuePair<string, object?>("Method", nameof(Contracts_PetitionForSignatureReceived)));
233
234 return;
235 }
236
237 if (Identity.State == IdentityState.Compromised || Identity.State == IdentityState.Rejected)
238 {
239 await ServiceRef.NetworkService.TryRequest(() =>
240 {
241 return ServiceRef.XmppService.SendPetitionSignatureResponse(
243 });
244 }
245 else
246 {
247 Identity = e.RequestorIdentity;
248
249 if (Identity is not null)
250 {
253 NotificationIntent Intent = CreateSignaturePetitionNotificationIntent(e);
254 await this.MarkPetitionNotificationConsumedAsync(Intent);
255 }
256 }
257 }
258 catch (Exception ex)
259 {
260 ServiceRef.LogService.LogException(ex);
261 }
262 }
263
264 private async Task Contracts_PetitionedIdentityResponseReceived(object? Sender, LegalIdentityPetitionResponseEventArgs e)
265 {
266 try
267 {
268 LegalIdentity Identity = e.RequestedIdentity;
269
270 if (!e.Response || Identity is null)
271 {
276 }
278 await ServiceRef.NavigationService.GoToAsync(nameof(ViewIdentityPage), new ViewIdentityNavigationArgs(Identity));
279 }
280 catch (Exception ex)
281 {
282 ServiceRef.LogService.LogException(ex);
283 }
284 }
285
286 private async Task Contracts_PetitionedPeerReviewResponseReceived(object? Sender, SignaturePetitionResponseEventArgs e)
287 {
288 try
289 {
290 LegalIdentity? ReviewedIdentity = ServiceRef.TagProfile.IdentityApplication;
291 if (ReviewedIdentity is null)
292 return;
293
294 if (!e.Response)
295 {
300
301 return;
302 }
303
304 LegalIdentity ReviewerIdentity = e.RequestedIdentity;
305 if (ReviewerIdentity is null)
306 return;
307
308 try
309 {
310 StringBuilder Xml = new();
311 ReviewedIdentity.Serialize(Xml, true, true, true, true, true, true, true);
312 string s = Xml.ToString();
313 byte[] Data = Encoding.UTF8.GetBytes(s);
314 bool? Result;
315
316 try
317 {
318 Result = ServiceRef.XmppService.ValidateSignature(ReviewerIdentity, Data, e.Signature);
319 }
320 catch (Exception ex)
321 {
323 return;
324 }
325
326 if (!Result.HasValue || !Result.Value)
327 {
332 }
333 else
334 {
335 (bool Succeeded, LegalIdentity? LegalIdentity) = await ServiceRef.NetworkService.TryRequest(async () =>
336 {
337 LegalIdentity Result = await ServiceRef.XmppService.AddPeerReviewIdAttachment(ReviewedIdentity, ReviewerIdentity, e.Signature);
338 await ServiceRef.TagProfile.IncrementNrPeerReviews();
339 return Result;
340 });
341
342 if (Succeeded)
343 {
348 }
349 }
350 }
351 catch (Exception ex)
352 {
353 ServiceRef.LogService.LogException(ex);
355 ServiceRef.Localizer[nameof(AppResources.ErrorTitle)], ex.Message,
357 }
358 }
359 catch (Exception ex)
360 {
361 ServiceRef.LogService.LogException(ex);
362 }
363 }
364
365 private static NotificationIntent CreateIdentityPetitionNotificationIntent(LegalIdentityPetitionEventArgs e)
366 {
369
370 NotificationIntent Intent = new()
371 {
373 Title = Title,
374 Body = Body,
375 Action = NotificationAction.OpenPetition,
376 EntityId = e.RequestorFullJid,
377 CorrelationId = e.PetitionId,
378 Presentation = NotificationPresentation.StoreOnly
379 };
380
381 Intent.Extras["petitionId"] = e.PetitionId ?? string.Empty;
382 Intent.Extras["requestedIdentityId"] = e.RequestedIdentityId ?? string.Empty;
383 Intent.Extras["requestorIdentityId"] = e.RequestorIdentity?.Id ?? string.Empty;
384
385 return Intent;
386 }
387
388 private static NotificationIntent CreateSignaturePetitionNotificationIntent(SignaturePetitionEventArgs e)
389 {
392
393 NotificationIntent Intent = new()
394 {
396 Title = Title,
397 Body = Body,
398 Action = NotificationAction.OpenPetition,
399 EntityId = e.RequestorFullJid,
400 CorrelationId = e.PetitionId,
401 Presentation = NotificationPresentation.StoreOnly
402 };
403
404 byte[] ContentToSign = e.ContentToSign ?? Array.Empty<byte>();
405 string ContentToSignBase64 = Convert.ToBase64String(ContentToSign);
406 string Purpose = e.Purpose ?? string.Empty;
407 string RequestorIdentityId = e.RequestorIdentity?.Id ?? string.Empty;
408
409 Intent.Extras["signatoryId"] = e.SignatoryIdentityId ?? string.Empty;
410 Intent.Extras["petitionId"] = e.PetitionId ?? string.Empty;
411 Intent.Extras["requestorIdentityId"] = RequestorIdentityId;
412 Intent.Extras["purpose"] = Purpose;
413 Intent.Extras["contentToSign"] = ContentToSignBase64;
414
415 return Intent;
416 }
417
418 private async Task MarkPetitionNotificationConsumedAsync(NotificationIntent Intent)
419 {
420 try
421 {
423 string NotificationId = NotificationService.ComputeId(Intent, NotificationSource.Xmpp);
424 await NotificationService.MarkConsumedAsync(NotificationId, CancellationToken.None);
425 }
426 catch (Exception ex)
427 {
428 ServiceRef.LogService.LogException(ex);
429 }
430 }
431
432 private static string ToBareJid(string Jid)
433 {
434 if (string.IsNullOrWhiteSpace(Jid))
435 return Jid;
436
437 int SlashIndex = Jid.IndexOf('/');
438 return SlashIndex > -1 ? Jid.Substring(0, SlashIndex) : Jid;
439 }
440
441 private async Task Contracts_ContractProposalRecieved(object? sender, ContractProposalEventArgs e)
442 {
443 try
444 {
445 Contract Contract = await ServiceRef.XmppService.GetContract(e.ContractId);
446
448 {
449 await Task.Delay(500);
450 }
451 await Task.Delay(500);
452
453 await ServiceRef.NavigationService.GoToAsync(nameof(ViewContractPage), new ViewContractNavigationArgs(
454 Contract, false, e.Role, e.MessageText, e.FromBareJID));
455 }
456 catch (Exception ex)
457 {
458 ServiceRef.LogService.LogException(ex);
459 }
460 }
461
462 private async Task Contracts_ConnectionStateChanged(object _, XmppState NewState)
463 {
464 /*
465 try
466 {
467 if (ServiceRef.XmppService.IsOnline &&
468 ServiceRef.TagProfile.IsCompleteOrWaitingForValidation())
469 {
470 if (ServiceRef.TagProfile.LegalIdentity is not null)
471 {
472 Task FireAndForget = Task.Run( async () =>
473 {
474 try
475 {
476 await Task.Delay(Constants.Timeouts.XmppInit);
477 await ReDownloadLegalIdentity();
478 }
479 catch (Exception ex)
480 {
481 ServiceRef.LogService.LogException(ex);
482 }
483 });
484 }
485 }
486 }
487 catch (Exception ex)
488 {
489 ServiceRef.LogService.LogException(ex);
490 }
491 */
492
493 }
494
495 #endregion
496
497 protected static async Task ReDownloadLegalIdentity()
498 {
499 if (ServiceRef.XmppService is null ||
500 !await ServiceRef.XmppService.WaitForConnectedState(Constants.Timeouts.XmppConnect) ||
501 !ServiceRef.XmppService.IsOnline ||
502 ServiceRef.TagProfile.LegalIdentity is null)
503 {
504 return;
505 }
506
507 LegalIdentity? Identity;
508
509 try
510 {
511 Identity = await ServiceRef.XmppService!.GetLegalIdentity(ServiceRef.TagProfile.LegalIdentity.Id);
512 }
513 catch (ForbiddenException) // Old ID belonging to a previous account, for example. Simply discard.
514 {
515 await ServiceRef.TagProfile.ClearLegalIdentity();
516 await ServiceRef.NavigationService.GoToAsync(nameof(OnboardingPage), new OnboardingNavigationArgs() { Scenario = OnboardingScenario.FullSetup });
517 return;
518 }
519 catch (Exception ex)
520 {
521 ServiceRef.LogService.LogException(ex);
522 return;
523 }
524
525 if (Identity is not null)
526 {
527 MainThread.BeginInvokeOnMainThread(async () =>
528 {
529 try
530 {
531
532 string? UserMessage = null;
533 bool GotoRegistrationPage = false;
534
535 if (Identity.State == IdentityState.Compromised)
536 {
537 UserMessage = ServiceRef.Localizer[nameof(AppResources.YourLegalIdentityHasBeenCompromised)];
538 await ServiceRef.TagProfile.CompromiseLegalIdentity(Identity);
539 GotoRegistrationPage = true;
540 }
541 else if (Identity.State == IdentityState.Obsoleted)
542 {
543 UserMessage = ServiceRef.Localizer[nameof(AppResources.YourLegalIdentityHasBeenObsoleted)];
544 await ServiceRef.TagProfile.RevokeLegalIdentity(Identity);
545 GotoRegistrationPage = true;
546 }
547 else if (Identity.State == IdentityState.Approved)
548 {
549 bool HasPrivateKeys = false;
550 try
551 {
552 HasPrivateKeys = await ServiceRef.XmppService.HasPrivateKey(Identity.Id);
553
554 }
555 catch (Exception Ex)
556 {
557 ServiceRef.LogService.LogException(Ex);
558 }
559
560 if (HasPrivateKeys)
561 {
562 await ServiceRef.TagProfile.SetLegalIdentity(Identity, true);
563 return;
564 }
565
566 bool Response = await ServiceRef.UiService.DisplayAlert(
571
572 if (Response)
573 await ServiceRef.TagProfile.SetLegalIdentity(Identity, true);
574 else
575 {
576 try
577 {
578 File.WriteAllText(Path.Combine(ServiceRef.StorageService.DataFolder, "Start.txt"),
579 DateTime.Now.AddHours(1).Ticks.ToString(CultureInfo.InvariantCulture));
580 }
581 catch (Exception ex)
582 {
583 ServiceRef.LogService.LogException(ex);
584 }
585
586 await App.StopAsync();
587 return;
588 }
589 }
590 else
591 await ServiceRef.TagProfile.SetLegalIdentity(Identity, true);
592
593 if (GotoRegistrationPage)
594 {
595 //await App.SetRegistrationPageAsync();
596
597 // After navigating to the registration page, show the user why this happened.
598 if (!string.IsNullOrWhiteSpace(UserMessage))
599 {
600 // Do a begin invoke here so the page animation has time to finish,
601 // and the view model loads state et.c. before showing the alert.
602 // This gives a better UX experience.
603 MainThread.BeginInvokeOnMainThread(async () =>
604 {
606 ServiceRef.Localizer[nameof(AppResources.YourLegalIdentity)], UserMessage);
607 });
608 }
609 }
610 }
611 catch (Exception E)
612 {
613 ServiceRef.LogService.LogException(E);
614 }
615 });
616 }
617 }
618
624 public async Task OpenLegalIdentity(string LegalId, string Purpose)
625 {
626 try
627 {
628 bool Connected = await ServiceRef.XmppService.WaitForConnectedState(Constants.Timeouts.XmppConnect);
629
630 if (!Connected)
631 throw new TimeoutException();
632
633 LegalIdentity Identity = await ServiceRef.XmppService.GetLegalIdentity(LegalId);
634 MainThread.BeginInvokeOnMainThread(async () =>
635 {
636 await ServiceRef.NavigationService.GoToAsync(nameof(ViewIdentityPage), new ViewIdentityNavigationArgs(Identity));
637 });
638 }
639 catch (ForbiddenException)
640 {
641 // This happens if you try to view someone else's legal identity.
642 // When this happens, try to send a petition to view it instead.
643 // Normal operation. Should not be logged.
644
645 MainThread.BeginInvokeOnMainThread(async () =>
646 {
647 bool Succeeded = await ServiceRef.NetworkService.TryRequest(() => ServiceRef.XmppService.PetitionIdentity(LegalId, Guid.NewGuid().ToString(), Purpose));
648 if (Succeeded)
649 {
653 }
654 });
655 }
656 catch (TimeoutException)
657 {
662 }
663 catch (Exception ex)
664 {
665 ServiceRef.LogService.LogException(ex, this.GetClassAndMethod(MethodBase.GetCurrentMethod()));
670 }
671 }
672
679 public async Task<LegalIdentity?> TryGetLegalIdentity(string LegalId, string Purpose)
680 {
681 try
682 {
683 LegalIdentity Identity = await ServiceRef.XmppService.GetLegalIdentity(LegalId);
684 return Identity;
685 }
686 catch (ForbiddenException)
687 {
688 // This happens if you try to view someone else's legal identity.
689 // When this happens, try to send a petition to view it instead.
690 // Normal operation. Should not be logged.
691 if (!string.IsNullOrEmpty(Purpose))
692 await ServiceRef.XmppService.PetitionIdentity(LegalId, Guid.NewGuid().ToString(), Purpose);
693 return null;
694 }
695 catch (Exception ex)
696 {
697 ServiceRef.LogService.LogException(ex, this.GetClassAndMethod(MethodBase.GetCurrentMethod()));
698 return null;
699 }
700 }
701
708 public async Task OpenContract(string ContractId, string Purpose, Dictionary<CaseInsensitiveString, object>? ParameterValues)
709 {
710 try
711 {
712 Contract Contract = await ServiceRef.XmppService.GetContract(ContractId);
713
714 ContractReference Ref = await Database.FindFirstDeleteRest<ContractReference>(
715 new FilterFieldEqualTo("ContractId", Contract.ContractId));
716
717 if (Ref is not null)
718 {
719 if (Ref.Updated != Contract.Updated || !Ref.ContractLoaded)
720 {
721 await Ref.SetContract(Contract);
722 await Database.Update(Ref);
723 }
724
725 ServiceRef.TagProfile.CheckContractReference(Ref);
726 }
727
728 MainThread.BeginInvokeOnMainThread(async () =>
729 {
730 if (Contract.PartsMode == ContractParts.TemplateOnly && Contract.State == ContractState.Approved)
731 {
732 if (Ref is null)
733 {
734 Ref = new()
735 {
736 ContractId = Contract.ContractId
737 };
738
739 await Ref.SetContract(Contract);
740 await Database.Insert(Ref);
741
742 ServiceRef.TagProfile.CheckContractReference(Ref);
743 }
746 {
747 CreationAttributesEventArgs CreationAttr = await ServiceRef.XmppService.GetNeuroFeatureCreationAttributes();
748 ServiceRef.TagProfile.TrustProviderId = CreationAttr.TrustProviderId;
749 ParameterValues ??= [];
750 ParameterValues.TryAdd(new CaseInsensitiveString("TrustProvider"), CreationAttr.TrustProviderId);
751 ParameterValues.TryAdd(new CaseInsensitiveString("Currency"), CreationAttr.Currency);
752 ParameterValues.TryAdd(new CaseInsensitiveString("CommissionPercent"), CreationAttr.Commission);
753 }
754
755 NewContractNavigationArgs e = new(Contract, ParameterValues);
756
757 await ServiceRef.NavigationService.GoToAsync(nameof(NewContractPage), e, BackMethod.CurrentPage);
758 }
759 else
760 {
761 ViewContractNavigationArgs e = new(Contract, false);
762
764 }
765 });
766 }
767 catch (ForbiddenException)
768 {
769 // This happens if you try to view someone else's contract.
770 // When this happens, try to send a petition to view it instead.
771 // Normal operation. Should not be logged.
772
773 MainThread.BeginInvokeOnMainThread(async () =>
774 {
775 bool Succeeded = await ServiceRef.NetworkService.TryRequest(() =>
776 ServiceRef.XmppService.PetitionContract(ContractId, Guid.NewGuid().ToString(), Purpose));
777
778 if (Succeeded)
779 {
782 }
783 });
784 }
785 catch (Exception ex)
786 {
787 ServiceRef.LogService.LogException(ex, this.GetClassAndMethod(MethodBase.GetCurrentMethod()));
789 }
790 }
791
796 public async Task TagSignature(string Request)
797 {
798 int i = Request.IndexOf(',');
799
800 if (i < 0)
801 throw new InvalidOperationException(ServiceRef.Localizer[nameof(AppResources.InvalidTagSignatureId)]);
802
803 string JID = System.Web.HttpUtility.UrlDecode(Request[..i]);
804 string Key = Request[(i + 1)..];
805
806 LegalIdentity? ID = ServiceRef.TagProfile.LegalIdentity;
807
808 if (ID is null)
809 {
810 await ServiceRef.Provider.GetRequiredService<UiService>().DisplayAlert(
813 return;
814 }
815
816 if (ID.State != IdentityState.Approved)
817 {
818 await ServiceRef.Provider.GetRequiredService<UiService>().DisplayAlert(
821 return;
822 }
823
824 string IdRef = ServiceRef.TagProfile.LegalIdentity?.Id ?? string.Empty;
825
826 StringBuilder Xml = new();
827
828 Xml.Append("<ql xmlns='https://tagroot.io/schema/Signature' key='");
829 Xml.Append(XML.Encode(Key));
830 Xml.Append("' legalId='");
831 Xml.Append(XML.Encode(IdRef));
832 Xml.Append("'/>");
833
834 if (!ServiceRef.XmppService.IsOnline &&
835 !await ServiceRef.XmppService.WaitForConnectedState(TimeSpan.FromSeconds(10)))
836 {
837 throw new InvalidOperationException(ServiceRef.Localizer[nameof(AppResources.AppNotConnected)]);
838 }
839
840 await ServiceRef.XmppService.IqSetAsync(JID, Xml.ToString());
841 }
842
843 private async Task Contracts_SignaturePetitionResponseReceived(object? Sender, SignaturePetitionResponseEventArgs e)
844 {
845 try
846 {
847 LegalIdentity Identity = e.RequestedIdentity;
848
849 if (!e.Response || Identity is null)
850 {
855 }
856 else
857 await ServiceRef.NavigationService.GoToAsync(nameof(ViewIdentityPage), new ViewIdentityNavigationArgs(Identity));
858 }
859 catch (Exception ex)
860 {
861 ServiceRef.LogService.LogException(ex);
862 }
863 }
864 }
865}
Represents an instance of the Neuro-Access app.
Definition: App.xaml.cs:125
Machine-readable names in contracts.
Definition: Constants.cs:938
const string PaymentInstructionsNamespace
Namespace for payment instructions
Definition: Constants.cs:942
const string Petitions
Petitions channel
Definition: Constants.cs:744
static readonly TimeSpan XmppConnect
XMPP Connect timeout
Definition: Constants.cs:702
const string PersonalNumber
Personal number
Definition: Constants.cs:394
const string OrgAddress2
Organization Address line 2
Definition: Constants.cs:474
const string OrgArea
Organization Area
Definition: Constants.cs:479
const string OrgRegion
Organization Region
Definition: Constants.cs:494
const string Nationality
Nationality
Definition: Constants.cs:434
const string BirthYear
Birth Year
Definition: Constants.cs:454
const string OrgCity
Organization City
Definition: Constants.cs:484
const string OrgRole
Organization Role
Definition: Constants.cs:509
const string Phone
Phone number
Definition: Constants.cs:524
const string EMail
e-Mail address
Definition: Constants.cs:529
const string OrgZipCode
Organization Zip Code
Definition: Constants.cs:489
const string MiddleNames
Middle names
Definition: Constants.cs:379
const string OrgCountry
Organization Country
Definition: Constants.cs:499
const string OrgDepartment
Organization Department
Definition: Constants.cs:504
const string Address2
Address line 2
Definition: Constants.cs:404
const string OrgAddress
Organization Address line 1
Definition: Constants.cs:469
const string Address
Address line 1
Definition: Constants.cs:399
const string LastNames
Last names
Definition: Constants.cs:384
const string OrgNumber
Organization number
Definition: Constants.cs:464
const string BirthMonth
Birth Month
Definition: Constants.cs:449
const string FirstName
First name
Definition: Constants.cs:374
const string OrgName
Organization name
Definition: Constants.cs:459
A set of never changing property constants and helpful values.
Definition: Constants.cs:24
A strongly-typed resource class, for looking up localized strings, etc.
static string YourLegalIdentity
Looks up a localized string similar to Your identity.
static string NotificationPetitionSignatureBody
Looks up a localized string similar to A new signature request is waiting..
static string AppNotConnected
Looks up a localized string similar to App is not connected to the network..
static string APetitionHasBeenSentToTheOwner
Looks up a localized string similar to A petition has been sent to the owner of the identity....
static string NotificationPetitionIdentityBody
Looks up a localized string similar to A new identity request is waiting..
static string APeerYouRequestedToReviewHasBeenRejectedDueToSignatureError
Looks up a localized string similar to A peer review you requested has been rejected,...
static string NotificationPetitionIdentityTitle
Looks up a localized string similar to Identity request from {0}.
static string Repair
Looks up a localized string similar to Repair.
static string PeerReviewRejected
Looks up a localized string similar to Peer review rejected.
static string PleaseTryAgain
Looks up a localized string similar to Please Try Again.
static string NotCompletedOnboardingError
Looks up a localized string similar to It looks like you haven’t completed the onboarding process yet...
static string Continue
Looks up a localized string similar to Continue.
static string SignaturePetitionDenied
Looks up a localized string similar to The signature petition was denied..
static string PeerReviewAccepted
Looks up a localized string similar to Peer review accepted.
static string PetitionSent
Looks up a localized string similar to Petition sent.
static string WarningTitle
Looks up a localized string similar to Warning.
static string Ok
Looks up a localized string similar to OK.
static string PetitionToViewLegalIdentityWasDenied
Looks up a localized string similar to Petition to view identity was denied..
static string LegalIdNotApproved
Looks up a localized string similar to ID not approved..
static string SomethingWentWrong
Looks up a localized string similar to Something went wrong.
static string APeerYouRequestedToReviewHasRejected
Looks up a localized string similar to A peer you requested to review your application,...
static string NotificationPetitionSignatureTitle
Looks up a localized string similar to Signature request from {0}.
static string InvalidTagSignatureId
Looks up a localized string similar to Invalid TAG Signature URI..
static string Message
Looks up a localized string similar to Message.
static string APetitionHasBeenSentToTheContract
Looks up a localized string similar to A petition has been sent to the parts of the contract....
static string ErrorTitle
Looks up a localized string similar to An error has occurred.
static string APeerReviewYouhaveRequestedHasBeenAccepted
Looks up a localized string similar to A peer review you requested has been accepted....
static string UnableToGetAccessToYourPrivateKeys
Looks up a localized string similar to The application was unable to get access to the private keys o...
bool BeginLoad(bool IsResuming, CancellationToken CancellationToken)
Sets the IsLoading flag if the service isn't already loading.
void EndLoad(bool isLoaded)
Sets the IsLoading and IsLoaded flags and fires an event representing the current load state of the s...
bool IsResuming
If App is resuming service.
bool BeginUnload()
Sets the IsLoading flag if the service isn't already unloading.
void EndUnload()
Sets the IsLoading and IsLoaded flags and fires an event representing the current load state of the s...
Platform-neutral intent describing how to route a notification.
Dictionary< string, string > Extras
Gets or sets extra data used for routing.
Base class that references services in the app.
Definition: ServiceRef.cs:43
static IServiceProvider Provider
The service provider for the app. This is set before the app is started, and will be used to resolve ...
Definition: ServiceRef.cs:48
static ILogService LogService
Log service.
Definition: ServiceRef.cs:214
static INetworkService NetworkService
Network service.
Definition: ServiceRef.cs:226
static IUiService UiService
Service serializing and managing UI-related tasks.
Definition: ServiceRef.cs:130
static INavigationService NavigationService
The navigation service for navigating between pages.
Definition: ServiceRef.cs:178
static ITagProfile TagProfile
TAG Profile service.
Definition: ServiceRef.cs:202
static IReportingStringLocalizer Localizer
Localization service
Definition: ServiceRef.cs:370
static IXmppService XmppService
The XMPP service for XMPP communication.
Definition: ServiceRef.cs:190
A page that allows the user to create a new contract.
A page to display when the user wants to view an identity.
Navigation arguments for onboarding flow. Scenario determines dynamic starting step.
A page to display when the user is asked to petition an identity.
A page to display when the user is asked to review an identity application.
Holds navigation parameters specific to views displaying a petition of a signature.
A page to display when the user is asked to petition a signature.
Event arguments for callback methods to token creation attributes queries.
string TrustProviderId
Legal ID used by the trust provider to sign contracts.
decimal Commission
Minimum commission (in %) expected by the trust provider, in order to sign contract.
const string NamespaceNeuroFeatures
Namespace for Neuro-Features.
Helps with common XML-related tasks.
Definition: XML.cs:21
static string Encode(string s)
Encodes a string for use in XML.
Definition: XML.cs:29
Contains the definition of a contract
Definition: Contract.cs:22
DateTime Updated
When the contract was last updated
Definition: Contract.cs:139
ContractParts PartsMode
How parts are defined in the smart contract.
Definition: Contract.cs:249
ContractState State
Contract state
Definition: Contract.cs:121
string ContractId
Contract identity
Definition: Contract.cs:65
string ForMachinesNamespace
Namespace used by the root node of the machine-readable contents of the contract (ForMachines).
Definition: Contract.cs:289
LegalIdentity RequestorIdentity
Legal Identity of requesting entity.
LegalIdentity RequestedIdentity
Requested identity, if accepted, null if rejected.
Abstract base class of signatures
Definition: Signature.cs:10
string FromBareJID
Bare JID of resource sending the message.
The requesting entity does not possess the necessary permissions to perform an action that only certa...
Represents a case-insensitive string.
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:21
static async Task Update(object Object)
Updates an object in the database.
Definition: Database.cs:1211
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
Definition: Database.cs:97
This filter selects objects that have a named field equal to a given value.
Orchestrates operations on contracts upon receiving certain events, like approving or rejecting other...
Interface for the redesigned notification service.
Task GoToAsync(string Route)
Navigates to the specified route and pushes the page onto the navigation stack.
BaseContentPage? CurrentPage
Gets the current visible view.
Task DisplayException(Exception Exception, string? Title=null)
Displays an alert/message box to the user.
Task< bool > DisplayAlert(string Title, string Message, string? Accept=null, string? Cancel=null)
Displays an alert/message box to the user.
Service responsible for presenting and dismissing application popups.
Definition: ImplTypes.g.cs:58
NotificationAction
Actions that can be routed from notifications.
NotificationSource
Describes the source producing a notification.
BackMethod
Navigation Back Method
Definition: BackMethod.cs:7
IdentityState
Lists recognized legal identity states.
SignWith
Options on what keys to use when signing data.
Definition: Enumerations.cs:82
ContractParts
How the parts of the contract are defined.
Definition: Part.cs:9
ContractState
Recognized contract states
Definition: Enumerations.cs:7
XmppState
State of XMPP connection.
Definition: XmppState.cs:7