Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AcmeAuthorization.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
4using Waher.Content;
6
8{
13 {
17 pending,
18
22 valid,
23
27 invalid,
28
32 deactivated,
33
37 expired,
38
42 revoked
43 };
44
49 {
50 private readonly AcmeAuthorizationStatus status;
51 private readonly DateTime? expires = null;
52 private readonly AcmeChallenge[] challenges = null;
53 private readonly string type = null;
54 private readonly string value = null;
55 private readonly bool? wildcard = null;
56
57 internal AcmeAuthorization(AcmeClient Client, Uri AccountLocation, Uri Location, IEnumerable<KeyValuePair<string, object>> Obj)
59 {
60 foreach (KeyValuePair<string, object> P in Obj)
61 {
62 switch (P.Key)
63 {
64 case "status":
65 if (!Enum.TryParse(P.Value as string, out this.status))
66 throw new ArgumentException("Invalid ACME authorization status: " + P.Value.ToString(), "status");
67 break;
68
69 case "expires":
70 if (XML.TryParse(P.Value as string, out DateTime TP))
71 this.expires = TP;
72 else
73 throw new ArgumentException("Invalid date and time value.", "expires");
74 break;
75
76 case "identifier":
77 if (P.Value is IEnumerable<KeyValuePair<string, object>> Obj2)
78 {
79 foreach (KeyValuePair<string, object> P2 in Obj2)
80 {
81 switch (P2.Key)
82 {
83 case "type":
84 this.type = P2.Value as string;
85 break;
86
87 case "value":
88 this.value = P2.Value as string;
89 break;
90 }
91 }
92 }
93 break;
94
95 case "challenges":
96 if (P.Value is Array A2)
97 {
98 List<AcmeChallenge> Challenges = new List<AcmeChallenge>();
99
100 foreach (object Obj3 in A2)
101 {
102 if (Obj3 is IEnumerable<KeyValuePair<string, object>> Obj4)
103 Challenges.Add(this.Client.CreateChallenge(AccountLocation, Obj4));
104 }
105
106 this.challenges = Challenges.ToArray();
107 }
108 break;
109
110 case "wildcard":
111 if (CommonTypes.TryParse(P.Value as string, out bool b))
112 this.wildcard = b;
113 else
114 throw new ArgumentException("Invalid boolean value.", "wildcard");
115 break;
116 }
117 }
118 }
119
123 public string Type => this.type;
124
128 public string Value => this.value;
129
133 public AcmeAuthorizationStatus Status => this.status;
134
138 public DateTime? Expires => this.expires;
139
144 public AcmeChallenge[] Challenges => this.challenges;
145
150 public bool? Wildcard => this.wildcard;
151
156 public Task<AcmeAuthorization> Poll()
157 {
158 return this.Client.GetAuthorization(this.AccountLocation, this.Location);
159 }
160
165 public Task<AcmeAuthorization> Deactivate()
166 {
167 return this.Client.DeactivateAuthorization(this.AccountLocation, this.Location);
168 }
169
170 }
171}
Helps with parsing of commong data types.
Definition: CommonTypes.cs:13
static bool TryParse(string s, out double Value)
Tries to decode a string encoded double.
Definition: CommonTypes.cs:46
Helps with common XML-related tasks.
Definition: XML.cs:19
static bool TryParse(string s, out DateTime Value)
Tries to decode a string encoded DateTime.
Definition: XML.cs:744
Represents an ACME authorization.
Task< AcmeAuthorization > Poll()
Gets the current state of the order.
string Value
The identifier itself.
Task< AcmeAuthorization > Deactivate()
Deactivates the authorization.
AcmeChallenge[] Challenges
For pending authorizations, the challenges that the client can fulfill in order to prove possession o...
bool? Wildcard
For authorizations created as a result of a newOrder request containing a DNS identifier with a value...
string Type
The type of identifier.
AcmeAuthorizationStatus Status
The status of this authorization.
DateTime? Expires
The timestamp after which the server will consider this authorization invalid
Base class of all ACME challenges.
Implements an ACME client for the generation of certificates using ACME-compliant certificate servers...
Definition: AcmeClient.cs:24
async Task< AcmeAuthorization > DeactivateAuthorization(Uri AccountLocation, Uri AuthorizationLocation)
Deactivates an authorization.
Definition: AcmeClient.cs:625
async Task< AcmeAuthorization > GetAuthorization(Uri AccountLocation, Uri AuthorizationLocation)
Gets the state of an authorization.
Definition: AcmeClient.cs:613
AcmeClient Client
ACME client.
Definition: AcmeObject.cs:26
Abstract base class for all ACME resources.
Definition: AcmeResource.cs:11
Uri Location
Location of resource.
Definition: AcmeResource.cs:37
Uri AccountLocation
Account location.
Definition: AcmeResource.cs:31
AcmeAuthorizationStatus
ACME Authorization status enumeration