Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(checklist): add new checklist steps #576

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/Portal.Backend.sln
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mailing.Library", "processe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mailing.Library.Tests", "..\tests\processes\Mailing.Library.Tests\Mailing.Library.Tests.csproj", "{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IssuerComponent.Library", "externalsystems\IssuerComponent.Library\IssuerComponent.Library.csproj", "{59E4B63B-BEA2-4CDA-98F0-13962146AEA5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IssuerComponent.Library.Tests", "..\tests\externalsystems\IssuerComponent.Library.Tests\IssuerComponent.Library.Tests.csproj", "{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1654,6 +1658,30 @@ Global
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}.Release|x86.Build.0 = Release|Any CPU
{D666EADA-770A-42FF-B891-5745F7A6BC2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D666EADA-770A-42FF-B891-5745F7A6BC2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59E4B63B-BEA2-4CDA-98F0-13962146AEA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{59E4B63B-BEA2-4CDA-98F0-13962146AEA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59E4B63B-BEA2-4CDA-98F0-13962146AEA5}.Debug|x64.ActiveCfg = Debug|Any CPU
{59E4B63B-BEA2-4CDA-98F0-13962146AEA5}.Debug|x64.Build.0 = Debug|Any CPU
{59E4B63B-BEA2-4CDA-98F0-13962146AEA5}.Debug|x86.ActiveCfg = Debug|Any CPU
{59E4B63B-BEA2-4CDA-98F0-13962146AEA5}.Debug|x86.Build.0 = Debug|Any CPU
{59E4B63B-BEA2-4CDA-98F0-13962146AEA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59E4B63B-BEA2-4CDA-98F0-13962146AEA5}.Release|Any CPU.Build.0 = Release|Any CPU
{59E4B63B-BEA2-4CDA-98F0-13962146AEA5}.Release|x64.ActiveCfg = Release|Any CPU
{59E4B63B-BEA2-4CDA-98F0-13962146AEA5}.Release|x64.Build.0 = Release|Any CPU
{59E4B63B-BEA2-4CDA-98F0-13962146AEA5}.Release|x86.ActiveCfg = Release|Any CPU
{59E4B63B-BEA2-4CDA-98F0-13962146AEA5}.Release|x86.Build.0 = Release|Any CPU
{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC}.Debug|x64.ActiveCfg = Debug|Any CPU
{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC}.Debug|x64.Build.0 = Debug|Any CPU
{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC}.Debug|x86.ActiveCfg = Debug|Any CPU
{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC}.Debug|x86.Build.0 = Debug|Any CPU
{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC}.Release|Any CPU.Build.0 = Release|Any CPU
{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC}.Release|x64.ActiveCfg = Release|Any CPU
{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC}.Release|x64.Build.0 = Release|Any CPU
{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC}.Release|x86.ActiveCfg = Release|Any CPU
{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1778,5 +1806,7 @@ Global
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4} = {282CEF03-292F-4A49-83C6-997567D0FF5F}
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{D666EADA-770A-42FF-B891-5745F7A6BC2F} = {282CEF03-292F-4A49-83C6-997567D0FF5F}
{59E4B63B-BEA2-4CDA-98F0-13962146AEA5} = {C8957230-4203-452C-A085-34091C5E370B}
{C6DE5F4C-DB67-48B9-BE0E-0C557AB704AC} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/********************************************************************************
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;

public interface IMailBusinessLogic
{
Task SendMail(MailData mailData);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Org.Eclipse.TractusX.Portal.Backend.Clearinghouse.Library.Models;
using Org.Eclipse.TractusX.Portal.Backend.Dim.Library.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
using Org.Eclipse.TractusX.Portal.Backend.IssuerComponent.Library.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models;
Expand Down Expand Up @@ -92,4 +93,18 @@ public interface IRegistrationBusinessLogic
/// <param name="documentId">Id of the document to get</param>
/// <returns>Returns the filename and content of the file</returns>
Task<(string fileName, byte[] content, string contentType)> GetDocumentAsync(Guid documentId);

/// <summary>
/// Processes the issuer bpn response
/// </summary>
/// <param name="data">the response data</param>
/// <param name="cancellationToken">cancellation token</param>
Task ProcessIssuerBpnResponseAsync(IssuerResponseData data, CancellationToken cancellationToken);

/// <summary>
/// Processes the issuer membership response
/// </summary>
/// <param name="data">the response data</param>
/// <param name="cancellationToken">cancellation token</param>
Task ProcessIssuerMembershipResponseAsync(IssuerResponseData data, CancellationToken cancellationToken);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/********************************************************************************
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories;
using Org.Eclipse.TractusX.Portal.Backend.Processes.Mailing.Library;
using System.Collections.Immutable;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;

public class MailBusinessLogic(IPortalRepositories portalRepositories, IMailingProcessCreation mailingProcessCreation)
: IMailBusinessLogic
{
private static readonly IEnumerable<string> ValidTemplates =
[
"CredentialExpiry",
"CredentialRejected",
"CredentialApproval"
];

public async Task SendMail(MailData mailData)
{
if (!ValidTemplates.Contains(mailData.Template))
{
throw ConflictException.Create(AdministrationMailErrors.INVALID_TEMPLATE, [new("template", mailData.Template)]);
}

var data = await portalRepositories.GetInstance<IUserRepository>().GetUserMailData(mailData.Requester).ConfigureAwait(false);
if (!data.Exists)
{
throw NotFoundException.Create(AdministrationMailErrors.USER_NOT_FOUND, [new("userId", mailData.Requester.ToString())]);
}

if (data.RecipientMail is not null)
{
mailingProcessCreation.CreateMailProcess(data.RecipientMail, mailData.Template, mailData.MailParameters.ToImmutableDictionary(x => x.Key, x => x.Value));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
using Org.Eclipse.TractusX.Portal.Backend.Dim.Library.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
using Org.Eclipse.TractusX.Portal.Backend.IssuerComponent.Library.BusinessLogic;
using Org.Eclipse.TractusX.Portal.Backend.IssuerComponent.Library.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Extensions;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
Expand Down Expand Up @@ -56,6 +58,7 @@ public sealed class RegistrationBusinessLogic : IRegistrationBusinessLogic
private readonly IClearinghouseBusinessLogic _clearinghouseBusinessLogic;
private readonly ISdFactoryBusinessLogic _sdFactoryBusinessLogic;
private readonly IDimBusinessLogic _dimBusinessLogic;
private readonly IIssuerComponentBusinessLogic _issuerComponentBusinessLogic;
private readonly IProvisioningManager _provisioningManager;
private readonly IMailingProcessCreation _mailingProcessCreation;
private readonly ILogger<RegistrationBusinessLogic> _logger;
Expand All @@ -67,6 +70,7 @@ public RegistrationBusinessLogic(
IClearinghouseBusinessLogic clearinghouseBusinessLogic,
ISdFactoryBusinessLogic sdFactoryBusinessLogic,
IDimBusinessLogic dimBusinessLogic,
IIssuerComponentBusinessLogic issuerComponentBusinessLogic,
IProvisioningManager provisioningManager,
IMailingProcessCreation mailingProcessCreation,
ILogger<RegistrationBusinessLogic> logger)
Expand All @@ -77,6 +81,7 @@ public RegistrationBusinessLogic(
_clearinghouseBusinessLogic = clearinghouseBusinessLogic;
_sdFactoryBusinessLogic = sdFactoryBusinessLogic;
_dimBusinessLogic = dimBusinessLogic;
_issuerComponentBusinessLogic = issuerComponentBusinessLogic;
_provisioningManager = provisioningManager;
_mailingProcessCreation = mailingProcessCreation;
_logger = logger;
Expand Down Expand Up @@ -593,4 +598,37 @@ private static IEnumerable<CompanyApplicationStatusId> GetCompanyApplicationStat

return (document.DocumentName, document.DocumentContent, document.MediaTypeId.MapToMediaType());
}

/// <inheritdoc />
public async Task ProcessIssuerBpnResponseAsync(IssuerResponseData data, CancellationToken cancellationToken)
{
var applicationId = await GetApplicationIdByBpn(data, cancellationToken);

await _issuerComponentBusinessLogic.StoreBpnlCredentialResponse(applicationId, data).ConfigureAwait(false);
await _portalRepositories.SaveAsync().ConfigureAwait(false);
}

/// <inheritdoc />
public async Task ProcessIssuerMembershipResponseAsync(IssuerResponseData data, CancellationToken cancellationToken)
{
var applicationId = await GetApplicationIdByBpn(data, cancellationToken);
await _issuerComponentBusinessLogic.StoreMembershipCredentialResponse(applicationId, data).ConfigureAwait(false);
await _portalRepositories.SaveAsync().ConfigureAwait(false);
}

private async Task<Guid> GetApplicationIdByBpn(IssuerResponseData data, CancellationToken cancellationToken)
{
var result = await _portalRepositories.GetInstance<IApplicationRepository>().GetSubmittedApplicationIdsByBpn(data.Bpn.ToUpper()).ToListAsync(cancellationToken).ConfigureAwait(false);
if (!result.Any())
{
throw new NotFoundException($"No companyApplication for BPN {data.Bpn} is not in status SUBMITTED");
}

if (result.Count > 1)
{
throw new ConflictException($"more than one companyApplication in status SUBMITTED found for BPN {data.Bpn} [{string.Join(", ", result)}]");
}

return result.Single();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/********************************************************************************
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic;
using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Web;
using Org.Eclipse.TractusX.Portal.Backend.Web.Identity;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers;

/// <summary>
/// Controller providing actions for displaying, filtering and updating connectors for companies.
/// </summary>
[EnvironmentRoute("MVC_ROUTING_BASEPATH", "[controller]")]
[ApiController]
[Produces("application/json")]
public class MailController : ControllerBase
{
private readonly IMailBusinessLogic _businessLogic;

/// <summary>
/// Constructor.
/// </summary>
/// <param name="businessLogic">Mail business logic.</param>
public MailController(IMailBusinessLogic businessLogic)
{
_businessLogic = businessLogic;
}

/// <summary>
/// Creates a mail from the given data
/// </summary>
/// <param name="data">Data for the mail</param>
/// <returns>Return NoContent</returns>
/// <remarks>Example: POST: /api/administration/mail/ssi-credentials</remarks>
[HttpPost]
[Route("ssi-credentials")]
[Authorize(Roles = "send_mail")]
[Authorize(Policy = PolicyTypes.ValidIdentity)]
[ProducesResponseType(typeof(int), StatusCodes.Status204NoContent)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status403Forbidden)]
public async Task<ActionResult> SendMail([FromBody] MailData data)
{
await _businessLogic.SendMail(data).ConfigureAwait(false);
return NoContent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Web;
using Org.Eclipse.TractusX.Portal.Backend.IssuerComponent.Library.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models;
Expand Down Expand Up @@ -432,4 +433,48 @@ public async Task<NoContentResult> RetriggerValidateDid([FromRoute] Guid applica
await _logic.TriggerChecklistAsync(applicationId, ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ProcessStepTypeId.RETRIGGER_VALIDATE_DID_DOCUMENT).ConfigureAwait(ConfigureAwaitOptions.None);
return NoContent();
}

/// <summary>
/// Processes the issuer bpn response
/// </summary>
/// <param name="responseData">Response data from the issuer component</param>
/// <param name="cancellationToken">Cancellation Token</param>
/// <returns>NoContent</returns>
/// Example: POST: api/administration/registration/issuer/bpncredential
/// <response code="204">Empty response on success.</response>
/// <response code="400">Either the CompanyApplication is not in status SUBMITTED or the bpn credential process is not in status IN_PROGRESS.</response>
/// <response code="404">No application found for the external id.</response>
[HttpPost]
[Authorize(Roles = "update_application_bpn_credential")]
[Route("issuer/bpncredential")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)]
public async Task<NoContentResult> ProcessIssuerBpnResponse([FromBody] IssuerResponseData responseData, CancellationToken cancellationToken)
{
await _logic.ProcessIssuerBpnResponseAsync(responseData, cancellationToken).ConfigureAwait(false);
return NoContent();
}

/// <summary>
/// Processes the issuer membership response
/// </summary>
/// <param name="responseData">Response data from the issuer component</param>
/// <param name="cancellationToken">Cancellation Token</param>
/// <returns>NoContent</returns>
/// Example: POST: api/administration/registration/issuer/membershipcredential
/// <response code="204">Empty response on success.</response>
/// <response code="400">Either the CompanyApplication is not in status SUBMITTED or the membership credential process is not in status IN_PROGRESS.</response>
/// <response code="404">No application found for the external id.</response>
[HttpPost]
[Authorize(Roles = "update_application_membership_credential")]
[Route("issuer/membershipcredential")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)]
public async Task<NoContentResult> ProcessIssuerMembershipResponse([FromBody] IssuerResponseData responseData, CancellationToken cancellationToken)
{
await _logic.ProcessIssuerMembershipResponseAsync(responseData, cancellationToken).ConfigureAwait(false);
return NoContent();
}
}
Loading
Loading