[성현모] KMS 서비스 기능 추가

This commit is contained in:
SHM
2026-02-02 10:14:43 +09:00
parent cfc36e80d4
commit e673cc20cf
5 changed files with 165 additions and 54 deletions

View File

@ -7,7 +7,63 @@
"API": [
{
"ApiName": "kms",
"Address": "https://1.237.74.86:5698/"
"Functions": [
{
"Name": "EcuID_SupplierEcuID",
"Method": "Post",
"Url": "https://1.237.74.86:5698/app/automotive/supplierEcuID"
},
{
"Name": "MasterEcuKey_SupplierKeyProvisioning",
"Method": "Post",
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeyProvisioning"
},
{
"Name": "MasterEcuKey_SupplierKeyProvisioningResult",
"Method": "Put",
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeyProvisioning"
},
{
"Name": "SupplierSymmKey_SupplierKeyProvisioning",
"Method": "Post",
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeyProvisioning"
},
{
"Name": "SupplierSymmKey_SupplierKeyProvisioningResult",
"Method": "Put",
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeyProvisioning"
},
{
"Name": "SupplierSymmKey_SupplierKeySyncValue",
"Method": "Post",
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeySyncValue"
},
{
"Name": "SupplierSymmKey_SupplierKeySyncValueResult",
"Method": "Put",
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeySyncValue"
},
{
"Name": "SecOCKey_SupplierKeyProvisioning",
"Method": "Post",
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeyProvisioning"
},
{
"Name": "SecOCKey_SupplierKeyProvisioningResult",
"Method": "Put",
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeyProvisioning"
},
{
"Name": "SecOCKey_SupplierKeySyncValue",
"Method": "Post",
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeySyncValue"
},
{
"Name": "SecOCKey_SupplierKeySyncValueResult",
"Method": "Put",
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeySyncValue"
}
]
}
]
}

View File

