5using System.Threading.Tasks;
33 return Task.CompletedTask;
41 return Task.CompletedTask;
51 foreach (KeyValuePair<string, object> Claim
in Application.Claims)
55 if (!(Claim.Value is
string s) ||
string.IsNullOrEmpty(s))
56 return Grade.NotAtAll;
58 if (!Guid.TryParse(s, out
_))
59 return Grade.NotAtAll;
64 return File.Exists(FileName) ? Grade.Perfect :
Grade.NotAtAll;
69 return Grade.NotAtAll;
74 return Grade.NotAtAll;
86 string PreviewId =
null;
88 foreach (KeyValuePair<string, object> Claim
in Application.Claims)
93 if (!(Claim.Value is
string s) ||
94 string.IsNullOrEmpty(s) ||
95 !Guid.TryParse(s, out
_))
97 Application.ReportError(
"Invalid preview identifier.",
"en",
string.Empty,
106 KeyValuePair<LegalIdentity, bool> P = await
LegalComponent.GetLocalLegalIdentity(PreviewId,
true);
107 Dictionary<string, string> PotentialClaims =
new Dictionary<string, string>();
109 bool Preview = P.Value;
112 if (!Preview || Identity is
null)
119 PreviewFileNames.Add(
LegalComponent.GetPreviewFileName(Identity.
Id,
".id"));
125 if (Ref.
FileName ==
"ApplicationReview.xml")
130 using MemoryStream ms =
new MemoryStream(Bin);
131 XmlDocument Doc =
new XmlDocument();
134 if (Doc.DocumentElement.LocalName !=
"identityReview" ||
143 Networking.XMPP.Contracts.ContractsClient.ParseValidationDetails(
144 Doc.DocumentElement, e);
148 foreach (Networking.XMPP.Contracts.PotentialClaim Claim in
151 PotentialClaims[Claim.Claim] = Claim.Value;
165 foreach (KeyValuePair<string, object> Claim
in Application.Claims)
179 string ClaimValue = Claim.Value?.ToString() ??
string.Empty;
180 string Value = Identity[Claim.Key];
182 if (
string.IsNullOrEmpty(Value))
184 if (!PotentialClaims.TryGetValue(Claim.Key, out Value))
188 if (Value == ClaimValue)
189 Application.ClaimValid(Claim.Key,
this);
192 Application.ClaimInvalid(Claim.Key,
193 "Does not match previewed value.",
"en",
"PreviewMismatch",
205 string AttachmentFileName =
LegalComponent.GetPreviewFileName(Ref.
Id,
".att");
207 if (!File.Exists(AttachmentFileName))
209 Application.PhotoInvalid(
Photo,
210 "Previewed attachment not found.",
"en",
"PreviewMismatch",
215 KeyValuePair<byte[], string> P2 = await
LegalComponent.GetPreviewSalt(AttachmentFileName);
219 using MemoryStream ms =
new MemoryStream(Blob);
221 byte[] Data = await Decoded.ReadAllAsync();
224 Convert.ToBase64String(Data) == Convert.ToBase64String(
Photo.
Binary))
226 Application.PhotoValid(
Photo,
this);
230 Application.PhotoInvalid(
Photo,
231 "Does not match previewed photo.",
"en",
"PreviewMismatch",
240 if (Application.IsValid.HasValue &&
241 Application.IsValid.Value &&
242 PreviewFileNames.HasFirstItem)
244 foreach (
string FileName
in PreviewFileNames)
248 if (File.Exists(FileName))
249 File.Delete(FileName);
262 Application.ReportError(ex.Message,
string.Empty,
string.Empty,
Represents a photo in an identity application.
string FileName
File Name of photo.
byte[] Binary
Binary representation of photo.
Static class managing the application event log. Applications and services log events on this static ...
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.
Identity Review event arguments.
bool HasPotentialClaims
If potential claims are reported.
PotentialClaim[] PotentialClaims
Potential claims.
A chunked list is a linked list of chunks of objects of type T .
Represents an attachment to a document.
string FileName
Filename of attachment.
CaseInsensitiveString Id
Attachment ID
CaseInsensitiveString Id
ID of the legal identity
Validates identity applications that reference an earlier preview application.
PreviewAuthenticator()
Validates identity applications that reference an earlier preview application.
Task Start()
Starts the module.
async Task Validate(IIdentityApplication Application)
Validates an identity application.
Grade Supports(IIdentityApplication Application)
Checks how well the authenticator supports the provided identity application.
Task Stop()
Stops the module.
Legal (digital identities, smart contracts) service component.
static bool IsNamespaceLegalIdentity(string Namespace)
If a namespace corresponds to a legal identity namespace.
Service Module hosting the XMPP broker and its components.
static Task< byte[]> LoadEncryptedFile(string FileName, byte[] Salt)
Loads an encrypted file.
static async Task< Stream > DecodeBlob(Stream Data)
Decodes a variable-length BLOB encoded by the EncodeBlob method. The length prefix is read first,...
Interface for identity applications.
Interface for identity application authenticator services.
ValidationErrorType
Type of validation error.