2using System.Collections.Generic;
4using System.Threading.Tasks;
72 byte[] Signature =
null;
74 bool HasTimeout =
false;
76 if (Obj is XmlDocument Xml)
78 PNr = Xml.DocumentElement[
"PNR"]?.InnerText;
79 Country = Xml.DocumentElement[
"COUNTRY"]?.InnerText;
80 TimeoutStr = Xml.DocumentElement[
"Timeout"]?.InnerText;
81 Reason = Xml.DocumentElement[
"Reason"]?.InnerText;
82 LegalId = Xml.DocumentElement[
"LegalId"]?.InnerText;
83 SignatureStr = Xml.DocumentElement[
"Signature"]?.InnerText;
85 else if (Obj is Dictionary<string, object> Json)
87 if (Json.TryGetValue(
"PNR", out
object v))
92 if (Json.TryGetValue(
"COUNTRY", out v))
93 Country = v.ToString();
97 if (Json.TryGetValue(
"Timeout", out v))
105 else if (v is
string s)
108 TimeoutStr = v.ToString();
113 if (Json.TryGetValue(
"Reason", out v))
114 Reason = v.ToString();
118 if (Json.TryGetValue(
"LegalId", out v))
119 LegalId = v.ToString();
123 if (Json.TryGetValue(
"Signature", out v))
131 SignatureStr = v.ToString();
136 else if (Obj is Dictionary<string, string> Form)
138 if (!Form.TryGetValue(
"PNR", out PNr))
141 if (!Form.TryGetValue(
"COUNTRY", out Country))
144 if (!Form.TryGetValue(
"Timeout", out TimeoutStr))
147 if (!Form.TryGetValue(
"Reason", out Reason))
150 if (!Form.TryGetValue(
"LegalId", out LegalId))
153 if (!Form.TryGetValue(
"Signature", out SignatureStr))
156 if (Form.TryGetValue(
"g-recaptcha-response", out
string RecaptchaResponse))
161 else if (
string.IsNullOrEmpty(LegalId))
167 if (
string.IsNullOrEmpty(PNr))
170 if (
string.IsNullOrEmpty(Country))
173 if (
string.IsNullOrEmpty(Reason))
178 if (TimeoutStr is
null || !
int.TryParse(TimeoutStr, out Timeout))
182 if (Timeout <= 0 || Timeout > 300)
185 if (
string.IsNullOrEmpty(LegalId))
187 if (!(Signature is
null) || !
string.IsNullOrEmpty(SignatureStr))
194 StringBuilder sb =
new StringBuilder();
195 DateTime TP = Next.Value;
196 DateTime Today = DateTime.Today;
198 if (Next.Value == DateTime.MaxValue)
200 sb.Append(
"This endpoint (");
202 sb.Append(
") has been blocked from the system.");
206 sb.Append(
"Too many failed login attempts in a row registered. Try again after ");
207 sb.Append(TP.ToLongTimeString());
209 if (TP.Date != Today)
211 if (TP.Date == Today.AddDays(1))
212 sb.Append(
" tomorrow");
216 sb.Append(TP.ToShortDateString());
220 sb.Append(
". Remote Endpoint: ");
232 if (Signature is
null && !
string.IsNullOrEmpty(LegalId))
234 if (
string.IsNullOrEmpty(SignatureStr))
239 Signature = Convert.FromBase64String(SignatureStr);
248 this.ProcessRequest(Request, Response, PNr, Country, Timeout, Reason, LegalId, Signature);
252 string PNr,
string Country,
int Timeout,
string Reason,
string LegalId,
Static class managing the runtime environment of the IoT Gateway.
static LoginAuditor LoginAuditor
Current Login Auditor. Should be used by modules accepting user logins, to protect the system from un...
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
The server understood the request, but is refusing to fulfill it. Authorization will not help and the...
Base class for all asynchronous HTTP resources. An asynchronous resource responds outside of the meth...
Represents an HTTP request.
string RemoteEndPoint
Remote end-point.
bool HasData
If the request has data.
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Represets a response of an HTTP client request.
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
The requested resource resides temporarily under a different URI. Since the redirection MAY be altere...
The user has sent too many requests in a given amount of time. Intended for use with rate limiting sc...
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
static readonly Regex BareJidRegEx
Regular expression for Bare JIDs
Web resource that allows calling applications to enable Multi-Factor Authentication using legal ident...
Task GET(HttpRequest Request, HttpResponse Response)
Executes the GET method on the resource.
bool AllowsGET
If the GET method is allowed.
override bool UserSessions
If the resource uses user sessions.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
bool AllowsPOST
If the POST method is allowed.
override bool HandlesSubPaths
If the resource handles sub-paths.
GET Interface for HTTP resources.
POST Interface for HTTP resources.