@ -25,41 +25,38 @@ namespace WebApi.Project.ProxyKMS.Controllers
Guid guid = Guid.NewGuid();
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
var response = await _kmsMetaService.PostKms<EcuID.Request_SupplierEcuID, EcuID.Response_SupplierEcuID>(request, guid.ToString());
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
// return Results.Ok(response);
return Results.Ok();
return Results.Ok(response);
}
//2. MasterECUKEy
[HttpPost("MasterEcuKey/SupplierKeyProvisioning")]
public async Task<IResult> MasterEcuKey_SupplierKeyProvisioning([FromBody] EcuID.Request_SupplierEcuID request)
public async Task<IResult> MasterEcuKey_SupplierKeyProvisioning([FromBody] MasterEcuKey.Request_SupplierKeyProvisioning request)
{
Guid guid = Guid.NewGuid();
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
var response = await _kmsMetaService.PostKms<MasterEcuKey.Request_SupplierKeyProvisioning, MasterEcuKey.Response_SupplierKeyProvisioning>(request, guid.ToString());
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
// return Results.Ok(response);
return Results.Ok();
return Results.Ok(response);
}
[HttpPut("MasterEcuKey/SupplierKeyProvisioning")]
public async Task<IResult> MasterEcuKey_SupplierKeyProvisioningResult([FromBody] MasterEcuKey.Request_SupplierKeyProvisioning request)
public async Task<IResult> MasterEcuKey_SupplierKeyProvisioningResult([FromBody] MasterEcuKey.Request_SupplierKeyProvisioning_Result request)
{
Guid guid = Guid.NewGuid();
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
var response = await _kmsMetaService.PutKms<MasterEcuKey.Request_SupplierKeyProvisioning_Result, MasterEcuKey.Response_SupplierKeyProvisioning_Result>(request, guid.ToString());
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
// return Results.Ok(response);
return Results.Ok();
return Results.Ok(response);
}
//3. SupplierSymmKey
@ -69,12 +66,11 @@ namespace WebApi.Project.ProxyKMS.Controllers
Guid guid = Guid.NewGuid();
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
var response = await _kmsMetaService.PostKms<SupplierSymmKey.Request_SupplierKeyProvisioning, SupplierSymmKey.Response_SupplierKeyProvisioning>(request, guid.ToString());
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
// return Results.Ok(response);
return Results.Ok();
return Results.Ok(response);
}
[HttpPut("SupplierSymmKey/SupplierKeyProvisioning")]
@ -83,40 +79,37 @@ namespace WebApi.Project.ProxyKMS.Controllers
Guid guid = Guid.NewGuid();
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
var response = await _kmsMetaService.PutKms<SupplierSymmKey.Request_SupplierKeyProvisioning_Result, SupplierSymmKey.Response_SupplierKeyProvisioning_Result>(request, guid.ToString());
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
// return Results.Ok(response);
return Results.Ok();
return Results.Ok(response);
}
[HttpPost("SupplierSymmKey/SupplierKeySyncValue")]
public async Task<IResult> SupplierSymmKey_SupplierKeySyncValue([FromBody] SupplierSymmKey.Request_SupplierKeyProvisioning request)
public async Task<IResult> SupplierSymmKey_SupplierKeySyncValue([FromBody] SupplierSymmKey.Request_SupplierKeySyncValue request)
{
Guid guid = Guid.NewGuid();
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
var response = await _kmsMetaService.PostKms<SupplierSymmKey.Request_SupplierKeySyncValue, SupplierSymmKey.Response_SupplierKeySyncValue>(request, guid.ToString());
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
// return Results.Ok(response);
return Results.Ok();
return Results.Ok(response);
}
[HttpPut("SupplierSymmKey/SupplierKeySyncValue")]
public async Task<IResult> SupplierSymmKey_SupplierKeySyncValueResult([FromBody] SupplierSymmKey.Request_SupplierKeyProvisioning_Result request)
public async Task<IResult> SupplierSymmKey_SupplierKeySyncValueResult([FromBody] SupplierSymmKey.Request_SupplierKeySyncValue_Result request)
{
Guid guid = Guid.NewGuid();
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
var response = await _kmsMetaService.PutKms<SupplierSymmKey.Request_SupplierKeySyncValue_Result, SupplierSymmKey.Response_SupplierKeySyncValue_Result>(request, guid.ToString());
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
// return Results.Ok(response);
return Results.Ok();
return Results.Ok(response);
}
//4,SecOCKey
@ -125,13 +118,12 @@ namespace WebApi.Project.ProxyKMS.Controllers
{
Guid guid = Guid.NewGuid();
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
var response = await _kmsMetaService.PostKms<SecOCKey.Request_SupplierKeyProvisioning, SecOCKey.Response_SupplierKeyProvisioning>(request, guid.ToString());
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
// return Results.Ok(response);
return Results.Ok();
return Results.Ok(response);
}
[HttpPut("SecOCKey/SupplierKeyProvisioning")]
@ -140,40 +132,37 @@ namespace WebApi.Project.ProxyKMS.Controllers
Guid guid = Guid.NewGuid();
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
var response = await _kmsMetaService.PutKms<SecOCKey.Request_SupplierKeyProvisioning_Result, SecOCKey.Response_SupplierKeyProvisioning_Result>(request, guid.ToString());
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
// return Results.Ok(response);
return Results.Ok();
return Results.Ok(response);
}
[HttpPost("SecOCKey/SupplierKeySyncValue")]
public async Task<IResult> SecOCKey_SupplierKeySyncValue([FromBody] SecOCKey.Request_SupplierKeyProvisioning request)
public async Task<IResult> SecOCKey_SupplierKeySyncValue([FromBody] SecOCKey.Request_SupplierKeySyncValue request)
{
Guid guid = Guid.NewGuid();
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
var response = await _kmsMetaService.PostKms<SecOCKey.Request_SupplierKeySyncValue, SecOCKey.Request_SupplierKeySyncValue>(request, guid.ToString());
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
// return Results.Ok(response);
return Results.Ok();
return Results.Ok(response);
}
[HttpPut("SecOCKey/SupplierKeySyncValue")]
public async Task<IResult> SecOCKey_SupplierKeySyncValueResult([FromBody] SecOCKey.Request_SupplierKeyProvisioning_Result request)
public async Task<IResult> SecOCKey_SupplierKeySyncValueResult([FromBody] SecOCKey.Request_SupplierKeySyncValue_Result request)
{
Guid guid = Guid.NewGuid();
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
var response = await _kmsMetaService.PutKms<SecOCKey.Request_SupplierKeySyncValue_Result, SecOCKey.Response_SupplierKeySyncValue_Result>(request, guid.ToString());
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
// return Results.Ok(response);
return Results.Ok();
return Results.Ok(response);
}
}
}

