4using System.Threading.Tasks;
34 : base(
"Legal/ProposeTemplate",
35 new KeyValuePair<Type,
Expression>(typeof(Dictionary<string, object>), new
Expression(jsonPattern)),
55 string TemplateBase64 = (string)Parameters[
"PTemplateBase64"].AssociatedObjectValue;
57 string TemplateXmlString;
58 XmlDocument TemplateXml;
64 TemplateBin = Convert.FromBase64String(TemplateBase64);
75 TemplateXml =
XML.
ParseXml(TemplateXmlString,
true);
79 throw new BadRequestException(
"Invalid template XML, or encoding of template XML: " + ex.Message);
91 Template = Parsed.Contract
100 if (!(Template.ClientSignatures is
null) && Template.ClientSignatures.Length > 0)
103 if (!(Template.ServerSignature is
null))
106 if (Template.PartsMode ==
ContractParts.ExplicitlyDefined && (Template.Parts is
null || Template.Parts.Length == 0))
118 LegalDomain =
"legal.example.com";
121 string Errors = await
XmppServerModule.Legal?.CheckContentIntegrity(Template);
122 if (!
string.IsNullOrEmpty(Errors))
126 ??
throw new ForbiddenException(Request,
"No current approved legal identity found for account.");
129 if (!
string.IsNullOrEmpty(Errors))
136 Template.Provider = LegalDomain;
139 Template.Updated = DateTime.MinValue;
143 Template.ContractId = Template.ObjectId +
"@" + Template.Provider;
148 if (Template.CanActAsTemplate)
153 KeyValuePair<string, object>[] Tags = Template.GetTags();
154 string FromJid = User.UserName +
"@" + Request.
Host;
156 Log.
Notice(
"Contract proposal registered.",
161 StringBuilder Markdown =
new StringBuilder();
163 Markdown.Append(
"Contract proposal received: [");
165 Markdown.Append(
"](");
167 Markdown.AppendLine(
")");
168 Markdown.AppendLine();
179 StringBuilder Xml =
new StringBuilder();
181 TemplateXmlString = Xml.ToString();
183 TemplateXml =
XML.
ParseXml(TemplateXmlString,
true);
187 {
"Template", TemplateXml },
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 ...
Helps with common XML-related tasks.
static XmlDocument ParseXml(string Xml)
Parses an XML Document from its string representation.
Static class managing the application event log. Applications and services log events on this static ...
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a notice 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.
Task Return(Exception ex)
Returns an error to the client.
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.
Static class managing persistent counters.
static Task< long > IncrementCounter(CaseInsensitiveString Key)
Increments a counter.
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 binary representations of strings.
static string GetString(byte[] Data, int Offset, int Count, Encoding DefaultEncoding)
Gets a string from its binary representation, taking any Byte Order Mark (BOM) into account.
Class managing a script expression.
string UserName
User Name.
Contains the definition of a contract
async Task 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.
static async Task< ParsedContract > Parse(XmlElement Xml, LegalComponent Legal)
Parses a contract from is XML representation.
CaseInsensitiveString ContractId
Contract Identity
Contains information about a parsed contract.
bool HasStatus
If a status element was found.
CaseInsensitiveString Provider
Provider where the identity is maintained.
Legal (digital identities, smart contracts) service component.
static DateTime UtcNowSecond
Current Date & Time (in UTC), to a precision of one second.
Task< LegalIdentity > GetCurrentApprovedLegalIdentityAsync(CaseInsensitiveString Account)
Gets the current approved legal identity for an account.
Provides the user with options to control notifications from the Broker.
static BrokerNotificationConfiguration Instance
Current instance of configuration.
bool ContractProposalReceived
If a notification should be sent when a contract proposal has been received.
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