4using System.Reflection;
6using System.Threading.Tasks;
40 private readonly Dictionary<string, Wallet> wallets =
new Dictionary<string, Wallet>();
43 private string defaultCurrency =
null;
63 this.
RegisterIqGetHandler(
"buyEDalerProviders", NamespaceEDaler, this.GetBuyEDalerProvidersHandler,
false);
64 this.
RegisterIqSetHandler(
"initiateGetOptionsBuyEDaler", NamespaceEDaler, this.InitiateGetOptionsBuyEDalerHandler,
false);
65 this.
RegisterIqSetHandler(
"initiateBuyEDaler", NamespaceEDaler, this.InitiateBuyEDalerHandler,
false);
66 this.
RegisterIqGetHandler(
"sellEDalerProviders", NamespaceEDaler, this.GetSellEDalerProvidersHandler,
false);
67 this.
RegisterIqSetHandler(
"initiateGetOptionsSellEDaler", NamespaceEDaler, this.InitiateGetOptionsSellEDalerHandler,
false);
68 this.
RegisterIqSetHandler(
"initiateSellEDaler", NamespaceEDaler, this.InitiateSellEDalerHandler,
false);
79 this.transactions.Dispose();
87 this.
UnregisterIqGetHandler(
"buyEDalerProviders", NamespaceEDaler, this.GetBuyEDalerProvidersHandler,
false);
88 this.
UnregisterIqSetHandler(
"initiateGetOptionsBuyEDaler", NamespaceEDaler, this.InitiateGetOptionsBuyEDalerHandler,
false);
90 this.
UnregisterIqGetHandler(
"sellEDalerProviders", NamespaceEDaler, this.GetSellEDalerProvidersHandler,
false);
91 this.
UnregisterIqSetHandler(
"initiateGetOptionsSellEDaler", NamespaceEDaler, this.InitiateGetOptionsSellEDalerHandler,
false);
116 return this.defaultCurrency;
121 string Key = AccountName.LowerCase +
"@" + Domain.
LowerCase;
126 if (this.wallets.TryGetValue(Key, out
Wallet))
130 bool Created =
false;
144 Account = AccountName,
147 Created = DateTime.Now
152 else if (
string.IsNullOrEmpty(
Wallet.Currency))
160 if (this.wallets.TryGetValue(Key, out
Wallet Wallet2))
163 this.wallets[Key] =
Wallet;
172 private async Task GetWalletBalanceHandler(
object Sender,
IqEventArgs e)
176 await e.
IqErrorForbidden(e.
To,
"Access to wallet only granted to accounts on broker.",
"en");
184 await e.
IqErrorForbidden(e.
To,
"Access to wallet only granted to accounts on broker.",
"en");
199 Wallet Wallet = await this.GetWallet(AccountName, Domain);
200 StringBuilder Xml =
new StringBuilder();
202 Xml.Append(
"<balance xmlns='");
204 Xml.Append(
"' amount='");
209 Xml.Append(
"' reserved='");
213 Xml.Append(
"' currency='");
215 Xml.Append(
"' timestamp='");
224 Xml.Append(
"</balance>");
230 public static bool IsValidCurrencySymbol(
string Currency)
232 if (Currency.Length > 5)
235 Currency = Currency.ToUpper();
237 foreach (
char ch
in Currency)
239 if (ch < 'A' || ch >
'Z')
246 public static Task<string> GenerateIssueUrl(decimal Amount,
string Currency,
int ExpiresDays,
string FreeText,
249 return GenerateIssueUrl(
string.Empty, Amount, Currency, ExpiresDays, FreeText, ManagerPassword, Request,
User);
252 public static async Task<string> GenerateIssueUrl(
string To, decimal Amount,
string Currency,
int ExpiresDays,
string FreeText,
255 if (
User is
null || !(
User?.HasPrivilege(
"Admin.eDaler.Generate") ??
false))
258 string Uri = await GenerateUrl(To, Amount, Currency, ExpiresDays, FreeText, ManagerPassword, Request,
User,
"is",
true);
259 KeyValuePair<string, object>[] Tags = await GetTags(Amount, Currency, ExpiresDays, FreeText, Request);
267 public static async Task<string> GenerateDestroyUrl(decimal Amount,
string Currency,
int ExpiresDays,
string FreeText,
270 if (
User is
null || !(
User?.HasPrivilege(
"Admin.eDaler.Destroy") ??
false))
273 string Uri = await GenerateUrl(
string.Empty, Amount, Currency, ExpiresDays, FreeText, ManagerPassword, Request,
User,
"xx",
false);
274 KeyValuePair<string, object>[] Tags = await GetTags(Amount, Currency, ExpiresDays, FreeText, Request);
282 private async
static Task<KeyValuePair<string, object>[]> GetTags(decimal Amount,
string Currency,
int ExpiresDays,
string FreeText,
HttpRequest Request)
285 new KeyValuePair<string, object>(
"Amount", Amount),
286 new KeyValuePair<string, object>(
"Currency", Currency),
287 new KeyValuePair<string, object>(
"ExpiresDays", ExpiresDays),
288 new KeyValuePair<string, object>(
"FreeText", FreeText),
289 new KeyValuePair<string, object>(
"RemoteEndpoint", Request.
RemoteEndPoint));
292 private static async Task<string> GenerateUrl(
string To, decimal Amount,
string Currency,
int ExpiresDays,
string FreeText,
string ManagerPassword,
296 throw new ArgumentException(
"Amount must be positive.", nameof(Amount));
298 if (
string.IsNullOrEmpty(Currency))
299 throw new ArgumentException(
"No currency specified.");
301 if (!IsValidCurrencySymbol(Currency))
302 throw new ArgumentException(
"Invalid currency symbol.");
304 if (ExpiresDays <= 0)
305 throw new ArgumentException(
"Expiry interval must be positive.", nameof(Amount));
307 if (
string.IsNullOrEmpty(FreeText))
308 throw new ArgumentException(
"No free text specified.");
320 StringBuilder sb =
new StringBuilder();
322 sb.Append(
"This endpoint (");
324 sb.Append(
") has been blocked from the system.");
329 sb =
new StringBuilder();
330 DateTime TP = Result.
Next.Value;
331 DateTime Today = DateTime.Today;
333 sb.Append(
"Too many failed login attempts in a row registered. Try again after ");
334 sb.Append(TP.ToLongTimeString());
336 if (TP.Date != Today)
338 if (TP.Date == Today.AddDays(1))
339 sb.Append(
" tomorrow");
343 sb.Append(TP.ToShortDateString());
347 sb.Append(
". Remote Endpoint: ");
365 StringBuilder Uri =
new StringBuilder();
366 Guid Id = Guid.NewGuid();
367 DateTime Created = DateTime.UtcNow;
369 Uri.Append(
"edaler:");
374 Uri.Append(Id.ToString());
376 if (!
string.IsNullOrEmpty(To))
378 int i = To.IndexOf(
'@');
379 if (i > 0 && Guid.TryParse(To[..i], out
_))
392 Uri.Append(Currency);
394 Uri.Append(
XML.
Encode(Created.Date.AddDays(ExpiresDays),
true));
396 Uri.Append(Convert.ToBase64String(Encoding.UTF8.GetBytes(FreeText)));
400 byte[] PreSign = Encoding.UTF8.GetBytes(Uri.ToString());
404 Uri.Append(Convert.ToBase64String(S));
407 return Uri.ToString();
410 private async Task SetUriHandler(
object Sender,
IqEventArgs e)
420 await e.
IqErrorForbidden(e.
To,
"Access to wallet only granted to accounts on broker.",
"en");
424 string UriString = e.
Query.InnerText;
440 public async Task<string>
ProcessUri(
string Uri,
string From)
445 if (ParsedUri is
null)
450 if (!await this.
ProcessUri(ParsedUri, ParsedFrom))
461 bool RemotelyControlled =
false;
464 if (OnPrincipal || FromPrincipal || ContractualPayment)
466 RemotelyControlled = (!OnPrincipal && FromPrincipal) || ContractualPayment;
468 List<ITransaction> Parts =
new List<ITransaction>();
471 if (Parts.Count == 1)
472 UriTransaction = Parts[0];
481 if (!await UriTransaction.
Prepare())
493 if (RemotelyControlled)
495 UriTransaction.Tag =
new RemoteControlState()
501 this.transactions.Register(UriTransaction);
509 if (await UriTransaction.
Execute())
511 if (await UriTransaction.
Commit())
523 await UriTransaction.
Abort();
532 private class RemoteControlState
538 private async Task ExecuteHandler(
object Sender,
IqEventArgs e)
549 await e.
IqErrorConflict(e.
To,
"Unable to execute transaction: " + State.Uri.State.ErrorMessage,
"en");
565 private async Task<ITransaction> PrepareTransaction(
IqEventArgs e)
569 if (!Guid.TryParse(IdStr, out Guid Id))
583 await e.
IqErrorForbidden(e.
To,
"You are not authorized to control this transaction.",
"en");
592 private async Task CommitHandler(
object Sender,
IqEventArgs e)
603 await e.
IqErrorConflict(e.
To,
"Unable to commit transaction: " + State.Uri.State.ErrorMessage,
"en");
621 private async Task RollbackHandler(
object Sender,
IqEventArgs e)
632 await e.
IqErrorConflict(e.
To,
"Unable to roll transaction back: " + State.Uri.State.ErrorMessage,
"en");
650 private async Task GetAccountEventsHandler(
object Sender,
IqEventArgs e)
654 await e.
IqErrorForbidden(e.
To,
"Access to wallet only granted to accounts on broker.",
"en");
662 await e.
IqErrorForbidden(e.
To,
"Access to wallet only granted to accounts on broker.",
"en");
672 IEnumerable<AccountEvent> Events;
677 if (!e.
Query.HasAttribute(
"from") ||
690 StringBuilder Xml =
new StringBuilder();
692 Xml.Append(
"<events xmlns=\"");
700 Xml.Append(
"<more/>");
707 Xml.Append(
"</events>");
712 private async Task GetBuyEDalerProvidersHandler(
object Sender,
IqEventArgs e)
716 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
724 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
734 LegalIdentity Identity = await this.legal.GetCurrentApprovedLegalIdentityAsync(AccountName);
735 if (Identity is
null)
742 if (
string.IsNullOrEmpty(Country))
744 await e.
IqErrorForbidden(e.
To,
"Approved legal identity lacks country specified.",
"en");
749 StringBuilder Xml =
new StringBuilder();
751 Xml.Append(
"<providers xmlns='");
757 foreach (Type T
in ServiceTypes)
771 Xml.Append(
"<provider id='");
773 Xml.Append(
"' type='");
775 Xml.Append(
"' name='");
778 if (!
string.IsNullOrEmpty(Service.
IconUrl))
780 Xml.Append(
"' iconUrl='");
782 Xml.Append(
"' iconWidth='");
783 Xml.Append(Service.
IconWidth.ToString());
784 Xml.Append(
"' iconHeight='");
790 Xml.Append(
"' templateId='");
798 Xml.Append(
"</providers>");
803 private async Task InitiateGetOptionsBuyEDalerHandler(
object Sender,
IqEventArgs e)
807 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
815 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
825 LegalIdentity Identity = await this.legal.GetCurrentApprovedLegalIdentityAsync(AccountName);
826 if (Identity is
null)
833 if (
string.IsNullOrEmpty(Country))
835 await e.
IqErrorForbidden(e.
To,
"Approved legal identity lacks country specified.",
"en");
844 string TransactionId = e.
Query.HasAttribute(
"tid") ?
XML.
Attribute(e.
Query,
"tid") : Guid.NewGuid().ToString();
846 if (
string.IsNullOrEmpty(ServiceId))
868 await e.
IqErrorBadRequest(e.
To,
"Service Provider does not support buying of eDaler.",
"en");
887 StringBuilder Xml =
new StringBuilder();
889 Xml.Append(
"<transaction xmlns='");
891 Xml.Append(
"' tid='");
897 Task
_ = Task.Run(async () =>
901 Dictionary<CaseInsensitiveString, CaseInsensitiveString> BuyerIdParameters =
new Dictionary<CaseInsensitiveString, CaseInsensitiveString>();
906 IDictionary<CaseInsensitiveString, object>[] Options;
911 SuccessUrl, FailureUrl, CancelUrl, async (sender, e2) =>
915 Xml.Append(
"<buyEDalerOptionsClientUrl xmlns='");
917 Xml.Append(
"' tid='");
919 Xml.Append(
"' url='");
929 Xml.Append(
"<buyEDalerOptionsCompleted xmlns='");
931 Xml.Append(
"' tid='");
935 if (!(Options is
null))
937 foreach (IDictionary<CaseInsensitiveString, object> Option
in Options)
939 Xml.Append(
"<option>");
941 foreach (KeyValuePair<CaseInsensitiveString, object> P
in Option)
944 Xml.Append(
"</option>");
948 Xml.Append(
"</buyEDalerOptionsCompleted>");
957 Xml.Append(
"<buyEDalerOptionsError xmlns='");
959 Xml.Append(
"' tid='");
963 Xml.Append(
"</buyEDalerOptionsError>");
976 private async Task InitiateBuyEDalerHandler(
object Sender,
IqEventArgs e)
980 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
988 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
998 LegalIdentity Identity = await this.legal.GetCurrentApprovedLegalIdentityAsync(AccountName);
999 if (Identity is
null)
1006 if (
string.IsNullOrEmpty(Country))
1008 await e.
IqErrorForbidden(e.
To,
"Approved legal identity lacks country specified.",
"en");
1019 string TransactionId = e.
Query.HasAttribute(
"tid") ?
XML.
Attribute(e.
Query,
"tid") : Guid.NewGuid().ToString();
1033 if (
string.IsNullOrEmpty(ServiceId))
1055 await e.
IqErrorBadRequest(e.
To,
"Service Provider does not support buying of eDaler.",
"en");
1061 if (Service is
null)
1069 await e.
IqErrorNotAllowed(e.
To,
"Selected service provider cannot perform action.",
"en");
1075 await e.
IqErrorNotAllowed(e.
To,
"Selected service provider does not support selected currency (" + Currency +
").",
"en");
1081 await e.
IqErrorForbidden(e.
To,
"Service provider requires a signed contract to perform payment. See associated Contract Template ID.",
"en");
1085 Dictionary<CaseInsensitiveString, object> ContractParameters =
new Dictionary<CaseInsensitiveString, object>()
1087 {
"Amount", Amount },
1088 {
"Currency", Currency.
Value.ToUpper() }
1090 Dictionary<CaseInsensitiveString, CaseInsensitiveString> BuyerIdParameters =
new Dictionary<CaseInsensitiveString, CaseInsensitiveString>();
1095 StringBuilder Xml =
new StringBuilder();
1097 Xml.Append(
"<transaction xmlns='");
1099 Xml.Append(
"' tid='");
1105 Task
_ = Task.Run(async () =>
1110 FailureUrl, CancelUrl, Service,
this, Identity.
Id,
null, ContractParameters, BuyerIdParameters, TransactionId,
1111 async (sender, e2) =>
1115 Xml.Append(
"<buyEDalerClientUrl xmlns='");
1117 Xml.Append(
"' tid='");
1119 Xml.Append(
"' url='");
1131 Xml.Append(
"<buyEDalerCompleted xmlns='");
1132 Xml.Append(NamespaceEDaler);
1133 Xml.Append(
"' tid='");
1134 Xml.Append(XML.Encode(TransactionId));
1135 Xml.Append(
"' amount='");
1136 Xml.Append(CommonTypes.Encode(PaymentResult.Amount));
1137 Xml.Append(
"' currency='");
1138 Xml.Append(XML.Encode(PaymentResult.Currency));
1141 await this.Server.SendMessage(string.Empty, string.Empty, e.To, e.From.ToBareJID(), string.Empty, Xml.ToString());
1148 Xml.Append(
"<buyEDalerError xmlns='");
1149 Xml.Append(NamespaceEDaler);
1150 Xml.Append(
"' tid='");
1151 Xml.Append(XML.Encode(TransactionId));
1153 Xml.Append(XML.Encode(PaymentResult.Error));
1154 Xml.Append(
"</buyEDalerError>");
1156 await this.Server.SendMessage(string.Empty, string.Empty, e.To, e.From.ToBareJID(), string.Empty, Xml.ToString());
1160 catch (Exception ex)
1167 private async Task GetSellEDalerProvidersHandler(
object Sender,
IqEventArgs e)
1171 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
1177 if (Account is
null)
1179 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
1189 LegalIdentity Identity = await this.legal.GetCurrentApprovedLegalIdentityAsync(AccountName);
1190 if (Identity is
null)
1197 if (
string.IsNullOrEmpty(Country))
1199 await e.
IqErrorForbidden(e.
To,
"Approved legal identity lacks country specified.",
"en");
1204 StringBuilder Xml =
new StringBuilder();
1206 Xml.Append(
"<providers xmlns='");
1212 foreach (Type T
in ServiceTypes)
1226 Xml.Append(
"<provider id='");
1228 Xml.Append(
"' type='");
1230 Xml.Append(
"' name='");
1233 if (!
string.IsNullOrEmpty(Service.
IconUrl))
1235 Xml.Append(
"' iconUrl='");
1237 Xml.Append(
"' iconWidth='");
1238 Xml.Append(Service.
IconWidth.ToString());
1239 Xml.Append(
"' iconHeight='");
1245 Xml.Append(
"' templateId='");
1253 Xml.Append(
"</providers>");
1258 private async Task InitiateGetOptionsSellEDalerHandler(
object Sender,
IqEventArgs e)
1262 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
1268 if (Account is
null)
1270 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
1280 LegalIdentity Identity = await this.legal.GetCurrentApprovedLegalIdentityAsync(AccountName);
1281 if (Identity is
null)
1288 if (
string.IsNullOrEmpty(Country))
1290 await e.
IqErrorForbidden(e.
To,
"Approved legal identity lacks country specified.",
"en");
1299 string TransactionId = e.
Query.HasAttribute(
"tid") ?
XML.
Attribute(e.
Query,
"tid") : Guid.NewGuid().ToString();
1301 if (
string.IsNullOrEmpty(ServiceId))
1323 await e.
IqErrorBadRequest(e.
To,
"Service Provider does not support selling of eDaler.",
"en");
1330 if (Service is
null)
1338 await e.
IqErrorNotAllowed(e.
To,
"Selected service provider cannot perform action.",
"en");
1342 StringBuilder Xml =
new StringBuilder();
1344 Xml.Append(
"<transaction xmlns='");
1346 Xml.Append(
"' tid='");
1352 Task
_ = Task.Run(async () =>
1356 Dictionary<CaseInsensitiveString, CaseInsensitiveString> SellerIdParameters =
new Dictionary<CaseInsensitiveString, CaseInsensitiveString>();
1361 IDictionary<CaseInsensitiveString, object>[] Options;
1366 SuccessUrl, FailureUrl, CancelUrl, async (sender, e2) =>
1370 Xml.Append(
"<sellEDalerOptionsClientUrl xmlns='");
1372 Xml.Append(
"' tid='");
1374 Xml.Append(
"' url='");
1384 Xml.Append(
"<sellEDalerOptionsCompleted xmlns='");
1386 Xml.Append(
"' tid='");
1390 if (!(Options is
null))
1392 foreach (IDictionary<CaseInsensitiveString, object> Option
in Options)
1394 Xml.Append(
"<option>");
1396 foreach (KeyValuePair<CaseInsensitiveString, object> P
in Option)
1399 Xml.Append(
"</option>");
1403 Xml.Append(
"</sellEDalerOptionsCompleted>");
1408 catch (Exception ex)
1412 Xml.Append(
"<sellEDalerOptionsError xmlns='");
1414 Xml.Append(
"' tid='");
1418 Xml.Append(
"</sellEDalerOptionsError>");
1424 catch (Exception ex)
1431 private async Task InitiateSellEDalerHandler(
object Sender,
IqEventArgs e)
1435 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
1441 if (Account is
null)
1443 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
1453 LegalIdentity Identity = await this.legal.GetCurrentApprovedLegalIdentityAsync(AccountName);
1454 if (Identity is
null)
1461 if (
string.IsNullOrEmpty(Country))
1463 await e.
IqErrorForbidden(e.
To,
"Approved legal identity lacks country specified.",
"en");
1474 string TransactionId = e.
Query.HasAttribute(
"tid") ?
XML.
Attribute(e.
Query,
"tid") : Guid.NewGuid().ToString();
1488 if (
string.IsNullOrEmpty(ServiceId))
1510 await e.
IqErrorBadRequest(e.
To,
"Service Provider does not support selling of eDaler.",
"en");
1516 if (Service is
null)
1524 await e.
IqErrorNotAllowed(e.
To,
"Selected service provider cannot perform action.",
"en");
1530 await e.
IqErrorNotAllowed(e.
To,
"Selected service provider does not support selected currency (" + Currency +
").",
"en");
1536 await e.
IqErrorForbidden(e.
To,
"Service provider requires a signed contract to perform payment. See associated Contract Template ID.",
"en");
1540 Dictionary<CaseInsensitiveString, object> ContractParameters =
new Dictionary<CaseInsensitiveString, object>()
1542 {
"Amount", Amount },
1543 {
"Currency", Currency.
Value.ToUpper() }
1545 Dictionary<CaseInsensitiveString, CaseInsensitiveString> SellerIdParameters =
new Dictionary<CaseInsensitiveString, CaseInsensitiveString>();
1550 StringBuilder Xml =
new StringBuilder();
1552 Xml.Append(
"<transaction xmlns='");
1554 Xml.Append(
"' tid='");
1560 Task
_ = Task.Run(async () =>
1565 FailureUrl, CancelUrl, Service,
this, Identity.
Id,
null, ContractParameters, SellerIdParameters, TransactionId,
1566 async (sender, e2) =>
1570 Xml.Append(
"<sellEDalerClientUrl xmlns='");
1572 Xml.Append(
"' tid='");
1574 Xml.Append(
"' url='");
1586 Xml.Append(
"<sellEDalerCompleted xmlns='");
1587 Xml.Append(NamespaceEDaler);
1588 Xml.Append(
"' tid='");
1589 Xml.Append(XML.Encode(TransactionId));
1590 Xml.Append(
"' amount='");
1591 Xml.Append(CommonTypes.Encode(PaymentResult.Amount));
1592 Xml.Append(
"' currency='");
1593 Xml.Append(XML.Encode(PaymentResult.Currency));
1596 await this.Server.SendMessage(string.Empty, string.Empty, e.To, e.From.ToBareJID(), string.Empty, Xml.ToString());
1603 Xml.Append(
"<sellEDalerError xmlns='");
1604 Xml.Append(NamespaceEDaler);
1605 Xml.Append(
"' tid='");
1606 Xml.Append(XML.Encode(TransactionId));
1608 Xml.Append(XML.Encode(PaymentResult.Error));
1609 Xml.Append(
"</sellEDalerError>");
1611 await this.Server.SendMessage(string.Empty, string.Empty, e.To, e.From.ToBareJID(), string.Empty, Xml.ToString());
1615 catch (Exception ex)
Contains information about a service provider that users can use to buy eDaler.
Result of request payment.
bool Ok
If payment was successful or not.
Contains information about a service provider that users can use to sell eDaler.
Contains information about a service provider.
Helps with parsing of commong data types.
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
static string Encode(string s)
Encodes a string for use in XML.
static bool TryParse(string s, out DateTime Value)
Tries to decode a string encoded DateTime.
Class representing an event.
override string ToString()
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.
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
The server understood the request, but is refusing to fulfill it. Authorization will not help and the...
Represents an HTTP request.
string RemoteEndPoint
Remote end-point.
Base class for components.
void RegisterIqSetHandler(string LocalName, string Namespace, EventHandlerAsync< IqEventArgs > Handler, bool PublishNamespaceAsFeature)
Registers an IQ-Set handler.
CaseInsensitiveString Subdomain
Subdomain name.
void RegisterIqGetHandler(string LocalName, string Namespace, EventHandlerAsync< IqEventArgs > Handler, bool PublishNamespaceAsFeature)
Registers an IQ-Get handler.
string Name
Component name.
XmppServer Server
XMPP Server.
bool UnregisterIqGetHandler(string LocalName, string Namespace, EventHandlerAsync< IqEventArgs > Handler, bool RemoveNamespaceAsFeature)
Unregisters an IQ-Get handler.
bool UnregisterIqSetHandler(string LocalName, string Namespace, EventHandlerAsync< IqEventArgs > Handler, bool RemoveNamespaceAsFeature)
Unregisters an IQ-Set handler.
Event arguments for IQ queries.
XmppAddress From
From address attribute
Task IqResult(string Xml, string From)
Returns a response to the current request.
Task IqErrorItemNotFound(XmppAddress From, string ErrorText, string Language)
Returns a item-not-found error.
XmlElement Query
Query element, if found, null otherwise.
Task IqErrorNotAllowed(XmppAddress From, string ErrorText, string Language)
Returns a not-allowed error.
XmppAddress To
To address attribute
async Task IqError(string ErrorType, string Xml, XmppAddress From, string ErrorText, string Language)
Returns an error response to the current request.
Task IqErrorServiceUnavailable(XmppAddress From, string ErrorText, string Language)
Returns a service-unavailable error.
Task IqErrorConflict(XmppAddress From, string ErrorText, string Language)
Returns a conflict error.
Task IqErrorBadRequest(XmppAddress From, string ErrorText, string Language)
Returns a bad-request error.
Task IqErrorForbidden(XmppAddress From, string ErrorText, string Language)
Returns a forbidden error.
Contains information about one XMPP address.
override string ToString()
object.ToString()
bool HasAccount
If the address has an account part.
CaseInsensitiveString Domain
Domain
XmppAddress ToBareJID()
Returns the Bare JID as an XmppAddress object.
CaseInsensitiveString BareJid
Bare JID
static readonly XmppAddress Empty
Empty address.
CaseInsensitiveString Account
Account
Task< bool > SendMessage(string Type, string Id, string From, string To, string Language, string ContentXml)
Sends a Message stanza to a recipient.
bool IsServerDomain(CaseInsensitiveString Domain, bool IncludeAlternativeDomains)
Checks if a domain is the server domain, or optionally, an alternative domain.
CaseInsensitiveString Domain
Domain name.
Represents a case-insensitive string.
string Value
String-representation of the case-insensitive string. (Representation is case sensitive....
string LowerCase
Lower-case representation of the case-insensitive string.
static bool IsNullOrEmpty(CaseInsensitiveString value)
Indicates whether the specified string is null or an CaseInsensitiveString.Empty string.
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static async Task Update(object Object)
Updates an object in the database.
static Task< IEnumerable< object > > Find(string Collection, params string[] SortOrder)
Finds objects in a given collection.
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
This filter selects objects that conform to all child-filters provided.
Custom filter used to filter objects using an external expression.
This filter selects objects that have a named field equal to a given value.
This filter selects objects that have a named field lesser than a given value.
Static class that dynamically manages types and interfaces available in the runtime environment.
static Type GetType(string FullName)
Gets a type, given its full name.
static object[] NoParameters
Contains an empty array of parameter values.
static object Instantiate(Type Type, params object[] Arguments)
Returns an instance of the type Type . If one needs to be created, it is. If the constructor requires...
static Type[] GetTypesImplementingInterface(string InterfaceFullName)
Gets all types implementing a given interface.
static ConstructorInfo GetDefaultConstructor(Type Type)
Gets the default constructor of a type, if one exists.
Static class managing persistent settings.
static async Task< string > GetAsync(string Key, string DefaultValue)
Gets a string-valued setting.
A transaction built up of a set of sub-transactions.
Abstract base class for transactions.
async Task< bool > Commit()
Commits any changes made during the execution phase.
object Tag
Caller can use this property to tag the transaction with information.
async Task< bool > Execute()
Executes the transaction.
async Task< bool > Rollback()
Rolls back any changes made during the execution phase.
Module making sure no unfinished transactions are left when system ends.
static bool Running
If the transaction module is running.
Maintains a collection of active transactions.
Class that monitors login events, and help applications determine malicious intent....
static async Task< KeyValuePair< string, object >[]> Annotate(string RemoteEndPoint, params KeyValuePair< string, object >[] Tags)
Annotates a remote endpoint.
Contains information about a login attempt.
DateTime? Next
Time when a new login can be attempted.
LoginResultType Type
Type of login result.
Corresponds to a user in the system.
Maintains the collection of all users in the system.
static async Task< LoginResult > Login(string UserName, string Password, string RemoteEndPoint, string Protocol)
Attempts to login in the system.
Manages eDaler on accounts connected to the broker.
override bool SupportsAccounts
If the component supports accounts (true), or if the subdomain name is the only valid address.
override void Dispose()
IDisposable.Dispose
async Task< string > ProcessUri(string Uri, string From)
Processes an eDaler URI.
LegalComponent Legal
Legal component
const string NamespaceEDaler
Namespace of eDaler component.
EDalerComponent(XmppServer Server, CaseInsensitiveString Subdomain, string Name, LegalComponent Legal)
Manages eDaler on accounts connected to the broker.
async Task< string > GetDefaultCurrency()
Gets the default currency
Relays processing of the URI to the principal domain.
eDaler URI representing a contractual payment of eDaler from a sender to a receiver.
Abstract base class for eDaler URIs
abstract void AddTransactionParts(List< ITransaction > Subtransactions, bool LocalOnly, LegalComponent Legal)
Adds subtransaction objects necessary to process the URI.
EDalerUriState State
URI State object.
CaseInsensitiveString PrincipalDomain
Principal domain (i.e domain controlling the execution of the transaction.)
static async Task< EDalerUri > Parse(string Uri, EDalerUriState State, EDalerComponent EDaler)
Parses an eDaler URI
virtual void Error(EDalerUriErrorType ErrorType, string ErrorMessage, bool LogAsNotice)
Reports an error with the URI
string ErrorMessage
Error message, or null if no error.
Current state of URI from external source
Current state of URI from internal source
Retains the current balance of an account.
Property[] Properties
Properties detailing the legal identity.
CaseInsensitiveString Id
ID of the legal identity
CaseInsensitiveString Name
Property name
CaseInsensitiveString Value
Property value
Legal (digital identities, smart contracts) service component.
Marketplace processor, brokering sales of items via tenders and offers defined in smart contracts.
Service Module hosting the XMPP broker and its components.
Interface for information about a service provider that users can use to buy eDaler.
string BuyEDalerTemplateContractId
Contract ID of Template, for buying e-Daler
Task< IDictionary< CaseInsensitiveString, object >[]> GetPaymentOptionsForBuyingEDaler(IDictionary< CaseInsensitiveString, CaseInsensitiveString > IdentityProperties, string SuccessUrl, string FailureUrl, string CancelUrl, EventHandlerAsync< ClientUrlEventArgs > ClientUrlCallback, object State)
Gets available payment options for buying eDaler.
Task< bool > CanBuyEDaler(CaseInsensitiveString AccountName)
If the service provider can be used to process a request to buy eDaler of a certain amount,...
Interface for information about a service provider that users can use to buy eDaler.
Task< IBuyEDalerService[]> GetServicesForBuyingEDaler(CaseInsensitiveString Currency, CaseInsensitiveString Country)
Gets available payment services.
Interface for information about a service provider that users can use to sell eDaler.
Task< bool > CanSellEDaler(CaseInsensitiveString AccountName)
If the service provider can be used to process a request to sell eDaler of a certain amount,...
string SellEDalerTemplateContractId
Contract ID of Template, for selling e-Daler
Task< IDictionary< CaseInsensitiveString, object >[]> GetPaymentOptionsForSellingEDaler(IDictionary< CaseInsensitiveString, CaseInsensitiveString > IdentityProperties, string SuccessUrl, string FailureUrl, string CancelUrl, EventHandlerAsync< ClientUrlEventArgs > ClientUrlCallback, object State)
Gets available payment options for selling eDaler.
Interface for information about a service provider that users can use to sell eDaler.
Task< ISellEDalerService[]> GetServicesForSellingEDaler(CaseInsensitiveString Currency, CaseInsensitiveString Country)
Gets available payment services.
string Id
ID of service provider.
int IconWidth
Width of icon, if available.
string IconUrl
Optional URL to icon of service provider.
int IconHeight
Height of icon, if available.
string Name
Displayable name of service provider.
CaseInsensitiveString UserName
User Name
bool Enabled
If the account is enabled.
Interface for XMPP user accounts.
Grade Supports(T Object)
If the interface understands objects such as Object .
Interface for transactions
Task< bool > Execute()
Executes the transaction.
Task< bool > Prepare()
Prepares the transaction for execution. This step can be used for validation and authorization of the...
Task< bool > Rollback()
Rolls back any changes made during the execution phase.
Task Abort()
Aborts the transaction.
Task< bool > Commit()
Commits any changes made during the execution phase.
Basic interface for a user.
LoginResultType
Result of login attempt
EDalerUriErrorType
Type of URI Error