4using System.Threading.Tasks;
31 : base(
"Legal/SignData",
32 new KeyValuePair<Type,
Expression>(typeof(Dictionary<string, object>), new
Expression(jsonPattern)),
58 string KeyId = (string)Parameters[
"PKeyId"].AssociatedObjectValue;
60 string DataBase64 = (string)Parameters[
"PDataBase64"].AssociatedObjectValue;
61 string KeySignature = (string)Parameters[
"PKeySignature"].AssociatedObjectValue;
62 string RequestSignature = (string)Parameters[
"PRequestSignature"].AssociatedObjectValue;
65 if (
string.IsNullOrEmpty(KeyId))
70 Data = Convert.FromBase64String(DataBase64);
80 if (Identity.Account != User.
UserName)
81 throw new ForbiddenException(Request,
"Only allowed to add attachments to your own legal identities.");
83 if (Identity.
State != IoTBroker.Legal.Identity.IdentityState.Approved)
91 StringBuilder sb =
new StringBuilder();
106 sb.Append(KeySignature);
108 string s2 = sb.ToString();
111 sb.Append(DataBase64);
115 string s3 = sb.ToString();
117 string s = Convert.ToBase64String(
120 Encoding.UTF8.GetBytes(s3)));
122 if (s != RequestSignature)
124 string Msg =
"Request Signature invalid.";
129 byte[] Signature = KeyEndpoint.
Sign(Data);
133 {
"Signature", Convert.ToBase64String(Signature) }
A Named dictionary is a dictionary, with a local name and a namespace. Use it to return content that ...
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...
Represents an HTTP request.
HttpRequestHeader Header
Request header.
Represets a response of an HTTP client request.
Task Return(Exception ex)
Returns an error to the client.
The server has not found anything matching the Request-URI. No indication is given of whether the con...
Abstract base class for Elliptic Curve endpoints.
override byte[] Sign(byte[] Data)
Signs binary data using the local private key.
Represents a case-insensitive string.
Static interface for database persistence. In order to work, a database provider has to be assigned t...
This filter selects objects that conform to all child-filters provided.
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.
static string LoadResourceAsText(string ResourceName)
Loads a text resource from an embedded resource.
Class managing a script expression.
Contains methods for simple hash calculations.
static byte[] ComputeHMACSHA256Hash(byte[] Key, byte[] Data)
Computes the HMAC-SHA-256 hash of a block of binary data.
string Password
Password of account
Account Account
Account object.
string UserName
User Name.
IdentityState State
Current state of identity
Legal (digital identities, smart contracts) service component.
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
Contains an encrypted key for an agent.
string Namespace
Namespace of algorithm
string LocalName
Local Name of algorithm
Applies for a new Legal ID
Signs binary data using a legal ID.
override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary< string, IElement > Parameters)
Executes the POST method on the resource.
override bool Synchronous
If the resource is synchronous (i.e. returns a response in the method handler), or if it is asynchron...
SignData()
Signs binary data using a legal ID.