Skip to content

Commit 08dda54

Browse files
checkpoint
1 parent e7a6b38 commit 08dda54

File tree

10 files changed

+1918
-1094
lines changed

10 files changed

+1918
-1094
lines changed

a10vthunder-orchestrator/Api/Models/ClientTemplateListResponse.cs

Lines changed: 574 additions & 119 deletions
Large diffs are not rendered by default.

a10vthunder-orchestrator/Api/Models/DeleteCertBaseRequest.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
1514
using Newtonsoft.Json;
16-
1715
namespace a10vthunder.Api.Models
1816
{
1917
public class DeleteCertBaseRequest
2018
{
21-
[JsonProperty("delete", NullValueHandling = NullValueHandling.Ignore)]
22-
public DeleteCertRequest DeleteCert { get; set; }
23-
19+
[JsonProperty("delete")]
20+
public DeleteCertRequest Delete { get; set; }
2421
}
25-
}
22+
}

a10vthunder-orchestrator/Api/Models/DeleteCertRequest.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
1514
using Newtonsoft.Json;
16-
1715
namespace a10vthunder.Api.Models
1816
{
1917
public class DeleteCertRequest
2018
{
21-
[JsonProperty("cert-name")]
22-
public string CertName { get; set; }
23-
24-
[JsonProperty("private-key",NullValueHandling=NullValueHandling.Ignore)]
19+
[JsonProperty("cert-name", NullValueHandling = NullValueHandling.Ignore)]
20+
public string CertName { get; set; }
21+
22+
[JsonProperty("private-key", NullValueHandling = NullValueHandling.Ignore)]
2523
public string PrivateKey { get; set; }
2624
}
27-
}
25+
}

a10vthunder-orchestrator/Api/Models/ManagementCertRequest.cs

Lines changed: 0 additions & 31 deletions
This file was deleted.

a10vthunder-orchestrator/Api/Models/ManagementCertRestartRequest.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

