Skip to content

Commit

Permalink
Merge pull request #730 from eclipse-tractusx/main
Browse files Browse the repository at this point in the history
build(2.0.0-rc7): merge main into dev
  • Loading branch information
evegufy authored May 14, 2024
2 parents 857c3d0 + 80a59c2 commit f1822e3
Show file tree
Hide file tree
Showing 39 changed files with 540 additions and 278 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

New features, fixed bugs, known defects and other noteworthy changes to each release of the Catena-X Portal Backend.

## 2.0.0-RC7

### Bugfix
* **Migrations Seeding**
* added missing service accounts and improve descriptions
* **Administration Service**
* adjusted request for framework credential creation
* adjusted error tolerance for GET companyData/decentraldentity/urls
* passed logging arguments to correct parameter
* adjusted clearinghouse data: get the DID of the company from the database if the DIM wallet is enabled instead of requesting it from the MIW
* adjusted framework credential creation to call the ssi issuer with the current user instead of the technical user
* **Apps Service**
* fixed short description returning error

## 2.0.0-RC6

### Feature
Expand Down Expand Up @@ -137,6 +151,11 @@ New features, fixed bugs, known defects and other noteworthy changes to each rel
* CONTRIBUTING.md: linked to contribution details
* updated eclipse dash tool for dependencies check

## 1.8.1

