[성현모] ProxyKMS 컨피그, 패킷 클래스 추가

This commit is contained in:
SHM
2025-12-24 11:42:59 +09:00
parent e2c367961a
commit 31f3079ead
7 changed files with 335 additions and 2 deletions

View File

@ -0,0 +1,13 @@
{
"Server": {
"Address": "https://*",
"Port": 9200,
"IIS": false
},
"API": [
{
"ApiName": "vpkira",
"Address": "https://vpkira.hmckmc.co.kr/"
}
]
}

View File

@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
using WebApi.Project.ProxyKMS.Models;
namespace WebApi.Project.ProxyKMS.Controllers
{
@ -21,6 +23,21 @@ namespace WebApi.Project.ProxyKMS.Controllers
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
MasterEcuKey.Response_SupplierKeyProvisioning res = new MasterEcuKey.Response_SupplierKeyProvisioning();
res.ResultMessage = "";
res.ResultStatus = "";
res.ResultReason = "";
res.Records.M1 = "M11";
res.Records.M2 = "M22";
res.Records.M3 = "M33";
res.Records.M4 = "M44";
res.Records.M5 = "M55";
res.Records.KeyID = "key";
var serialize = JsonSerializer.Serialize(res, new JsonSerializerOptions() { WriteIndented = true });
var desObj = JsonSerializer.Deserialize<MasterEcuKey.Response_SupplierKeyProvisioning>(serialize);
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),

View File

@ -0,0 +1,216 @@
using Microsoft.OpenApi.Writers;
using System.ComponentModel.DataAnnotations;
namespace WebApi.Project.ProxyKMS.Models
{
//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 SupplierKeyProvisioningRecords Records { get; set; } = new SupplierKeyProvisioningRecords();
#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 SupplierKeyProvisioningRecords Records { get; set; } = new SupplierKeyProvisioningRecords();
#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 SupplierKeySyncValueRecords Records { get; set; } = new SupplierKeySyncValueRecords();
#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 SupplierKeyProvisioningRecords Records { get; set; } = new SupplierKeyProvisioningRecords();
#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 SupplierKeySyncValueRecords Records { get; set; } = new SupplierKeySyncValueRecords();
#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
}

View File

@ -0,0 +1,8 @@
using WebApi.Library.Config;
namespace WebApi.Project.ProxyKMS.Models
{
public class ProxyKMSConfig : WebApiConfig
{
}
}

View File

@ -1,25 +1,90 @@
using SystemX.Core.Services;
using WebApi.Project.ProxyKMS.Models;
string configDir = @"../../Config";
string configFileName = "WebApi.Project.ProxyKMSApi.Config.json";
//raed log4net configs
if (LogXnet.ReadConfig(@$"{configDir}/LogXnetConfig.json") == true)
{
LogXnet.WriteLine("LogXnet Init Success");
}
else
{
Console.WriteLine("LogXnet Init Failed");
return;
}
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
//singleton
builder.Services.AddSingleton<ConfigService<ProxyKMSConfig>>();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddHttpContextAccessor();
//config preload, auth set
ConfigService<ProxyKMSConfig> preloadConfig = new ConfigService<ProxyKMSConfig>();
if (preloadConfig.OpenConfig($@"{configDir}/{configFileName}") == true)
{
var config = preloadConfig.GetConfig();
}
else
{
LogXnet.WriteLine("Config Preload Load Error.", LogXLabel.Error);
return;
}
var app = builder.Build();
//read api config and set
string serverUrl = string.Empty;
var configService = app.Services.GetService<ConfigService<ProxyKMSConfig>>();
bool isIIS = false;
int socketPort = 0;
if (configService?.OpenConfig($@"{configDir}/{configFileName}") == true)
{
LogXnet.WriteLine("WebApi Config Success.");
var apiConfig = ConfigService<ProxyKMSConfig>.Config;
if (apiConfig != null)
{
serverUrl = $"{apiConfig?.Server?.Address}:{apiConfig?.Server?.Port}";
isIIS = apiConfig!.Server.IIS;
}
}
else
{
LogXnet.WriteLine("WebApi Config Error.");
return;
}
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
LogXnet.WriteLine($"IsDevelopment:{app.Environment.IsDevelopment()}");
LogXnet.WriteLine($"Swagger Url: {serverUrl}/swagger");
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
if (isIIS == true)
{
app.Run();
}
else
{
LogXnet.WriteLine($"Operation Url: {serverUrl}");
app.Run($"{serverUrl}");
}

View File

@ -10,4 +10,17 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WebApi.Library\WebApi.Library.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="SystemX.Core">
<HintPath>..\..\DLL\SystemX.Core.dll</HintPath>
</Reference>
<Reference Include="SystemX.Core.DB">
<HintPath>..\..\DLL\SystemX.Core.DB.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@ -10,6 +10,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{C8D5274F-AC00-46C7-1F8D-E88E81087A52}"
ProjectSection(SolutionItems) = preProject
..\Config\WebApi.AuthApi.Config.json = ..\Config\WebApi.AuthApi.Config.json
..\Config\WebApi.Project.ProxyKMSApi.Config.json = ..\Config\WebApi.Project.ProxyKMSApi.Config.json
..\Config\WebApi.Project.UniqueKeyApi.Config.json = ..\Config\WebApi.Project.UniqueKeyApi.Config.json
EndProjectSection
EndProject