Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RequestOrigin.cs
1using System.Threading.Tasks;
2
3namespace Waher.Things
4{
9 {
13 public static readonly RequestOrigin Empty = new RequestOrigin(string.Empty,
14 null, null, null, null);
15
16 private readonly IRequestOrigin authority;
17 private readonly string[] deviceTokens;
18 private readonly string[] serviceTokens;
19 private readonly string[] userTokens;
20 private readonly string from;
21
30 public RequestOrigin(string From, string[] DeviceTokens, string[] ServiceTokens, string[] UserTokens,
32 {
33 this.from = From;
34 this.deviceTokens = DeviceTokens;
35 this.serviceTokens = ServiceTokens;
36 this.userTokens = UserTokens;
37 this.authority = Authority;
38 }
39
43 public string From => this.from;
44
48 public string[] DeviceTokens => this.deviceTokens;
49
53 public string[] ServiceTokens => this.serviceTokens;
54
58 public string[] UserTokens => this.userTokens;
59
63 public IRequestOrigin Authority => this.authority;
64
68 public Task<RequestOrigin> GetOrigin()
69 {
70 return Task.FromResult(this);
71 }
72
78 public bool HasPrivilege(string Privilege)
79 {
80 return this.authority?.HasPrivilege(Privilege) ?? false;
81 }
82 }
83}
Tokens available in request.
Definition: RequestOrigin.cs:9
static readonly RequestOrigin Empty
Empty request origin.
bool HasPrivilege(string Privilege)
If the origin has a given privilege.
RequestOrigin(string From, string[] DeviceTokens, string[] ServiceTokens, string[] UserTokens, IRequestOrigin Authority)
Tokens available in request.
IRequestOrigin Authority
Optional authority for privilege authorization
string[] UserTokens
User tokens, or null.
string[] DeviceTokens
Device tokens, or null.
string From
Address of caller.
Task< RequestOrigin > GetOrigin()
Origin of request.
string[] ServiceTokens
Service tokens, or null.
Interface for requestors that can act as an origin for distributed requests.