2using System.Collections.Generic;
4using System.Text.RegularExpressions;
5using System.Threading.Tasks;
19 [CollectionName(
"BrokerAccounts")]
21 [ObsoleteMethod(nameof(ObsoleteProperties))]
24 [Index(
"ApiKey",
"UserName")]
25 [Index(
"EMail",
"UserName")]
26 [Index(
"PhoneNr",
"UserName")]
29 internal static readonly Regex FromSaveUnsaved =
new Regex(
@"Waher[.]Persistence[.]Files[.]ObjectBTreeFile[.+]<SaveUnsaved>\w*[.]\w*",
30 RegexOptions.Compiled | RegexOptions.Singleline);
31 internal static readonly Regex FromUpdateObject =
new Regex(
@"Waher[.]Persistence[.]Files[.]ObjectBTreeFile[.+]<UpdateObject>\w*[.]\w*",
32 RegexOptions.Compiled | RegexOptions.Singleline);
33 private static readonly
object[] approvedSources =
new object[]
38 typeof(Persistence.NeuroLedger.NeuroLedgerProvider),
39 typeof(Networking.SASL.AuthenticationMechanism).Assembly,
40 typeof(Content.Markdown.Web.MarkdownToHtmlConverter),
45 private string objectId =
null;
46 private string apiKey =
string.Empty;
48 private string password =
string.
Empty;
62 private bool enabled =
true;
63 private bool canRelayMessages =
false;
64 private DateTime created = DateTime.MinValue;
65 private DateTime? eMailVerified =
null;
66 private DateTime? phoneNrVerified =
null;
83 set => this.objectId = value;
92 set => this.apiKey = value;
100 get => this.userName;
101 set => this.userName = value;
107 [DefaultValueStringEmpty]
113 return this.password;
118 if (!
string.IsNullOrEmpty(this.password))
121 this.password = value;
131 set => this.eMail = value;
140 set => this.phoneNr = value;
147 [DefaultValueStringEmpty]
150 get => this.latestIdentity;
151 set => this.latestIdentity = value;
157 [DefaultValueStringEmpty]
160 get => this.firstName;
161 set => this.firstName = value;
167 [DefaultValueStringEmpty]
170 get => this.middleNames;
171 set => this.middleNames = value;
177 [DefaultValueStringEmpty]
180 get => this.lastNames;
181 set => this.lastNames = value;
187 [DefaultValueStringEmpty]
190 get => this.personalNumber;
191 set => this.personalNumber = value;
197 [DefaultValueStringEmpty]
201 set => this.country = value;
207 [DefaultValueStringEmpty]
210 get => this.orgNumber;
211 set => this.orgNumber = value;
217 [DefaultValueStringEmpty]
221 set => this.orgName = value;
227 [DefaultValueStringEmpty]
231 set => this.orgRole = value;
237 [DefaultValueStringEmpty]
240 get => this.orgDepartment;
241 set => this.orgDepartment = value;
247 [DefaultValueStringEmpty]
250 get => this.orgCountry;
251 set => this.orgCountry = value;
257 [DefaultValueDateTimeMinValue]
261 set => this.created = value;
269 get => this.eMailVerified;
270 set => this.eMailVerified = value;
278 get => this.phoneNrVerified;
279 set => this.phoneNrVerified = value;
289 set => this.enabled = value;
295 [DefaultValue(
false)]
298 get => this.canRelayMessages;
299 set => this.canRelayMessages = value;
312 default:
return false;
325 bool Updated =
false;
327 if (
string.IsNullOrEmpty(Login.RemoteEndpoint) &&
328 Properties.TryGetValue(
"RemoteEndpoint", out
object Obj) &&
329 Obj is
string RemoteEndpoint)
331 Login.RemoteEndpoint = RemoteEndpoint;
335 if (Login.LastLogin == DateTime.MinValue &&
336 Properties.TryGetValue(
"LastLogin", out Obj) &&
337 Obj is DateTime LastLogin)
339 Login.LastLogin = LastLogin;
360 Login.LastLogin = DateTime.Now;
361 Login.RemoteEndpoint = RemoteEndpoint;
372 if (!(this.accountLogin is
null))
373 return this.accountLogin;
376 if (!(this.accountLogin is
null))
377 return this.accountLogin;
382 RemoteEndpoint =
string.
Empty,
383 LastLogin = DateTime.MinValue
388 return this.accountLogin;
394 public string FullName => Concat(
" ", this.firstName, this.middleNames, this.lastNames);
404 public string OrganizationInformation => Concat(
", ", this.orgRole, this.orgDepartment, this.orgName, this.orgNumber, this.orgCountry);
408 StringBuilder sb =
new StringBuilder();
411 foreach (
string Segment
in Segments)
412 Append(sb, ref First, Segment, Delimiter);
414 return sb.ToString();
417 private static void Append(StringBuilder sb, ref
bool First,
CaseInsensitiveString Segment,
string Delimiter)
419 if (!
string.IsNullOrEmpty(Segment))
424 sb.Append(Delimiter);
426 sb.Append(Segment.
Value);
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.
Implements a simple SMTP Server, as defined in:
const string SmtpRelayPrivilegeID
SmtpRelay
Represents a case-insensitive string.
string Value
String-representation of the case-insensitive string. (Representation is case sensitive....
static readonly CaseInsensitiveString Empty
Empty case-insensitive string
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static async Task InsertLazy(object Object)
Inserts an object into the database, if unlocked. If locked, object will be inserted at next opportun...
static async Task UpdateLazy(object Object)
Updates an object in the database, if unlocked. If locked, object will be updated at next opportunity...
This filter selects objects that have a named field equal to a given value.
Static class containing methods that can be used to make sure calls are made from appropriate locatio...
static void CallFromSource(params string[] Sources)
Makes sure the call is made from one of the listed sources.
Contains information about a broker account.
DateTime? PhoneNrVerified
When Phone Number was verified.
CaseInsensitiveString PersonalNumber
Phone Number associated with account holder.
CaseInsensitiveString EMail
E-mail address associated with account.
CaseInsensitiveString UserName
User Name of account
bool Enabled
If account is enabled
CaseInsensitiveString OrgRole
Organization role associated with account holder.
async void ObsoleteProperties(Dictionary< string, object > Properties)
Method called when loading the object and properties were found that are no longer recognized.
CaseInsensitiveString FirstName
First name associated with account holder.
string PersonalInformation
Personal information of account holder.
async Task< AccountLogin > GetAccountLogin()
Gets the object with the associated account login status information.
DateTime? EMailVerified
When e-Mail was verified.
string Password
Password of account
CaseInsensitiveString Country
Country code associated with account holder.
bool HasPrivilege(string PrivilegeID)
If account has a certain privilege.
string OrganizationInformation
Organizational information of account holder.
CaseInsensitiveString LastNames
Last name(s) associated with account holder.
CaseInsensitiveString PhoneNr
Phone number associated with account.
Account()
Contains information about a broker account.
CaseInsensitiveString OrgDepartment
Organization department associated with account holder.
bool CanRelayMessages
If account is allowed to relay e-mail messages
CaseInsensitiveString OrgNumber
Organization number associated with account holder.
string FullName
Full name of account holder.
async Task LoggedIn(string RemoteEndpoint)
Registers a log-in event on the account.
DateTime Created
When account was created associated with account holder.
CaseInsensitiveString OrgName
Organization name associated with account holder.
CaseInsensitiveString OrgCountry
Country code of organization associated with account holder.
CaseInsensitiveString MiddleNames
Middle name(s) associated with account holder.
CaseInsensitiveString LatestIdentity
Last Legal Identity approved for account. Note: Identity object might not be approved any longer.
Service Module hosting the XMPP broker and its components.
Interface for XMPP user accounts.
TypeNameSerialization
How the type name should be serialized.