2using System.Collections.Generic;
4using System.Threading.Tasks;
30 : base(
"Legal/ProposeTemplate",
31 new KeyValuePair<Type,
Expression>(typeof(Dictionary<string, object>), new
Expression(jsonPattern)),
51 string TemplateBase64 = (string)Parameters[
"PTemplateBase64"].AssociatedObjectValue;
53 string TemplateXmlString;
54 XmlDocument TemplateXml;
60 TemplateBin = Convert.FromBase64String(TemplateBase64);
71 TemplateXml =
new XmlDocument()
73 PreserveWhitespace =
true
76 TemplateXml.LoadXml(TemplateXmlString);
80 throw new BadRequestException(
"Invalid template XML, or encoding of template XML: " + ex.Message);
92 Template = Parsed.Contract
101 if (!(Template.ClientSignatures is
null) && Template.ClientSignatures.Length > 0)
104 if (!(Template.ServerSignature is
null))
107 if (Template.PartsMode ==
ContractParts.ExplicitlyDefined && (Template.Parts is
null || Template.Parts.Length == 0))
119 LegalDomain =
"legal.example.com";
122 string Errors = await
XmppServerModule.Legal?.CheckContentIntegrity(Template);
123 if (!
string.IsNullOrEmpty(Errors))
127 ??
throw new ForbiddenException(
"No current approved legal identity found for account.");
130 if (!
string.IsNullOrEmpty(Errors))
133 LegalDomain = Identity.Provider;
137 Template.Provider = LegalDomain;
140 Template.Updated = DateTime.MinValue;
144 Template.ContractId = Template.ObjectId +
"@" + Template.Provider;
149 KeyValuePair<string, object>[] Tags = Template.GetTags();
150 string FromJid = User.UserName +
"@" + Request.
Host;
155 StringBuilder Markdown =
new StringBuilder();
157 Markdown.Append(
"Contract proposal received: [");
159 Markdown.Append(
"](");
161 Markdown.AppendLine(
")");
162 Markdown.AppendLine();
172 StringBuilder Xml =
new StringBuilder();
174 TemplateXmlString = Xml.ToString();
176 TemplateXml =
new XmlDocument()
178 PreserveWhitespace =
true
180 TemplateXml.LoadXml(TemplateXmlString);
184 {
"Template", TemplateXml },
Helps with parsing of commong data types.
static string GetString(byte[] Data, Encoding DefaultEncoding)
Gets a string from its binary representation, taking any Byte Order Mark (BOM) into account.
Contains a markdown document. This markdown document class supports original markdown,...
static string Encode(string s)
Encodes all special characters in a string so that it can be included in a markdown document without ...
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.
Static class managing the application event log. Applications and services log events on this static ...
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
Static class managing the runtime environment of the IoT Gateway.
static Task SendNotification(Graph Graph)
Sends a graph as a notification message to configured notification recipients.
static string GetUrl(string LocalResource)
Gets a URL for a resource.
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.
string Host
Host reference. (Value of Host header, without the port number)
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,...
Represents a case-insensitive string.
string Value
String-representation of the case-insensitive string. (Representation is case sensitive....
static bool IsNullOrEmpty(CaseInsensitiveString value)
Indicates whether the specified string is null or an CaseInsensitiveString.Empty string.
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static async Task Update(object Object)
Updates an object in the database.
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
Class managing a script expression.
string UserName
User Name.
Contains the definition of a contract
static async Task< ParsedContract > Parse(XmlElement Xml, LegalComponent Legal)
Parses a contract from is XML representation.
void Serialize(StringBuilder Xml, bool IncludeNamespace, bool IncludeIdAttribute, bool IncludeClientSignatures, bool IncludeAttachments, bool IncludeStatus, bool IncludeServerSignature, bool IncludeAttachmentReferences, Dictionary< string, string > AttachmentsUrls, LegalComponent LegalComponent)
Serializes the Contract, in normalized form.
CaseInsensitiveString ContractId
Contract Identity
Contains information about a parsed contract.
bool HasStatus
If a status element was found.
Provisioning and registry service component.
static DateTime NowSecond
Current Date & Time, to a precision of one second.
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
Proposes a new contract template.
ProposeTemplate()
Proposes a new contract template.
override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary< string, IElement > Parameters)
Executes the POST method on the resource.
Service Module hosting the XMPP broker and its components.
ContractState
Recognized contract states
ContractParts
How the parts of the contract are defined.
Represents a duration value, as defined by the xsd:duration data type: http://www....
static readonly Duration Zero
Zero value