2using System.Collections.Generic;
4using System.Threading.Tasks;
32 : base(
"Legal/PetitionSignature",
33 new KeyValuePair<Type,
Expression>(typeof(Dictionary<string, object>), new
Expression(jsonPattern)),
53 string KeyId = (string)Parameters[
"PKeyId"].AssociatedObjectValue;
54 if (
string.IsNullOrEmpty(KeyId))
81 string ContentBase64 = (string)Parameters[
"PContentBase64"].AssociatedObjectValue;
83 string PetitionId = (string)Parameters[
"PPetitionId"].AssociatedObjectValue;
84 string Purpose = (string)Parameters[
"PPurpose"].AssociatedObjectValue;
85 string KeySignature = (string)Parameters[
"PKeySignature"].AssociatedObjectValue;
86 string RequestSignature = (string)Parameters[
"PRequestSignature"].AssociatedObjectValue;
90 Content = Convert.FromBase64String(ContentBase64);
97 string s = Encoding.UTF8.GetString(Content);
98 if (s.StartsWith(
"<identity") && s.EndsWith(
"</identity>"))
99 throw new ForbiddenException(
"Use the PetitionPeerReview request to ask a peer to sign a legal identity.");
101 StringBuilder sb =
new StringBuilder();
116 sb.Append(KeySignature);
129 sb.Append(ContentBase64);
131 string s3 = sb.ToString();
133 s = Convert.ToBase64String(
136 Encoding.UTF8.GetBytes(s3)));
138 if (s != RequestSignature)
140 string Msg =
"Request Signature invalid.";
147 if (User.
UserName != Identity.Account)
152 LegalComponent.ClientInformation ClientInfo = await
XmppServerModule.Legal.GetNetworkIdentity(RemoteId,
true,
false, Identity.Version);
155 XmppServerModule.Legal.IdentityAuthorization(RemoteJid, From, LegalId,
true);
156 Dictionary<string, string> AttachmentUrls =
XmppServerModule.Legal.GetAttachmentUrls(Identity);
158 StringBuilder Msg =
new StringBuilder();
160 Msg.Append(
"<petitionSignatureMsg id=\"");
162 Msg.Append(
"\" pid=\"");
164 Msg.Append(
"\" from=\"");
166 Msg.Append(
"\" purpose=\"");
168 Msg.Append(
"\" clientEp=\"");
170 Msg.Append(
"\" xmlns=\"");
172 Msg.Append(
"\"><content>");
173 Msg.Append(ContentBase64);
174 Msg.Append(
"</content>");
175 Identity.Serialize(Msg,
false,
true,
true,
true,
true,
true,
true, AttachmentUrls,
XmppServerModule.Legal);
176 Msg.Append(
"</petitionSignatureMsg>");
A Named dictionary is a dictionary, with a local name and a namespace. Use it to return content that ...
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.
Helps with common XML-related tasks.
static string Encode(string s)
Encodes a string for use in XML.
Static class managing the runtime environment of the IoT Gateway.
static CaseInsensitiveString Domain
Domain name.
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.
string RemoteEndPoint
Remote end-point.
Represets a response of an HTTP client request.
async Task Return(object Object)
Returns an object to the client. This method can only be called once per response,...
The server has not found anything matching the Request-URI. No indication is given of whether the con...
XmppAddress MainDomain
Main/principal domain address
bool IsComponentDomain(CaseInsensitiveString Domain, bool IncludeAlternativeDomains)
Checks if a domain is the component domain, or optionally, an alternative component domain.
Contains information about one XMPP address.
bool IsBareJID
If the address is a Bare JID.
CaseInsensitiveString Domain
Domain
CaseInsensitiveString Address
XMPP Address
Task< bool > SendMessage(string Type, string Id, string From, string To, string Language, string ContentXml)
Sends a Message stanza to a recipient.
Represents a case-insensitive string.
static readonly CaseInsensitiveString Empty
Empty case-insensitive string
static bool IsNullOrEmpty(CaseInsensitiveString value)
Indicates whether the specified string is null or an CaseInsensitiveString.Empty string.
override string ToString()
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.
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.
Provisioning and registry service component.
static string NamespaceLegalIdentity(NamespaceSet Version)
Returns the namespace for legal identities.
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
Petitions access to a remote legal identity.
Petitions a remote entity to sign some data.
override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary< string, IElement > Parameters)
Executes the POST method on the resource.
PetitionSignature()
Petitions a remote entity to sign some data.
Service Module hosting the XMPP broker and its components.