-
Notifications
You must be signed in to change notification settings - Fork 73
/
AcmeAccount.cs
77 lines (64 loc) · 2.24 KB
/
AcmeAccount.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System.Collections.Generic;
using ACMESharp.Protocol.Resources;
namespace ACMESharp
{
/// <summary>
/// Represents the details of a registered ACME Account with a specific ACME CA.
/// </summary>
public class AcmeAccount : AcmeAccount.IAccountDetails
{
private Account _account;
public AcmeAccount(Account account, string kid, string tosLink)
{
_account = account;
Kid = kid;
TosLink = tosLink;
}
Account IAccountDetails.AccountDetails => _account;
public IEnumerable<string> Contacts => _account?.Contact;
public object PublicKey => _account?.Key;
/// <summary>
/// This is the Key Identifier used in most messages sent to the ACME CA after
/// the initial Account registration. It references the public key that was
/// registered with the Account in the JWS-signed Account create message.
/// </summary>
/// <remarks>
/// https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-6.2
/// https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.3
/// <para>
/// The KID is returned as a <c>Location</c> header in the Account
/// creation response.
/// </para>
/// </remarks>
/// <returns></returns>
public string Kid { get; }
public string TosLink { get; }
/// <summary>
/// CA-assigned unique identifier for the Account.
/// </summary>
/// <returns></returns>
public string Id => _account?.Id;
public AccountStatus Status { get; }
public AccountStatus GeStatus()
{
switch (_account?.Status)
{
case "valid": return AccountStatus.Valid;
case "deactivated": return AccountStatus.Deactivated;
case "revoked": return AccountStatus.Revoked;
default: return AccountStatus.Unknown;
}
}
public enum AccountStatus
{
Unknown = 0,
Valid = 1,
Deactivated = 2,
Revoked = 3,
}
public interface IAccountDetails
{
Account AccountDetails { get; }
}
}
}