Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PackageUrlValidator.cs
1
using
System;
2
using
System.Threading.Tasks;
3
using
Waher.Content.Xml
;
4
using
Waher.Networking.HTTP
;
5
using
Waher.Security
;
6
7
namespace
Waher.Service.IoTBroker.Provisioning.SoftwareUpdates
8
{
9
public
class
PackageUrlValidator
:
HttpAuthenticationScheme
10
{
11
public
PackageUrlValidator
()
12
{
13
}
14
15
public
override
string
GetChallenge
()
16
{
17
throw
new
BadRequestException
();
18
}
19
20
public
override
async Task<IUser>
IsAuthenticated
(
HttpRequest
Request)
21
{
22
if
(!Request.
Header
.
TryGetQueryParameter
(
"s"
, out
string
SignatureStr) ||
23
!Request.
Header
.
TryGetQueryParameter
(
"p"
, out
string
PublishedStr) ||
24
XML
.
TryParse
(PublishedStr, out DateTime Published))
25
{
26
return
null
;
27
}
28
29
Package
Package
= await
ProvisioningComponent
.GetPackage(Request.
SubPath
);
30
if
(
Package
is
null
||
31
Package
.
Published
!= Published ||
32
string
.Compare(Convert.ToBase64String(
Package
.
Signature
), SignatureStr,
true
) != 0)
33
{
34
return
null
;
35
}
36
37
return
new
PackageUser(
Package
);
38
}
39
40
private
class
PackageUser :
IUser
41
{
42
private
readonly
Package
package;
43
44
public
PackageUser(
Package
Package
)
45
{
46
this.package =
Package
;
47
}
48
49
public
string
UserName => this.package.
FileName
;
50
public
string
PasswordHash =>
throw
new
InvalidOperationException();
51
public
string
PasswordHashType =>
throw
new
InvalidOperationException();
52
53
public
bool
HasPrivilege(
string
Privilege)
54
{
55
return
false
;
56
}
57
}
58
}
59
}
Waher.Content.Xml.XML
Helps with common XML-related tasks.
Definition:
XML.cs:19
Waher.Content.Xml.XML.TryParse
static bool TryParse(string s, out DateTime Value)
Tries to decode a string encoded DateTime.
Definition:
XML.cs:744
Waher.Networking.HTTP.BadRequestException
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Definition:
BadRequestException.cs:9
Waher.Networking.HTTP.HttpAuthenticationScheme
Base class for all HTTP authentication schemes, as defined in RFC-7235: https://datatracker....
Definition:
HttpAuthenticationScheme.cs:11
Waher.Networking.HTTP.HttpRequestHeader.TryGetQueryParameter
bool TryGetQueryParameter(string QueryParameter, out string Value)
Tries to get the value of an individual query parameter, if available.
Definition:
HttpRequestHeader.cs:185
Waher.Networking.HTTP.HttpRequest
Represents an HTTP request.
Definition:
HttpRequest.cs:18
Waher.Networking.HTTP.HttpRequest.Header
HttpRequestHeader Header
Request header.
Definition:
HttpRequest.cs:134
Waher.Networking.HTTP.HttpRequest.SubPath
string SubPath
Sub-path. If a resource is found handling the request, this property contains the trailing sub-path o...
Definition:
HttpRequest.cs:146
Waher.Service.IoTBroker.Provisioning.ProvisioningComponent
Provisioning and registry service component.
Definition:
ProvisioningComponent.cs:52
Waher.Service.IoTBroker.Provisioning.SoftwareUpdates.Package
Contains information about a software package.
Definition:
Package.cs:18
Waher.Service.IoTBroker.Provisioning.SoftwareUpdates.Package.Signature
byte[] Signature
Cryptographic signature of package, as calculated by the issuer of the package.
Definition:
Package.cs:46
Waher.Service.IoTBroker.Provisioning.SoftwareUpdates.Package.FileName
CaseInsensitiveString FileName
Filename of package.
Definition:
Package.cs:40
Waher.Service.IoTBroker.Provisioning.SoftwareUpdates.Package.Published
DateTime Published
When package was published.
Definition:
Package.cs:76
Waher.Service.IoTBroker.Provisioning.SoftwareUpdates.PackageUrlValidator
Definition:
PackageUrlValidator.cs:10
Waher.Service.IoTBroker.Provisioning.SoftwareUpdates.PackageUrlValidator.IsAuthenticated
override async Task< IUser > IsAuthenticated(HttpRequest Request)
Checks if the request is authorized.
Definition:
PackageUrlValidator.cs:20
Waher.Service.IoTBroker.Provisioning.SoftwareUpdates.PackageUrlValidator.GetChallenge
override string GetChallenge()
Gets a challenge for the authenticating client to respond to.
Definition:
PackageUrlValidator.cs:15
Waher.Security.IUser
Basic interface for a user.
Definition:
IUser.cs:7
Waher.Content.Xml
Definition:
XmlCodec.cs:11
Waher.Networking.HTTP
Definition:
Page.cs:6
Waher.Security
Definition:
AcmeAccount.cs:8
Waher.Service.IoTBroker.Provisioning.SoftwareUpdates
Definition:
Package.cs:9
Waher.Service.IoTBroker
Provisioning
SoftwareUpdates
PackageUrlValidator.cs
Generated by
1.9.5