diff --git a/Projects/Config/WebClient.Operation.Config.json b/Projects/Config/WebClient.Operation.Config.json index 00f01e5..65177d9 100644 --- a/Projects/Config/WebClient.Operation.Config.json +++ b/Projects/Config/WebClient.Operation.Config.json @@ -9,7 +9,12 @@ { "Id": 1, "ApiName": "CPMetaWbms", - "Host": "192.168.0.126:9000" + "Host": "192.168.0.126:9000" + }, + { + "Id": 2, + "ApiNmae": "ProxyKms", + "Host": "https://127.0.0.1:9200" } ] } \ No newline at end of file diff --git a/Projects/WebApi/WebApi.Project.ProxyKMS/.config/dotnet-tools.json b/Projects/WebApi/WebApi.Project.ProxyKMS/.config/dotnet-tools.json new file mode 100644 index 0000000..a74bf0b --- /dev/null +++ b/Projects/WebApi/WebApi.Project.ProxyKMS/.config/dotnet-tools.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "10.0.2", + "commands": [ + "dotnet-ef" + ], + "rollForward": false + } + } +} \ No newline at end of file diff --git a/Projects/WebApi/WebApi.Project.ProxyKMS/Models/Packet.cs b/Projects/WebApi/WebApi.Project.ProxyKMS/Models/Packet.cs index 40b889d..032369e 100644 --- a/Projects/WebApi/WebApi.Project.ProxyKMS/Models/Packet.cs +++ b/Projects/WebApi/WebApi.Project.ProxyKMS/Models/Packet.cs @@ -31,7 +31,7 @@ namespace WebApi.Project.ProxyKMS.Models } public class Response_SupplierKeyProvisioning : Response_Common { - public SupplierKeyProvisioningRecords Records { get; set; } = new SupplierKeyProvisioningRecords(); + public List Records { get; set; } = new List(); #region record public class SupplierKeyProvisioningRecords @@ -70,7 +70,7 @@ namespace WebApi.Project.ProxyKMS.Models } public class Response_SupplierKeyProvisioning : Response_Common { - public SupplierKeyProvisioningRecords Records { get; set; } = new SupplierKeyProvisioningRecords(); + public List Records { get; set; } = new List(); #region record public class SupplierKeyProvisioningRecords @@ -104,7 +104,7 @@ namespace WebApi.Project.ProxyKMS.Models } public class Response_SupplierKeySyncValue : Response_Common { - public SupplierKeySyncValueRecords Records { get; set; } = new SupplierKeySyncValueRecords(); + public List Records { get; set; } = new List(); #region record public class SupplierKeySyncValueRecords @@ -143,7 +143,7 @@ namespace WebApi.Project.ProxyKMS.Models } public class Response_SupplierKeyProvisioning : Response_Common { - public SupplierKeyProvisioningRecords Records { get; set; } = new SupplierKeyProvisioningRecords(); + public List Records { get; set; } = new List(); #region record public class SupplierKeyProvisioningRecords @@ -179,7 +179,7 @@ namespace WebApi.Project.ProxyKMS.Models } public class Response_SupplierKeySyncValue : Response_Common { - public SupplierKeySyncValueRecords Records { get; set; } = new SupplierKeySyncValueRecords(); + public List Records { get; set; } = new List(); #region record public class SupplierKeySyncValueRecords diff --git a/Projects/WebClient/Web.Operation/Components/Layout/MainLayout.razor b/Projects/WebClient/Web.Operation/Components/Layout/MainLayout.razor index beae606..078967a 100644 --- a/Projects/WebClient/Web.Operation/Components/Layout/MainLayout.razor +++ b/Projects/WebClient/Web.Operation/Components/Layout/MainLayout.razor @@ -15,6 +15,7 @@ + diff --git a/Projects/WebClient/Web.Operation/Components/Pages/ProxyKMS.razor b/Projects/WebClient/Web.Operation/Components/Pages/ProxyKMS.razor new file mode 100644 index 0000000..6b736f1 --- /dev/null +++ b/Projects/WebClient/Web.Operation/Components/Pages/ProxyKMS.razor @@ -0,0 +1,66 @@ +@page "/ProxyKMS" + +@using Web.Operation.Packet +@using Web.Operation.Module + +@inject ConfigService _configService + +

ProxyKMS

+
+ + + + +
+ + + + +
+ + +
+
+ + + + +
+ + +
+ + +
+ + +
+
+ + + + +
+ + +
+ + +
+ + +
+
+ +@code { + public string ApiAddress { get; set; } + + protected override async Task OnInitializedAsync() + { + var findApi = _configService.GetConfig().Api.Find(x => x.Id == 2); + if(findApi is not null) + { + ApiAddress = findApi.Host; + } + } +} diff --git a/Projects/WebClient/Web.Operation/Module/ProxyKmsModule.razor b/Projects/WebClient/Web.Operation/Module/ProxyKmsModule.razor new file mode 100644 index 0000000..cbbba3e --- /dev/null +++ b/Projects/WebClient/Web.Operation/Module/ProxyKmsModule.razor @@ -0,0 +1,75 @@ +@using Newtonsoft.Json +@using Radzen.Blazor +@using Web.Operation.Services + +@typeparam TRequest where TRequest : class, new() +@typeparam TResponse where TResponse : class, new() + +@inject ProxyKMSService _proxyKmsService + +
+ @Title +
+
+
+
+ Request + @($"[{Method}]") + + Send +
+
+ +
+
+
+
+ Response +
+
+ +
+
+
+
+
+ +@code { + [Parameter] + public string Title { get; set; } + + [Parameter] + public string Method { get; set; } + + [Parameter] + public string Url { get; set; } + + + public string Request{ get; set; } + + public string Response{ get; set; } + + protected override async Task OnInitializedAsync() + { + var request = new TRequest(); + Request = request.ToJson(); + } + + private async Task OnClickSend() + { + var req = JsonConvert.DeserializeObject(Request); + TResponse res = new TResponse(); + + if(Method.ToLower() == "post") + { + res = await _proxyKmsService.PostKms($"{Url}", req); + } + else if(Method.ToLower() == "put") + { + res = await _proxyKmsService.PutKms($"{Url}", req); + } + + + Response = res.ToJson(); + } +} diff --git a/Projects/WebClient/Web.Operation/Packet/ProxyKmsPacket.cs b/Projects/WebClient/Web.Operation/Packet/ProxyKmsPacket.cs new file mode 100644 index 0000000..75e2baf --- /dev/null +++ b/Projects/WebClient/Web.Operation/Packet/ProxyKmsPacket.cs @@ -0,0 +1,213 @@ +namespace Web.Operation.Packet +{ + //1. EcuID + public class EcuID + { + public class Request_SupplierEcuID + { + public string EcuType { get; set; } = string.Empty; + public string Phase { get; set; } = string.Empty; + public string SupplierID { get; set; } = string.Empty; + public string EcuID { get; set; } = string.Empty; + public string Serial { get; set; } = string.Empty; + } + + public class Response_SupplierEcuID : Response_Common + { + } + } + + //2. MasterECUKey + public class MasterEcuKey + { + public class Request_SupplierKeyProvisioning + { + public string ProvisioningType { get; set; } = string.Empty; + public string EcuID { get; set; } = string.Empty; + public string KeyID { get; set; } = string.Empty; + } + public class Response_SupplierKeyProvisioning : Response_Common + { + public List Records { get; set; } = new List(); + + #region record + public class SupplierKeyProvisioningRecords + { + public string KeyID { get; set; } = string.Empty; + public string M1 { get; set; } = string.Empty; + public string M2 { get; set; } = string.Empty; + public string M3 { get; set; } = string.Empty; + public string M4 { get; set; } = string.Empty; + public string M5 { get; set; } = string.Empty; + } + #endregion + } + + // + public class Request_SupplierKeyProvisioning_Result + { + public string ProvisioningType { get; set; } = string.Empty; + public string EcuID { get; set; } = string.Empty; + public string ResultMessage { get; set; } = string.Empty; + public string ResultStatus { get; set; } = string.Empty; + } + public class Response_SupplierKeyProvisioning_Result : Response_Common + { + } + } + + //3. SupplierSymmKey + public class SupplierSymmKey + { + public class Request_SupplierKeyProvisioning + { + public string ProvisioningType { get; set; } = string.Empty; + public string EcuID { get; set; } = string.Empty; + public string KeyID { get; set; } = string.Empty; + } + public class Response_SupplierKeyProvisioning : Response_Common + { + public List Records { get; set; } = new List(); + + #region record + public class SupplierKeyProvisioningRecords + { + public string M1 { get; set; } = string.Empty; + public string M2 { get; set; } = string.Empty; + public string M3 { get; set; } = string.Empty; + public string M4 { get; set; } = string.Empty; + public string M5 { get; set; } = string.Empty; + } + #endregion + } + + // + public class Request_SupplierKeyProvisioning_Result + { + public string ProvisioningType { get; set; } = string.Empty; + public string EcuID { get; set; } = string.Empty; + public string ResultMessage { get; set; } = string.Empty; + public string ResultStatus { get; set; } = string.Empty; + } + public class Response_SupplierKeyProvisioning_Result : Response_Common + { + } + + // + public class Request_SupplierKeySyncValue + { + public string ProvisioningType { get; set; } = string.Empty; + public string EcuID { get; set; } = string.Empty; + } + public class Response_SupplierKeySyncValue : Response_Common + { + public List Records { get; set; } = new List(); + + #region record + public class SupplierKeySyncValueRecords + { + public string KeyID { get; set; } = string.Empty; + public string KeySyncValue { get; set; } = string.Empty; + public string Challenge { get; set; } = string.Empty; + } + #endregion + } + + // + public class Request_SupplierKeySyncValue_Result + { + public string ProvisioningType { get; set; } = string.Empty; + public string EcuID { get; set; } = string.Empty; + public string ResultMessage { get; set; } = string.Empty; + public string ResultStatus { get; set; } = string.Empty; + } + public class Response_SupplierKeySyncValue_Result : Response_Common + { + } + } + + //4. SecOCKey + public class SecOCKey + { + public class Request_SupplierKeyProvisioning + { + public string ProvisioningType { get; set; } = string.Empty; + public string EcuID { get; set; } = string.Empty; + public string KeyID { get; set; } = string.Empty; + public string SupplierSecretKey { get; set; } = string.Empty; + public string Counter { get; set; } = string.Empty; + public string Challenge { get; set; } = string.Empty; + } + public class Response_SupplierKeyProvisioning : Response_Common + { + public List Records { get; set; } = new List(); + + #region record + public class SupplierKeyProvisioningRecords + { + public string KeyID { get; set; } = string.Empty; + public string M1 { get; set; } = string.Empty; + public string M2 { get; set; } = string.Empty; + public string M3 { get; set; } = string.Empty; + public string M4 { get; set; } = string.Empty; + public string M5 { get; set; } = string.Empty; + } + #endregion + } + + // + public class Request_SupplierKeyProvisioning_Result + { + public string ProvisioningType { get; set; } = string.Empty; + public string EcuID { get; set; } = string.Empty; + public string KeyID { get; set; } = string.Empty; + public string ResultMessage { get; set; } = string.Empty; + public string ResultStatus { get; set; } = string.Empty; + } + public class Response_SupplierKeyProvisioning_Result : Response_Common + { + } + + // + public class Request_SupplierKeySyncValue + { + public string ProvisioningType { get; set; } = string.Empty; + public string EcuID { get; set; } = string.Empty; + } + public class Response_SupplierKeySyncValue : Response_Common + { + public List Records { get; set; } = new List(); + + #region record + public class SupplierKeySyncValueRecords + { + public string KeyID { get; set; } = string.Empty; + public string KeySyncValue { get; set; } = string.Empty; + public string Challenge { get; set; } = string.Empty; + } + #endregion + } + + // + public class Request_SupplierKeySyncValue_Result + { + public string ProvisioningType { get; set; } = string.Empty; + public string EcuID { get; set; } = string.Empty; + public string KeyID { get; set; } = string.Empty; + public string ResultMessage { get; set; } = string.Empty; + public string ResultStatus { get; set; } = string.Empty; + } + public class Response_SupplierKeySyncValue_Result : Response_Common + { + } + } + + #region common + public class Response_Common + { + public string ResultStatus { get; set; } = string.Empty; + public string ResultReason { get; set; } = string.Empty; + public string ResultMessage { get; set; } = string.Empty; + } + #endregion +} diff --git a/Projects/WebClient/Web.Operation/Program.cs b/Projects/WebClient/Web.Operation/Program.cs index 6f744d3..7146125 100644 --- a/Projects/WebClient/Web.Operation/Program.cs +++ b/Projects/WebClient/Web.Operation/Program.cs @@ -34,6 +34,7 @@ builder.Services.AddSingleton>(); //scoped builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); //db builder.Services.AddSingleton(); // Generic µî·Ï diff --git a/Projects/WebClient/Web.Operation/Services/ProxyKMSService.cs b/Projects/WebClient/Web.Operation/Services/ProxyKMSService.cs new file mode 100644 index 0000000..199e2d0 --- /dev/null +++ b/Projects/WebClient/Web.Operation/Services/ProxyKMSService.cs @@ -0,0 +1,39 @@ +using SystemX.Core.Communication; +using SystemX.Core.Services; +using Web.Operation.Packet; +using WebClient.Library.Config; + +namespace Web.Operation.Services +{ + public class ProxyKMSService + { + private readonly IServiceScopeFactory _scopeFactory; + private readonly ConfigService? _configService; + + private string ApiHost = string.Empty; + + public ProxyKMSService(IServiceProvider serviceProvider, IServiceScopeFactory scopeFactory, ConfigService configService) + { + _scopeFactory = scopeFactory; + _configService = configService; + } + + public async Task PostKms(string url, REQUEST request) where REQUEST : class where RESPONSE : class + { + + Http http = new Http(); + var res = await http.PostJsonAsync($"{url}", request); + + return res; + } + + public async Task PutKms(string url, REQUEST request) where REQUEST : class where RESPONSE : class + { + + Http http = new Http(); + var res = await http.PutJsonAsync($"{url}", request); + + return res; + } + } +} diff --git a/Projects/WebClient/Web.Operation/wwwroot/app.css b/Projects/WebClient/Web.Operation/wwwroot/app.css index e6eef8b..25fc4cb 100644 --- a/Projects/WebClient/Web.Operation/wwwroot/app.css +++ b/Projects/WebClient/Web.Operation/wwwroot/app.css @@ -96,6 +96,15 @@ h1:focus { font-size: 1.5rem !important; } +.rz-fieldset-legend-text{ + font-size: 1.6rem !important; + color:darkorange; +} + +.rz-fieldset{ + border-color: darkorange !important; +} + /*common*/ span { font-size: 1.5rem;