a10vthunder-orchestrator/Api/Models/ManagementPrivateKeyRequest.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 114 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,162 @@
1-
// Copyright 2025 Keyfactor
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
14-
15-
using Keyfactor.PKI.X509;
16-
using Newtonsoft.Json;
17-
using Newtonsoft.Json.Linq;
18-
using System;
1+
// Copyright 2025 Keyfactor
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
using Newtonsoft.Json;
195
using System.Collections.Generic;
20-
21-
22-
namespace a10vthunder.Api.Models
23-
{
24-
public class TemplateCertificate
25-
{
26-
public string cert { get; set; }
27-
public string key { get; set; }
28-
public string uuid { get; set; }
29-
30-
[JsonProperty("a10-url")]
31-
public string a10url { get; set; }
32-
}
33-
34-
public class ServerTemplateListResponse
35-
{
36-
[JsonProperty("server-ssl-list")]
37-
public List<ServerSslList> serverssllist { get; set; }
6+
7+
namespace a10vthunder.Api.Models
8+
{
9+
public class ServerCertificate
10+
{
11+
[JsonProperty("cert")]
12+
public string Cert { get; set; }
13+
14+
[JsonProperty("key")]
15+
public string Key { get; set; }
16+
17+
[JsonProperty("uuid")]
18+
public string Uuid { get; set; }
19+
20+
[JsonProperty("a10-url")]
21+
public string A10Url { get; set; }
3822
}
3923

4024
public class ServerSslList
4125
{
42-
public string name { get; set; }
26+
[JsonProperty("name")]
27+
public string Name { get; set; }
28+
29+
// v4 direct properties (will be null in v6)
30+
[JsonProperty("cert")]
31+
public string Cert { get; set; }
32+
33+
[JsonProperty("key")]
34+
public string Key { get; set; }
4335

4436
[JsonProperty("enable-tls-alert-logging")]
45-
public int enabletlsalertlogging { get; set; }
37+
public int? EnableTlsAlertLogging { get; set; }
4638

4739
[JsonProperty("handshake-logging-enable")]
48-
public int handshakeloggingenable { get; set; }
40+
public int? HandshakeLoggingEnable { get; set; }
4941

42+
// v6 specific property (will be null in v4)
5043
[JsonProperty("session-key-logging-enable")]
51-
public int sessionkeyloggingenable { get; set; }
44+
public int? SessionKeyLoggingEnable { get; set; }
5245

5346
[JsonProperty("close-notify")]
54-
public int closenotify { get; set; }
47+
public int? CloseNotify { get; set; }
5548

5649
[JsonProperty("forward-proxy-enable")]
57-
public int? forwardproxyenable { get; set; } // optional
50+
public int? ForwardProxyEnable { get; set; }
5851

5952
[JsonProperty("session-ticket-enable")]
60-
public int sessionticketenable { get; set; }
53+
public int? SessionTicketEnable { get; set; }
6154

62-
public int version { get; set; }
63-
public int dgversion { get; set; }
55+
[JsonProperty("version")]
56+
public int? Version { get; set; }
57+
58+
[JsonProperty("dgversion")]
59+
public int? DgVersion { get; set; }
6460

6561
[JsonProperty("ssli-logging")]
66-
public int? ssliLogging { get; set; } // optional
62+
public int? SsliLogging { get; set; }
63+
64+
// v4 specific property (will be null in v6)
65+
[JsonProperty("dh-short-key-action")]
66+
public string DhShortKeyAction { get; set; }
6767

6868
[JsonProperty("ocsp-stapling")]
69-
public int ocspstapling { get; set; }
69+
public int? OcspStapling { get; set; }
7070

7171
[JsonProperty("use-client-sni")]
72-
public int useclientsni { get; set; }
72+
public int? UseClientSni { get; set; }
7373

7474
[JsonProperty("renegotiation-disable")]
75-
public int renegotiationdisable { get; set; }
75+
public int? RenegotiationDisable { get; set; }
7676

7777
[JsonProperty("session-cache-size")]
78-
public int sessioncachesize { get; set; }
78+
public int? SessionCacheSize { get; set; }
7979

80+
// v6 specific property (will be null in v4)
8081
[JsonProperty("early-data")]
81-
public int earlydata { get; set; }
82+
public int? EarlyData { get; set; }
8283

83-
public string uuid { get; set; }
84+
[JsonProperty("uuid")]
85+
public string Uuid { get; set; }
8486

87+
// v6 has certificate object, v4 has direct cert/key
8588
[JsonProperty("certificate")]
86-
[JsonConverter(typeof(CertificateConverter))]
87-
public TemplateCertificate certificate { get; set; }
89+
public ServerCertificate Certificate { get; set; }
8890

89-
[JsonProperty("cert")]
90-
public string certFlat { get; set; }
91+
[JsonProperty("a10-url")]
92+
public string A10Url { get; set; }
9193

92-
[JsonProperty("key")]
93-
public string keyFlat { get; set; }
94+
// Helper methods to work with both formats (consistent with client model)
95+
public string GetCertificate()
96+
{
97+
// v4 format - direct cert property
98+
if (!string.IsNullOrEmpty(Cert))
99+
return Cert;
94100

95-
[JsonProperty("a10-url")]
96-
public string a10url { get; set; }
97-
98-
[JsonIgnore]
99-
public TemplateCertificate MergedCertificate => certificate ?? (
100-
certFlat != null && keyFlat != null
101-
? new TemplateCertificate { cert = certFlat, key = keyFlat, uuid = uuid, a10url = a10url + "/certificate" }
102-
: null
103-
);
104-
}
101+
// v6 format - certificate object
102+
if (Certificate != null && !string.IsNullOrEmpty(Certificate.Cert))
103+
return Certificate.Cert;
105104

106-
public class CertificateConverter : JsonConverter<TemplateCertificate>
107-
{
108-
public override TemplateCertificate ReadJson(JsonReader reader, Type objectType, TemplateCertificate existingValue, bool hasExistingValue, JsonSerializer serializer)
105+
return null;
106+
}
107+
108+
public string GetKey()
109+
{
110+
// v4 format - direct key property
111+
if (!string.IsNullOrEmpty(Key))
112+
return Key;
113+
114+
// v6 format - certificate object
115+
if (Certificate != null && !string.IsNullOrEmpty(Certificate.Key))
116+
return Certificate.Key;
117+
118+
return null;
119+
}
120+
121+
public ServerCertificate GetCertificateObject()
109122
{
110-
JObject obj = JObject.Load(reader);
123+
// v6 format - return certificate object directly
124+
if (Certificate != null)
125+
return Certificate;
111126

112-
// Case 1: certificate is a full object
113-
if (obj["cert"] != null && obj["key"] != null)
127+
// v4 format - create certificate object from direct properties
128+
if (!string.IsNullOrEmpty(Cert) || !string.IsNullOrEmpty(Key))
114129
{
115-
return obj.ToObject<TemplateCertificate>();
130+
return new ServerCertificate
131+
{
132+
Cert = Cert,
133+
Key = Key,
134+
Uuid = Uuid,
135+
A10Url = A10Url?.EndsWith("/certificate") == true
136+
? A10Url
137+
: A10Url + "/certificate"
138+
};
116139
}
117140

118-
// If the certificate node is not an object (e.g., null or primitive), fallback
119141
return null;
120142
}
121143

122-
public override void WriteJson(JsonWriter writer, TemplateCertificate value, JsonSerializer serializer)
144+
// Check if this is v4 format
145+
public bool IsV4Format()
123146
{
124-
serializer.Serialize(writer, value);
147+
return !string.IsNullOrEmpty(Cert) || !string.IsNullOrEmpty(Key) || !string.IsNullOrEmpty(DhShortKeyAction);
125148
}
149+
150+
// Check if this is v6 format
151+
public bool IsV6Format()
152+
{
153+
return Certificate != null || SessionKeyLoggingEnable.HasValue || EarlyData.HasValue;
154+
}
155+
}
156+
157+
public class ServerTemplateListResponse
158+
{
159+
[JsonProperty("server-ssl-list")]
160+
public List<ServerSslList> ServerSslList { get; set; }
126161
}
127-
128-
}
162+
}

0 commit comments

Comments
 (0)