3using System.Threading.Tasks;
22 : base(
"/ProposeContract")
56 throw new NotSupportedException(
"Proposing new contracts not permitted. Broker does not support smart contracts.");
64 if (
Posted is XmlDocument Doc)
75 StringBuilder sb =
new StringBuilder();
79 Doc =
new XmlDocument()
81 PreserveWhitespace =
true
83 Doc.LoadXml(Xml = sb.ToString());
85 ParsedContract.Contract.ForMachines = Doc.DocumentElement;
89 else if (
Posted is
bool Command)
103 PageVariables[
"Contract"] =
Contract;
106 PageVariables.
Remove(
"Contract");
111 catch (XmlException ex)
Helps with common XML-related tasks.
static XmlException AnnotateException(XmlException ex)
Creates a new XML Exception object, with reference to the source XML file, for information.
Static class managing the runtime environment of the IoT Gateway.
static IUser AssertUserAuthenticated(HttpRequest Request, string Privilege)
Makes sure a request is being made from a session with a successful user login.
static ContractsClient ContractsClient
XMPP Contracts Client, if such a compoent is available on the XMPP broker.
Proposes a new smart contract
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
ProposeContract()
Proposes a new smart contract
override bool UserSessions
If the resource uses user sessions.
bool AllowsPOST
If the POST method is allowed.
override bool HandlesSubPaths
If the resource handles sub-paths.
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.
bool HasData
If the request has data.
Variables Session
Contains session states, if the resource requires sessions, or null otherwise.
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Represets a response of an HTTP client request.
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
static Variables GetPageVariables(HttpRequest Request)
Gets the variable collection for the current page.
Decoded data posted to the resource
Contains the definition of a contract
static Task< ParsedContract > Parse(XmlDocument Xml)
Validates a contract XML Document, and returns the contract definition in it.
Parameter[] Parameters
Defined parameters for the smart contract.
Duration? ArchiveRequired
Requied time to archive a signed smart contract, after it becomes obsolete.
HumanReadableText[] ForHumans
Human-readable contents of the contract.
Duration? ArchiveOptional
Optional time to archive a signed smart contract, after it becomes obsolete, and after its required a...
bool CanActAsTemplate
If the contract can act as a template for other contracts.
XmlElement ForMachines
Machine-readable contents of the contract.
Role[] Roles
Roles defined in the smart contract.
DateTime? SignAfter
Signatures will only be accepted after this point in time.
ContractParts PartsMode
How parts are defined in the smart contract.
static string NormalizeXml(string Xml)
Normalizes XML.
Part[] Parts
Defined parts for the smart contract.
Duration? Duration
Duration of the contract. Is counted from the time it is signed by the required parties.
DateTime? SignBefore
Signatures will only be accepted until this point in time.
string Namespace
Namespace used when serializing the identity for signatures.
ContractVisibility Visibility
Contrat Visibility
Task< Contract > CreateContractAsync(XmlElement ForMachines, HumanReadableText[] ForHumans, Role[] Roles, Part[] Parts, Parameter[] Parameters, ContractVisibility Visibility, ContractParts PartsMode, Duration? Duration, Duration? ArchiveRequired, Duration? ArchiveOptional, DateTime? SignAfter, DateTime? SignBefore, bool CanActAsTemplate)
Creates a new contract.
Contains information about a parsed contract.
bool ParametersValid
If parameter values in the contract are valid.
bool HasStatus
If a status element was found.
Contract Contract
Contract object
Contains information about a variable.
virtual bool TryGetVariable(string Name, out Variable Variable)
Tries to get a variable object, given its name.
virtual bool Remove(string VariableName)
Removes a varaiable from the collection.
POST Interface for HTTP resources.
ContractParts
How the parts of the contract are defined.