View File

@ -4,5 +4,20 @@ namespace WebApi.Project.ProxyKMS.Models
{
public class ProxyKMSConfig : WebApiConfig
{
public List<API> API { get; set; } = new List<API>();
}
public class API
{
public string ApiName { get; set; } = string.Empty;
public List<Function> Functions { get; set; } = new List<Function>();
}
public class Function
{
public string Name { get; set; }
public string Method { get; set; }
public string Url { get; set; }
}
}

View File

@ -23,6 +23,7 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton<ConfigService<ProxyKMSConfig>>();
//scoped
builder.Services.AddSingleton<HttpService>();
builder.Services.AddSingleton<KmsService>();
builder.Services.AddControllers();
@ -30,6 +31,7 @@ builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddHttpContextAccessor();
builder.Services.AddHttpContextAccessor();
//config preload, auth set
ConfigService<ProxyKMSConfig> preloadConfig = new ConfigService<ProxyKMSConfig>();

View File

@ -1,6 +1,55 @@
namespace WebApi.Project.ProxyKMS.Services
using System;
using System.Runtime.CompilerServices;
using SystemX.Core.DB;
using SystemX.Core.Services;
using WebApi.Library.Enums;
using WebApi.Project.ProxyKMS.Models;
namespace WebApi.Project.ProxyKMS.Services
{
public class KmsService
public class KmsService : HttpService
{
private readonly IServiceScopeFactory _scopeFactory;
private readonly ConfigService<ProxyKMSConfig>? _configService;
private API KmsApi = new API();
public KmsService(IServiceProvider serviceProvider, IServiceScopeFactory scopeFactory, ConfigService<ProxyKMSConfig> configSerice)
{
_scopeFactory = scopeFactory;
_configService = configSerice;
KmsApi = _configService.GetConfig().API.Find(x=>x.ApiName.ToLower() == "kms");
}
public async Task<RESPONSE?> PostKms<REQUEST,RESPONSE>(REQUEST request, string guid = "", [CallerMemberName] string memberName = "") where REQUEST : class where RESPONSE : class
{
RESPONSE? response = default(RESPONSE);
LogXnet.WriteLine($"KmsService.PostKms::{memberName}", LogXLabel.Debug);
if (request != null)
{
var function = KmsApi.Functions.Find(x => x.Name == memberName);
response = await PostJsonAsync<REQUEST, RESPONSE>($"{function.Url}", request);
}
return response;
}
public async Task<RESPONSE?> PutKms<REQUEST, RESPONSE>(REQUEST request, string guid = "", [CallerMemberName] string memberName = "") where REQUEST : class where RESPONSE : class
{
RESPONSE? response = default(RESPONSE);
LogXnet.WriteLine($"KmsService.PutKms::{memberName}", LogXLabel.Debug);
if (request != null)
{
var function = KmsApi.Functions.Find(x => x.Name == memberName);
response = await PutJsonAsync<REQUEST, RESPONSE>($"{function.Url}", request);
}
return response;
}
}
}