1using System.Collections.Generic;
3using System.Threading.Tasks;
17 private readonly
Account account;
36 public string UserName => this.account.UserName;
71 public Task<IEnumerable<KeyValuePair<string, object>>>
CreateClaims(
bool Encrypted)
73 if (!this.account.Enabled)
74 return Task.FromResult<IEnumerable<KeyValuePair<string, object>>>(
null);
76 int IssuedAt = (int)Math.Round(DateTime.UtcNow.Subtract(
JSON.
UnixEpoch).TotalSeconds);
77 int Expires = IssuedAt + 3600;
79 List<KeyValuePair<string, object>> Claims =
new List<KeyValuePair<string, object>>()
90 if (!
string.IsNullOrWhiteSpace(this.account.EMail))
91 Claims.Add(
new KeyValuePair<string, object>(
JwtClaims.
EMail,
this.account.EMail));
93 if (!
string.IsNullOrWhiteSpace(this.account.PhoneNr))
96 if (this.account.CanRelayMessages)
100 return Task.FromResult<IEnumerable<KeyValuePair<string, object>>>(Claims);
111 IEnumerable<KeyValuePair<string, object>> Claims = await this.
CreateClaims(Encrypted);
115 return Factory.
Create(Claims);
Helps with common JSON-related tasks.
static readonly DateTime UnixEpoch
Unix Date and Time epoch, starting at 1970-01-01T00:00:00Z
Static class managing the runtime environment of the IoT Gateway.
static CaseInsensitiveString Domain
Domain name.
static byte[] NextBytes(int NrBytes)
Generates an array of random bytes.
Implements a simple SMTP Server, as defined in:
const string SmtpRelayPrivilegeID
SmtpRelay
Static class containing predefined JWT claim names.
const string Issuer
Issuer of the JWT
const string IssueTime
Time at which the JWT was issued; can be used to determine age of the JWT
const string JwtId
Unique identifier; can be used to prevent the JWT from being replayed (allows a token to be used only...
const string EMail
Preferred e-mail address
const string PhoneNumber
Preferred telephone number
const string Subject
Subject of the JWT (the user)
const string Entitlements
Entitlements
const string ExpirationTime
Time after which the JWT expires
A factory that can create and validate JWT tokens.
string Create(params KeyValuePair< string, object >[] Claims)
Creates a new JWT token.
Contains information about a broker account.
Account Account
Account object.
string UserName
User Name.
AccountUser(Account Account)
Account user object.
string PasswordHashType
Type of password hash. The empty stream means a clear-text password.
Task< RequestOrigin > GetOrigin()
Origin of request.
Task< IEnumerable< KeyValuePair< string, object > > > CreateClaims(bool Encrypted)
Creates a set of claims identifying the user.
bool HasPrivilege(string Privilege)
If the user has a given privilege.
async Task< string > CreateToken(JwtFactory Factory, bool Encrypted)
Creates a JWT Token referencing the user object.
string PasswordHash
Password Hash
Tokens available in request.
A User that can participate in distributed operations, where the user is identified using a JWT token...
Interface for requestors that can act as an origin for distributed requests.