5using System.Threading.Tasks;
77 byte[] Signature =
null;
79 bool HasTimeout =
false;
87 if (Content.
Decoded is XmlDocument Xml)
91 TimeoutStr = Xml.DocumentElement[
"Timeout"]?.InnerText;
92 Reason = Xml.DocumentElement[
"Reason"]?.InnerText;
93 LegalId = Xml.DocumentElement[
"LegalId"]?.InnerText;
94 SignatureStr = Xml.DocumentElement[
"Signature"]?.InnerText;
96 else if (Content.
Decoded is Dictionary<string, object> Json)
104 Country = v.ToString();
108 if (Json.TryGetValue(
"Timeout", out v))
116 else if (v is
string s)
119 TimeoutStr = v.ToString();
124 if (Json.TryGetValue(
"Reason", out v))
125 Reason = v.ToString();
129 if (Json.TryGetValue(
"LegalId", out v))
130 LegalId = v.ToString();
134 if (Json.TryGetValue(
"Signature", out v))
142 SignatureStr = v.ToString();
147 else if (Content.
Decoded is Dictionary<string, string> Form)
155 if (!Form.TryGetValue(
"Timeout", out TimeoutStr))
158 if (!Form.TryGetValue(
"Reason", out Reason))
161 if (!Form.TryGetValue(
"LegalId", out LegalId))
164 if (!Form.TryGetValue(
"Signature", out SignatureStr))
167 if (Form.TryGetValue(
"g-recaptcha-response", out
string RecaptchaResponse))
175 else if (
string.IsNullOrEmpty(LegalId))
187 if (
string.IsNullOrEmpty(PNr))
193 if (
string.IsNullOrEmpty(Country))
199 if (
string.IsNullOrEmpty(Reason))
207 if (TimeoutStr is
null || !
int.TryParse(TimeoutStr, out Timeout))
214 if (Timeout <= 0 || Timeout > 300)
220 if (
string.IsNullOrEmpty(LegalId))
222 if (!(Signature is
null) || !
string.IsNullOrEmpty(SignatureStr))
232 StringBuilder sb =
new StringBuilder();
233 DateTime TP = Next.Value;
234 DateTime Today = DateTime.Today;
236 if (Next.Value == DateTime.MaxValue)
238 sb.Append(
"This endpoint (");
240 sb.Append(
") has been blocked from the system.");
244 sb.Append(
"Too many failed login attempts in a row registered. Try again after ");
245 sb.Append(TP.ToLongTimeString());
247 if (TP.Date != Today)
249 if (TP.Date == Today.AddDays(1))
250 sb.Append(
" tomorrow");
254 sb.Append(TP.ToShortDateString());
258 sb.Append(
". Remote Endpoint: ");
274 if (Signature is
null && !
string.IsNullOrEmpty(LegalId))
276 if (
string.IsNullOrEmpty(SignatureStr))
284 Signature = Convert.FromBase64String(SignatureStr);
294 this.ProcessRequest(Request, Response, PNr, Country, Timeout, Reason, LegalId, Signature);
298 string PNr,
string Country,
int Timeout,
string Reason,
string LegalId,
Contains information about a response to a content request.
bool HasError
If an error occurred.
object Decoded
Decoded object.
Exception Error
Error response.
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< ContentResponse > 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.
static async Task< bool > SiteVerify(string RecaptchaResponse, string RemoteEndPoint)
Allows web pages and web services to verify that Google reCaptcha responses are valid.
GET Interface for HTTP resources.
POST Interface for HTTP resources.