### Bugfix
* fixed roles for Registration, Portal and technical_roles_management not being retrieved by endpoints [(718)](https://github.com/eclipse-tractusx/portal-backend/issues/718): added clients to base seeding of the app_instances table; the clients were accidentally maintained in consortia test data seeding

## 1.8.0

### Change
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionSuffix>RC6</VersionSuffix>
<VersionSuffix>RC7</VersionSuffix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ await portalRepositories
.ConfigureAwait(false);

/// <inheritdoc />
public Task<Guid> CreateUseCaseParticipation(UseCaseParticipationCreationData data, CancellationToken cancellationToken) =>
_issuerComponentBusinessLogic.CreateFrameworkCredentialData(data.VerifiedCredentialExternalTypeDetailId, data.Framework, _identityData.IdentityId, cancellationToken);
public Task<Guid> CreateUseCaseParticipation(UseCaseParticipationCreationData data, string token, CancellationToken cancellationToken) =>
_issuerComponentBusinessLogic.CreateFrameworkCredentialData(data.VerifiedCredentialExternalTypeDetailId, data.CredentialType, _identityData.IdentityId, token, cancellationToken);

/// <inheritdoc />
public async Task CreateSsiCertificate(SsiCertificateCreationData data, CancellationToken cancellationToken)
Expand Down Expand Up @@ -579,28 +579,12 @@ public async IAsyncEnumerable<CompanyCertificateBpnData> GetCompanyCertificatesB
public async Task<DimUrlsResponse> GetDimServiceUrls()
{
var (bpnl, did, walletServiceUrl) = await portalRepositories.GetInstance<ICompanyRepository>().GetDimServiceUrls(_identityData.CompanyId).ConfigureAwait(ConfigureAwaitOptions.None);

if (bpnl is null)
{
throw new ConflictException("Bpn must be set");
}

if (did is null)
{
throw new ConflictException("Did must be set");
}

if (walletServiceUrl is null)
{
throw new ConflictException("Wallet Url must be set");
}

return new(
_settings.IssuerDid,
bpnl,
did,
_settings.BpnDidResolverUrl,
$"{walletServiceUrl}/oauth/token",
walletServiceUrl is null ? null : $"{walletServiceUrl}/oauth/token",
_settings.DecentralIdentityManagementAuthUrl
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public interface ICompanyDataBusinessLogic

Task<IEnumerable<SsiCertificateData>> GetSsiCertificatesAsync();

Task<Guid> CreateUseCaseParticipation(UseCaseParticipationCreationData data, CancellationToken cancellationToken);
Task<Guid> CreateUseCaseParticipation(UseCaseParticipationCreationData data, string token, CancellationToken cancellationToken);
Task CreateSsiCertificate(SsiCertificateCreationData data, CancellationToken cancellationToken);

Task<Pagination.Response<CredentialDetailData>> GetCredentials(int page, int size, CompanySsiDetailStatusId? companySsiDetailStatusId, VerifiedCredentialTypeId? credentialTypeId, string? companyName, CompanySsiDetailSorting? sorting);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ private UserUpdateError CreateUserUpdateError(int line, Exception error) =>
IEnumerable<(Guid IdentityProviderId, string Alias)> existingIdps,
[EnumeratorCancellation] CancellationToken cancellationToken)
{
await foreach (var (companyUserId, profile, identityProviderLinks) in userProfileLinkDatas)
await foreach (var (companyUserId, profile, identityProviderLinks) in userProfileLinkDatas.WithCancellation(cancellationToken))
{
Exception? error = null;
var success = false;
Expand All @@ -784,6 +784,7 @@ private UserUpdateError CreateUserUpdateError(int line, Exception error) =>
await UpdateUserProfileAsync(userRepository, iamUserId, companyUserId, profile, existingLinks, sharedIdp).ConfigureAwait(false);
updated = true;
}

success = updated;
}
catch (Exception e)
Expand All @@ -792,8 +793,10 @@ private UserUpdateError CreateUserUpdateError(int line, Exception error) =>
{
throw;
}

error = e;
}

yield return (success, error);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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.Keycloak.Authentication;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.Web.Identity;
Expand Down Expand Up @@ -237,7 +238,7 @@ public IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes() =>
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
public Task<Guid> CreateUseCaseParticipation([FromForm] UseCaseParticipationCreationData data, CancellationToken cancellationToken) =>
_logic.CreateUseCaseParticipation(data, cancellationToken);
this.WithBearerToken(token => _logic.CreateUseCaseParticipation(data, token, cancellationToken));

/// <summary>
/// Creates the SSI Certificate request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;

public record DimUrlsResponse(
[property: JsonPropertyName("trusted_issuer")] string IssuerDid,
[property: JsonPropertyName("participant_id")] string Bpnl,
[property: JsonPropertyName("iatp_id")] string HolderDid,
[property: JsonPropertyName("participant_id")] string? Bpnl,
[property: JsonPropertyName("iatp_id")] string? HolderDid,
[property: JsonPropertyName("did_resolver")] string BpnDidResolverUrl,
[property: JsonPropertyName("decentralIdentityManagementAuthUrl")] string DecentralIdentityManagementAuthUrl,
[property: JsonPropertyName("decentralIdentityManagementAuthUrl")] string? DecentralIdentityManagementAuthUrl,
[property: JsonPropertyName("decentralIdentityManagementServiceUrl")] string DecentralIdentityManagementServiceUrl
);
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;
public record UseCaseParticipationCreationData
(
Guid VerifiedCredentialExternalTypeDetailId,
UseCaseFrameworkId Framework,
UseCaseFrameworkId CredentialType,
IFormFile? Document
);

Expand Down
3 changes: 2 additions & 1 deletion src/administration/Administration.Service/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@
"ClientSecret": "",
"Scope": "",
"TokenAddress": "",
"BaseAddress": ""
"BaseAddress": "",
"UseDimWallet": false
},
"SdFactory": {
"Username": "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -28,27 +28,15 @@

namespace Org.Eclipse.TractusX.Portal.Backend.Clearinghouse.Library.BusinessLogic;

public class ClearinghouseBusinessLogic : IClearinghouseBusinessLogic
public class ClearinghouseBusinessLogic(
IPortalRepositories portalRepositories,
IClearinghouseService clearinghouseService,
ICustodianBusinessLogic custodianBusinessLogic,
IApplicationChecklistService checklistService,
IOptions<ClearinghouseSettings> options)
: IClearinghouseBusinessLogic
{
private readonly IPortalRepositories _portalRepositories;
private readonly IClearinghouseService _clearinghouseService;
private readonly ICustodianBusinessLogic _custodianBusinessLogic;
private readonly IApplicationChecklistService _checklistService;
private readonly ClearinghouseSettings _settings;

public ClearinghouseBusinessLogic(
IPortalRepositories portalRepositories,
IClearinghouseService clearinghouseService,
ICustodianBusinessLogic custodianBusinessLogic,
IApplicationChecklistService checklistService,
IOptions<ClearinghouseSettings> options)
{
_portalRepositories = portalRepositories;
_clearinghouseService = clearinghouseService;
_custodianBusinessLogic = custodianBusinessLogic;
_checklistService = checklistService;
_settings = options.Value;
}
private readonly ClearinghouseSettings _settings = options.Value;

public async Task<IApplicationChecklistService.WorkerChecklistProcessStepExecutionResult> HandleClearinghouse(IApplicationChecklistService.WorkerChecklistProcessStepData context, CancellationToken cancellationToken)
{
Expand All @@ -59,26 +47,43 @@ public ClearinghouseBusinessLogic(
_ => throw new UnexpectedConditionException($"HandleClearingHouse called for unexpected processStepTypeId {context.ProcessStepTypeId}. Expected {ProcessStepTypeId.START_CLEARING_HOUSE} or {ProcessStepTypeId.START_OVERRIDE_CLEARING_HOUSE}")
};

var walletData = await _custodianBusinessLogic.GetWalletByBpnAsync(context.ApplicationId, cancellationToken);
if (walletData == null || string.IsNullOrEmpty(walletData.Did))
string companyDid;
if (_settings.UseDimWallet)
{
var (exists, did) = await portalRepositories.GetInstance<IApplicationRepository>()
.GetDidForApplicationId(context.ApplicationId).ConfigureAwait(ConfigureAwaitOptions.None);
if (!exists || string.IsNullOrWhiteSpace(did))
{
throw new ConflictException($"Did must be set for Application {context.ApplicationId}");
}

companyDid = did;
}
else
{
throw new ConflictException($"Decentralized Identifier for application {context.ApplicationId} is not set");
var walletData = await custodianBusinessLogic.GetWalletByBpnAsync(context.ApplicationId, cancellationToken);
if (walletData == null || string.IsNullOrEmpty(walletData.Did))
{
throw new ConflictException($"Decentralized Identifier for application {context.ApplicationId} is not set");
}

companyDid = walletData.Did;
}

await TriggerCompanyDataPost(context.ApplicationId, walletData.Did, overwrite, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
await TriggerCompanyDataPost(context.ApplicationId, companyDid, overwrite, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);

return new IApplicationChecklistService.WorkerChecklistProcessStepExecutionResult(
ProcessStepStatusId.DONE,
entry => entry.ApplicationChecklistEntryStatusId = ApplicationChecklistEntryStatusId.IN_PROGRESS,
new[] { ProcessStepTypeId.END_CLEARING_HOUSE },
[ProcessStepTypeId.END_CLEARING_HOUSE],
null,
true,
null);
}

private async Task TriggerCompanyDataPost(Guid applicationId, string decentralizedIdentifier, bool overwrite, CancellationToken cancellationToken)
{
var data = await _portalRepositories.GetInstance<IApplicationRepository>()
var data = await portalRepositories.GetInstance<IApplicationRepository>()
.GetClearinghouseDataForApplicationId(applicationId).ConfigureAwait(ConfigureAwaitOptions.None);
if (data is null)
{
Expand All @@ -101,23 +106,23 @@ private async Task TriggerCompanyDataPost(Guid applicationId, string decentraliz
_settings.CallbackUrl,
overwrite);

await _clearinghouseService.TriggerCompanyDataPost(transferData, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
await clearinghouseService.TriggerCompanyDataPost(transferData, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
}

public async Task ProcessEndClearinghouse(Guid applicationId, ClearinghouseResponseData data, CancellationToken cancellationToken)
{
var context = await _checklistService
var context = await checklistService
.VerifyChecklistEntryAndProcessSteps(
applicationId,
ApplicationChecklistEntryTypeId.CLEARING_HOUSE,
new[] { ApplicationChecklistEntryStatusId.IN_PROGRESS },
[ApplicationChecklistEntryStatusId.IN_PROGRESS],
ProcessStepTypeId.END_CLEARING_HOUSE,
processStepTypeIds: new[] { ProcessStepTypeId.START_SELF_DESCRIPTION_LP })
processStepTypeIds: [ProcessStepTypeId.START_SELF_DESCRIPTION_LP])
.ConfigureAwait(ConfigureAwaitOptions.None);

var declined = data.Status == ClearinghouseResponseStatus.DECLINE;

_checklistService.FinalizeChecklistEntryAndProcessSteps(
checklistService.FinalizeChecklistEntryAndProcessSteps(
context,
null,
item =>
Expand All @@ -128,7 +133,7 @@ public async Task ProcessEndClearinghouse(Guid applicationId, ClearinghouseRespo
item.Comment = data.Message;
},
declined
? new[] { ProcessStepTypeId.TRIGGER_OVERRIDE_CLEARING_HOUSE }
: new[] { ProcessStepTypeId.START_SELF_DESCRIPTION_LP });
? [ProcessStepTypeId.TRIGGER_OVERRIDE_CLEARING_HOUSE]
: [ProcessStepTypeId.START_SELF_DESCRIPTION_LP]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ public class ClearinghouseSettings : KeyVaultAuthSettings

[Required(AllowEmptyStrings = false)]
public string CallbackUrl { get; set; } = null!;

public bool UseDimWallet { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -26,28 +26,21 @@

namespace Org.Eclipse.TractusX.Portal.Backend.Custodian.Library.BusinessLogic;

public class CustodianBusinessLogic : ICustodianBusinessLogic
public class CustodianBusinessLogic(IPortalRepositories portalRepositories, ICustodianService custodianService)
: ICustodianBusinessLogic
{
private readonly IPortalRepositories _portalRepositories;
private readonly ICustodianService _custodianService;

public CustodianBusinessLogic(IPortalRepositories portalRepositories, ICustodianService custodianService)
{
_portalRepositories = portalRepositories;
_custodianService = custodianService;
}

/// <inheritdoc />
public async Task<WalletData?> GetWalletByBpnAsync(Guid applicationId, CancellationToken cancellationToken)
{
var bpn = await _portalRepositories.GetInstance<IApplicationRepository>()
var bpn = await portalRepositories.GetInstance<IApplicationRepository>()
.GetBpnForApplicationIdAsync(applicationId).ConfigureAwait(ConfigureAwaitOptions.None);

if (string.IsNullOrWhiteSpace(bpn))
{
throw new ConflictException("BusinessPartnerNumber is not set");
}

var walletData = await _custodianService.GetWalletByBpnAsync(bpn, cancellationToken)
var walletData = await custodianService.GetWalletByBpnAsync(bpn, cancellationToken)
.ConfigureAwait(ConfigureAwaitOptions.None);

return walletData;
Expand Down Expand Up @@ -88,7 +81,7 @@ public CustodianBusinessLogic(IPortalRepositories portalRepositories, ICustodian

private async Task<string> CreateWalletInternal(Guid applicationId, CancellationToken cancellationToken)
{
var result = await _portalRepositories.GetInstance<IApplicationRepository>().GetCompanyAndApplicationDetailsForCreateWalletAsync(applicationId).ConfigureAwait(ConfigureAwaitOptions.None);
var result = await portalRepositories.GetInstance<IApplicationRepository>().GetCompanyAndApplicationDetailsForCreateWalletAsync(applicationId).ConfigureAwait(ConfigureAwaitOptions.None);
if (result == default)
{
throw new ConflictException($"CompanyApplication {applicationId} is not in status SUBMITTED");
Expand All @@ -100,6 +93,6 @@ private async Task<string> CreateWalletInternal(Guid applicationId, Cancellation
throw new ConflictException($"BusinessPartnerNumber (bpn) for CompanyApplications {applicationId} company {companyId} is empty");
}

return await _custodianService.CreateWalletAsync(businessPartnerNumber, companyName, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
return await custodianService.CreateWalletAsync(businessPartnerNumber, companyName, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
}
}
Loading

0 comments on commit f1822e3

Please sign in to comment.