[성현모] ProxyKMS 컨피그, 패킷 클래스 추가
This commit is contained in:
13
Projects/Config/WebApi.Project.ProxyKMSApi.Config.json
Normal file
13
Projects/Config/WebApi.Project.ProxyKMSApi.Config.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"Server": {
|
||||||
|
"Address": "https://*",
|
||||||
|
"Port": 9200,
|
||||||
|
"IIS": false
|
||||||
|
},
|
||||||
|
"API": [
|
||||||
|
{
|
||||||
|
"ApiName": "vpkira",
|
||||||
|
"Address": "https://vpkira.hmckmc.co.kr/"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -1,4 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Text.Json;
|
||||||
|
using WebApi.Project.ProxyKMS.Models;
|
||||||
|
|
||||||
namespace WebApi.Project.ProxyKMS.Controllers
|
namespace WebApi.Project.ProxyKMS.Controllers
|
||||||
{
|
{
|
||||||
@ -21,6 +23,21 @@ namespace WebApi.Project.ProxyKMS.Controllers
|
|||||||
[HttpGet(Name = "GetWeatherForecast")]
|
[HttpGet(Name = "GetWeatherForecast")]
|
||||||
public IEnumerable<WeatherForecast> Get()
|
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
|
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||||
{
|
{
|
||||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||||
|
|||||||
216
Projects/WebApi/WebApi.Project.ProxyKMS/Models/Packet.cs
Normal file
216
Projects/WebApi/WebApi.Project.ProxyKMS/Models/Packet.cs
Normal 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
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
using WebApi.Library.Config;
|
||||||
|
|
||||||
|
namespace WebApi.Project.ProxyKMS.Models
|
||||||
|
{
|
||||||
|
public class ProxyKMSConfig : WebApiConfig
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
|
//singleton
|
||||||
|
builder.Services.AddSingleton<ConfigService<ProxyKMSConfig>>();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen();
|
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();
|
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.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
LogXnet.WriteLine($"IsDevelopment:{app.Environment.IsDevelopment()}");
|
||||||
|
LogXnet.WriteLine($"Swagger Url: {serverUrl}/swagger");
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
|
if (isIIS == true)
|
||||||
|
{
|
||||||
app.Run();
|
app.Run();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogXnet.WriteLine($"Operation Url: {serverUrl}");
|
||||||
|
app.Run($"{serverUrl}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,4 +10,17 @@
|
|||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||||
</ItemGroup>
|
</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>
|
</Project>
|
||||||
|
|||||||
@ -10,6 +10,7 @@ EndProject
|
|||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{C8D5274F-AC00-46C7-1F8D-E88E81087A52}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{C8D5274F-AC00-46C7-1F8D-E88E81087A52}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
..\Config\WebApi.AuthApi.Config.json = ..\Config\WebApi.AuthApi.Config.json
|
..\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
|
..\Config\WebApi.Project.UniqueKeyApi.Config.json = ..\Config\WebApi.Project.UniqueKeyApi.Config.json
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
|||||||
Reference in New Issue
Block a user