Skip to content

Commit f411425

Browse files
committed
Add trustlist.xml reading
1 parent b31857e commit f411425

4 files changed

Lines changed: 426 additions & 4 deletions

File tree

src/AasSecurity/SecuritySettingsForServerParser.cs

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
using System;
1515
using System.Buffers.Text;
1616
using System.Security.Cryptography.X509Certificates;
17+
using System.Xml;
18+
using System.Xml.Linq;
1719
using AasSecurity.Models;
1820
using AasxServer;
1921
using AdminShellNS;
@@ -145,14 +147,97 @@ private static void ParseAuthenticationServer(AdminShellPackageEnv env, Submodel
145147
GlobalSecurityVariables.ServerCertFileNames.Add(serverName + ".cer");
146148
GlobalSecurityVariables.ServerDomain.Add(domain);
147149
GlobalSecurityVariables.ServerJwksUrl.Add("");
148-
GlobalSecurityVariables.ServerKid.Add("");
150+
GlobalSecurityVariables.ServerKid.Add("");
149151
}
150152
else if (insideBas64)
151153
{
152154
base64 += line;
153155
}
154156
}
155157
}
158+
}
159+
else if (System.IO.File.Exists("trustlist.xml"))
160+
{
161+
Console.WriteLine("Read trustlist.xml");
162+
163+
164+
// Load the XML
165+
var doc = XDocument.Load("trustlist.xml");
166+
167+
// Default ETSI namespace present in the document
168+
XNamespace ns = "http://uri.etsi.org/02231/v2#"; // <- critical
169+
// (There's also an XMLDSIG signature later in a different ns; we can ignore it.)
170+
171+
XNamespace nsDs = "http://www.w3.org/2000/09/xmldsig#"; // XMLDSIG ns (for <Signature>)
172+
173+
174+
// Navigate to <TrustServiceProviderList>
175+
var tspList = doc
176+
.Root // <TrustServiceStatusList>
177+
?.Element(ns + "TrustServiceProviderList"); // <TrustServiceProviderList>
178+
179+
180+
// Enumerate <TrustServiceProvider>
181+
var providers = tspList.Elements(ns + "TrustServiceProvider")
182+
.Select(tsp => new
183+
{
184+
TspName = tsp
185+
.Element(ns + "TSPInformation")
186+
?.Element(ns + "TSPName")
187+
?.Elements(ns + "Name")
188+
.Select(n => (string)n)
189+
.FirstOrDefault(),
190+
191+
Domain = tsp
192+
.Element(ns + "TSPInformation")
193+
?.Element(ns + "TSPInformationExtensions")
194+
?.Elements(ns + "Extension")
195+
.Elements(ns + "TSPDomainName")
196+
.Select(x => (string)x)
197+
.FirstOrDefault(),
198+
199+
// Grab one service’s basics (if available)
200+
Service = tsp
201+
.Element(ns + "TSPServices")
202+
?.Elements(ns + "TSPService")
203+
.Select(svc => new
204+
{
205+
Type = (string)svc
206+
.Element(ns + "ServiceInformation")
207+
?.Element(ns + "ServiceTypeIdentifier"),
208+
209+
Name = svc
210+
.Element(ns + "ServiceInformation")
211+
?.Element(ns + "ServiceName")
212+
?.Elements(ns + "Name")
213+
.Select(n => (string)n)
214+
.FirstOrDefault(),
215+
216+
SupplyPoint = svc
217+
.Element(ns + "ServiceInformation")
218+
?.Element(ns + "ServiceSupplyPoints")
219+
?.Elements(ns + "ServiceSupplyPoint")
220+
.Select(sp => (string)sp)
221+
.FirstOrDefault()
222+
})
223+
.FirstOrDefault()
224+
})
225+
.ToList();
226+
227+
foreach (var provider in providers)
228+
{
229+
var serverName = provider?.Service?.Name;
230+
var domain = provider?.Domain;
231+
var jwks = provider?.Service?.SupplyPoint;
232+
var kid = "";
233+
234+
GlobalSecurityVariables.ServerCertificates.Add(null);
235+
GlobalSecurityVariables.ServerCertFileNames.Add("");
236+
GlobalSecurityVariables.ServerCertFileNames.Add(serverName + ".cer");
237+
GlobalSecurityVariables.ServerDomain.Add(domain);
238+
GlobalSecurityVariables.ServerJwksUrl.Add(jwks);
239+
GlobalSecurityVariables.ServerKid.Add(kid);
240+
}
156241
}
157242
if (authServer == null || authServer.Value == null)
158243
{

src/AasxServerBlazor/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"AasxServerBlazor": {
1212
"commandName": "Project",
13-
"commandLineArgs": "--with-db --start-index 1000 --secret-string-api 1234 --data-path \"C:\\Development\\p5\" --edit --external-blazor http://localhost:5001",
13+
"commandLineArgs": "--with-db --start-index 0 --secret-string-api 1234 --data-path \"C:\\Users\\ee924l\\Documents\\aas\\mqtt\" --edit --external-blazor http://localhost:5001",
1414
"launchBrowser": true,
1515
"environmentVariables": {
1616
"ASPNETCORE_ENVIRONMENT": "Development",

src/AasxServerBlazor/Shared/MainLayout.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@
8383
<div class="self-center">
8484
<div class="flex items-stretch">
8585
<img src="zvei_2021_RZ_RGB.png" style="max-width: 100px; display: inline; object-fit: contain;" alt="zvei logo"/>
86-
<img src="Logo_IDTA.jpg" style=" max-width: 100px; display: inline; object-fit: contain; margin-top: 20px" alt="Logo of IDTA"/>
86+
<img src="Logo_IDTA.jpg" style=" max-width: 100px; display: inline; object-fit: contain; margin-top: 18px" alt="Logo of IDTA"/>
8787
@if (!Program.showWeight)
8888
{
89-
<span hspace=20 style="padding-left:15px; padding-right:5px; font-size:medium;" class="self-center">
89+
<span hspace=20 style="padding-left:15px; padding-right:5px; font-size:large;" class="self-center">
9090
<strong>Product Carbon Footprint Showcase</strong>
9191
</span>
9292
}

0 commit comments

Comments
 (0)