using Microsoft.AspNetCore.Mvc; using SystemX.Core.Controller; using WebApi.Project.ProxyKMS.Models; using WebApi.Project.ProxyKMS.Services; namespace WebApi.Project.ProxyKMS.Controllers { [ApiController] [Route("[controller]")] public class KmsController : CommonController { private readonly KmsService _kmsMetaService; public KmsController(IServiceProvider serviceProvider, IHttpContextAccessor httpContextAccessor, KmsService kmsService) : base(serviceProvider, httpContextAccessor) { _kmsMetaService = kmsService; } //1. EcuID [HttpPost("EcuID/SupplierEcuID")] public async Task EcuID_SupplierEcuID([FromBody] EcuID.Request_SupplierEcuID request) { 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(request, guid.ToString()); LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } //2. MasterECUKEy [HttpPost("MasterEcuKey/SupplierKeyProvisioning")] public async Task 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); var response = await _kmsMetaService.PostKms(request, guid.ToString()); LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } [HttpPut("MasterEcuKey/SupplierKeyProvisioning")] public async Task 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); var response = await _kmsMetaService.PutKms(request, guid.ToString()); LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } //3. SupplierSymmKey [HttpPost("SupplierSymmKey/SupplierKeyProvisioning")] public async Task SupplierSymmKey_SupplierKeyProvisioning([FromBody] SupplierSymmKey.Request_SupplierKeyProvisioning request) { 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(request, guid.ToString()); LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } [HttpPut("SupplierSymmKey/SupplierKeyProvisioning")] public async Task SupplierSymmKey_SupplierKeyProvisioningResult([FromBody] SupplierSymmKey.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); var response = await _kmsMetaService.PutKms(request, guid.ToString()); LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } [HttpPost("SupplierSymmKey/SupplierKeySyncValue")] public async Task 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); var response = await _kmsMetaService.PostKms(request, guid.ToString()); LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } [HttpPut("SupplierSymmKey/SupplierKeySyncValue")] public async Task 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); var response = await _kmsMetaService.PutKms(request, guid.ToString()); LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } //4,SecOCKey [HttpPost("SecOCKey/SupplierKeyProvisioning")] public async Task SecOCKey_SupplierKeyProvisioning([FromBody] SecOCKey.Request_SupplierKeyProvisioning request) { 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(request, guid.ToString()); LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } [HttpPut("SecOCKey/SupplierKeyProvisioning")] public async Task SecOCKey_SupplierKeyProvisioningResult([FromBody] SecOCKey.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); var response = await _kmsMetaService.PutKms(request, guid.ToString()); LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } [HttpPost("SecOCKey/SupplierKeySyncValue")] public async Task 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); var response = await _kmsMetaService.PostKms(request, guid.ToString()); LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } [HttpPut("SecOCKey/SupplierKeySyncValue")] public async Task 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); var response = await _kmsMetaService.PutKms(request, guid.ToString()); LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } } }