Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RemoteReferences.cs
1using System;
3using System.Threading.Tasks;
4using System.Xml;
5using Waher.Content;
10using Waher.Script;
14
16{
22 {
28 : base("Account/RemoteReferences",
29 new KeyValuePair<Type, Expression>(typeof(Dictionary<string, object>), new Expression(jsonPattern)),
30 new KeyValuePair<Type, Expression>(typeof(XmlDocument), new Expression(xmlPattern)))
31 {
32 }
33
34 private static readonly string jsonPattern = Resources.LoadResourceAsText(typeof(Login).Namespace + ".JSON.RemoteReferences.req");
35 private static readonly string xmlPattern = Resources.LoadResourceAsText(typeof(Login).Namespace + ".XML.RemoteReferences.req");
36
45 public override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary<string, IElement> Parameters)
46 {
47 AccountUser User = AssertUserAuthenticated(Request, true);
48
49 SortedDictionary<CaseInsensitiveString, RemoteIdentityReference> ByDomain = new SortedDictionary<CaseInsensitiveString, RemoteIdentityReference>();
50
52 new FilterFieldEqualTo("Account", User.Account.UserName)))
53 ByDomain[Ref.RemoteDomain] = Ref;
54
55 List<NamedDictionary<string, object>> References = new List<NamedDictionary<string, object>>();
56
57 foreach (RemoteIdentityReference Ref in ByDomain.Values)
58 {
59 References.Add(new NamedDictionary<string, object>("Reference", AgentNamespace)
60 {
61 { "domain", Ref.RemoteDomain.Value },
62 { "legalId", Ref.LegalId.Value }
63 });
64 }
65
66 await Response.Return(new NamedDictionary<string, object>("RemoteReferencesResult", AgentNamespace)
67 {
68 { "References", References.ToArray() }
69 });
70 }
71 }
72}
A Named dictionary is a dictionary, with a local name and a namespace. Use it to return content that ...
Represents an HTTP request.
Definition: HttpRequest.cs:22
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:23
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:21
static Task< IEnumerable< object > > Find(string Collection, params string[] SortOrder)
Finds objects in a given collection.
Definition: Database.cs:238
This filter selects objects that have a named field equal to a given value.
Static class managing loading of resources stored as embedded resources or in content files.
Definition: Resources.cs:13
static string LoadResourceAsText(string ResourceName)
Loads a text resource from an embedded resource.
Definition: Resources.cs:55
Class managing a script expression.
Definition: Expression.cs:41
Gets a list of remote references pointing to legal identities belonging to the account.
override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary< string, IElement > Parameters)
Executes the POST method on the resource.
RemoteReferences()
Gets a list of remote references pointing to legal identities belonging to the account.
Abstract base class for agent resources supporting the POST method.
static AccountUser AssertUserAuthenticated(HttpRequest Request)
Makes sure the request is made by an authenticated API user.
const string AgentNamespace
https://waher.se/Schema/BrokerAgent.xsd