Skip to content

Commit

Permalink
feat(ssi): remove old ssi endpoints (#780)
Browse files Browse the repository at this point in the history
Refs: #538
Reviewed-By: Evelyn Gurschler <[email protected]>
  • Loading branch information
Phil91 authored May 29, 2024
1 parent 05c34ff commit a392441
Show file tree
Hide file tree
Showing 57 changed files with 10,012 additions and 4,118 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,12 @@ public class CompanyDataSettings
{
public CompanyDataSettings()
{
UseCaseParticipationMediaTypes = null!;
SsiCertificateMediaTypes = null!;
CompanyCertificateMediaTypes = null!;
DecentralIdentityManagementAuthUrl = null!;
IssuerDid = null!;
BpnDidResolverUrl = null!;
}

/// <summary>
/// The media types that are allowed for the uploaded document for use case participation
/// </summary>
[Required]
[EnumEnumeration]
[DistinctValues]
public IEnumerable<MediaTypeId> UseCaseParticipationMediaTypes { get; set; }

/// <summary>
/// The media types that are allowed for the uploaded document for ssi certificate
/// </summary>
[Required]
[EnumEnumeration]
[DistinctValues]
public IEnumerable<MediaTypeId> SsiCertificateMediaTypes { get; set; }

/// <summary>
/// The media types that are allowed for the uploaded document for company certificate
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,7 @@ public interface ICompanyDataBusinessLogic
IAsyncEnumerable<CompanyRoleConsentViewData> GetCompanyRoleAndConsentAgreementDetailsAsync(string? languageShortName);

Task CreateCompanyRoleAndConsentAgreementDetailsAsync(IEnumerable<CompanyRoleConsentDetails> companyRoleConsentDetails);

Task<IEnumerable<UseCaseParticipationData>> GetUseCaseParticipationAsync(string? language);

Task<IEnumerable<SsiCertificateData>> GetSsiCertificatesAsync();

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);

Task ApproveCredential(Guid credentialId, CancellationToken cancellationToken);

Task RejectCredential(Guid credentialId);

IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes();

IAsyncEnumerable<CompanyCertificateBpnData> GetCompanyCertificatesByBpn(string businessPartnerNumber);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,52 +171,6 @@ public async Task<NoContentResult> CreateCompanyRoleAndConsentAgreementDetailsAs
return NoContent();
}

/// <summary>
/// Gets all use case frameworks and the participation status of the acting company
/// </summary>
/// <remarks>Example: Get: api/administration/companydata/useCaseParticipation</remarks>
/// <returns>All UseCaseParticipations and the particiation status of the acting company</returns>
/// <response code="200">Returns a collection of UseCaseParticipation.</response>
/// <response code="409">There should only be one pending or active SSI detail be assigned</response>
[HttpGet]
[Authorize(Roles = "view_use_case_participation")]
[Authorize(Policy = PolicyTypes.ValidCompany)]
[Route("useCaseParticipation")]
[ProducesResponseType(typeof(IEnumerable<UseCaseParticipationData>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public Task<IEnumerable<UseCaseParticipationData>> GetUseCaseParticipation([FromQuery] string? language) =>
_logic.GetUseCaseParticipationAsync(language);

/// <summary>
/// Gets all company certificate requests and their status
/// </summary>
/// <returns>All SSI certifications of the own company</returns>
/// <remarks>Example: Get: api/administration/companydata/certificates</remarks>
/// <response code="200">Returns a collection of certificates.</response>
/// <response code="409">There should only be one pending or active SSI detail be assigned</response>
[HttpGet]
[Authorize(Roles = "view_certificates")]
[Authorize(Policy = PolicyTypes.ValidCompany)]
[Route("certificates")]
[ProducesResponseType(typeof(IEnumerable<SsiCertificateTransferData>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public Task<IEnumerable<SsiCertificateData>> GetSsiCertificationData() =>
_logic.GetSsiCertificatesAsync();

/// <summary>
/// Gets the certificate types for which the company can apply for
/// </summary>
/// <returns>All certificate types for which the company can apply for</returns>
/// <remarks>Example: Get: api/administration/companydata/certificateTypes</remarks>
/// <response code="200">Returns a collection of VerifiedCredentialTypeIds.</response>
[HttpGet]
[Authorize(Roles = "request_ssicredential")]
[Authorize(Policy = PolicyTypes.ValidCompany)]
[Route("certificateTypes")]
[ProducesResponseType(typeof(IEnumerable<SsiCertificateTransferData>), StatusCodes.Status200OK)]
public IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes() =>
_logic.GetCertificateTypes();

/// <summary>
/// Creates the use case participation request
/// </summary>
Expand All @@ -240,32 +194,6 @@ public IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes() =>
public Task<Guid> CreateUseCaseParticipation([FromForm] UseCaseParticipationCreationData data, CancellationToken cancellationToken) =>
this.WithBearerToken(token => _logic.CreateUseCaseParticipation(data, token, cancellationToken));

/// <summary>
/// Creates the SSI Certificate request
/// </summary>
/// <param name="data">The type and document</param>
/// <param name="cancellationToken">Cancellation Token</param>
/// <returns>The id of the created SSI certificate request</returns>
/// <remarks>Example: POST: api/administration/companydata/certificates</remarks>
/// <response code="204">Successfully created the SSI certificate request.</response>
/// <response code="400">
/// credentialTypeId is not assigned to a certificate <br />
/// Credential request already exist
/// </response>
[HttpPost]
[Consumes("multipart/form-data")]
[Authorize(Roles = "request_ssicredential")]
[Authorize(Policy = PolicyTypes.ValidIdentity)]
[Authorize(Policy = PolicyTypes.ValidCompany)]
[Route("certificates")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
public async Task<NoContentResult> CreateSsiCertificate([FromForm] SsiCertificateCreationData data, CancellationToken cancellationToken)
{
await _logic.CreateSsiCertificate(data, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
return NoContent();
}

/// <summary>
/// Creates the Company Certificate request
/// </summary>
Expand Down Expand Up @@ -396,79 +324,6 @@ public async Task<ActionResult> GetCompanyCertificateDocumentContentFileAsync([F
public Task<int> DeleteCompanyCertificate([FromRoute] Guid documentId) =>
_logic.DeleteCompanyCertificateAsync(documentId);

/// <summary>
/// Gets all outstanding, existing and inactive credentials
/// </summary>
/// <remarks>Example: Get: /api/administration/companydata/credentials/</remarks>
/// <param name="page">The page to get</param>
/// <param name="size">Amount of entries</param>
/// <param name="companySsiDetailStatusId">OPTIONAL: Filter for the status</param>
/// <param name="credentialTypeId">OPTIONAL: The type of the credential that should be returned</param>
/// <param name="companyName">OPTIONAL: Search string for the company name</param>
/// <param name="sorting">Defines the sorting of the list</param>
/// <response code="200">Collection of the credentials.</response>
[HttpGet]
[Authorize(Roles = "decision_ssicredential")]
[Authorize(Policy = PolicyTypes.ValidIdentity)]
[Route("credentials", Name = nameof(GetCredentials))]
[ProducesResponseType(typeof(IEnumerable<CredentialDetailData>), StatusCodes.Status200OK)]
public Task<Pagination.Response<CredentialDetailData>> GetCredentials(
[FromQuery] int page = 0,
[FromQuery] int size = 15,
[FromQuery] CompanySsiDetailStatusId? companySsiDetailStatusId = null,
[FromQuery] VerifiedCredentialTypeId? credentialTypeId = null,
[FromQuery] string? companyName = null,
[FromQuery] CompanySsiDetailSorting? sorting = null) =>
_logic.GetCredentials(page, size, companySsiDetailStatusId, credentialTypeId, companyName, sorting);

/// <summary>
/// Approves the given credential and triggers the verified credential creation
/// </summary>
/// <remarks>Example: PUT: api/administration/companydata/credentials/{credentialId}/approval</remarks>
/// <param name="credentialId">Id of the entry that should be approved</param>
/// <param name="cts">Cancellation Token</param>
/// <returns>No Content</returns>
/// <response code="204">Successfully approved the credentials and triggered the verified credential creation.</response>
/// <response code="404">CompanySsiDetail does not exists</response>
/// <response code="409">
/// Credential is in Incorrect State <br />
/// VerifiedCredentialTypeKindId must not be null
/// </response>
[HttpPut]
[Authorize(Roles = "decision_ssicredential")]
[Authorize(Policy = PolicyTypes.CompanyUser)]
[Route("credentials/{credentialId}/approval")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public async Task<NoContentResult> ApproveCredential([FromRoute] Guid credentialId, CancellationToken cts)
{
await _logic.ApproveCredential(credentialId, cts).ConfigureAwait(ConfigureAwaitOptions.None);
return NoContent();
}

/// <summary>
/// Rejects the given credential
/// </summary>
/// <remarks>Example: PUT: api/administration/companydata/credentials/{credentialId}/reject</remarks>
/// <param name="credentialId">Id of the entry that should be rejected</param>
/// <returns>No Content</returns>
/// <response code="204">Successfully rejected the credential.</response>
/// <response code="404">CompanySsiDetail does not exists</response>
/// <response code="409">CredentialSsiDetail is in Incorrect State</response>
[HttpPut]
[Authorize(Roles = "decision_ssicredential")]
[Authorize(Policy = PolicyTypes.CompanyUser)]
[Route("credentials/{credentialId}/reject")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)]
public async Task<NoContentResult> RejectCredential([FromRoute] Guid credentialId)
{
await _logic.RejectCredential(credentialId).ConfigureAwait(ConfigureAwaitOptions.None);
return NoContent();
}

/// <summary>
/// Rejects the given credential
/// </summary>
Expand Down

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions src/administration/Administration.Service/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@
},
"CompanyData": {
"MaxPageSize": 20,
"UseCaseParticipationMediaTypes": [],
"SsiCertificateMediaTypes": [],
"CompanyCertificateMediaTypes":[],
"DecentralIdentityManagementAuthUrl": "",
"IssuerDid": "",
Expand Down
32 changes: 16 additions & 16 deletions src/externalsystems/Custodian.Library/Custodian.Library.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>Org.Eclipse.TractusX.Portal.Backend.Custodian.Library</AssemblyName>
<RootNamespace>Org.Eclipse.TractusX.Portal.Backend.Custodian.Library</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>Org.Eclipse.TractusX.Portal.Backend.Custodian.Library</AssemblyName>
<RootNamespace>Org.Eclipse.TractusX.Portal.Backend.Custodian.Library</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\framework\Framework.IO\Framework.IO.csproj" />
<ProjectReference Include="..\..\framework\Framework.Token\Framework.Token.csproj" />
<ProjectReference Include="..\..\portalbackend\PortalBackend.DBAccess\PortalBackend.DBAccess.csproj" />
<ProjectReference Include="..\..\processes\ApplicationChecklist.Library\ApplicationChecklist.Library.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\framework\Framework.IO\Framework.IO.csproj" />
<ProjectReference Include="..\..\framework\Framework.Token\Framework.Token.csproj" />
<ProjectReference Include="..\..\portalbackend\PortalBackend.DBAccess\PortalBackend.DBAccess.csproj" />
<ProjectReference Include="..\..\processes\ApplicationChecklist.Library\ApplicationChecklist.Library.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
</ItemGroup>

</Project>
12 changes: 4 additions & 8 deletions src/externalsystems/Custodian.Library/CustodianService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,31 +113,27 @@ public async Task<string> SetMembership(string bpn, CancellationToken cancellati
}

/// <inheritdoc />
public async Task TriggerFrameworkAsync(string bpn, UseCaseDetailData useCaseDetailData, CancellationToken cancellationToken)
public async Task TriggerFrameworkAsync(string bpn, CancellationToken cancellationToken)
{
using var httpClient = await tokenService.GetAuthorizedClient<CustodianService>(_settings, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);

var requestBody = new CustodianFrameworkRequest
(
bpn,
useCaseDetailData.VerifiedCredentialExternalTypeId,
useCaseDetailData.Template,
useCaseDetailData.Version
bpn
);

await httpClient.PostAsJsonAsync("/api/credentials/issuer/framework", requestBody, Options, cancellationToken)
.CatchingIntoServiceExceptionFor("custodian-framework-post", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE).ConfigureAwait(false);
}

/// <inheritdoc />
public async Task TriggerDismantlerAsync(string bpn, VerifiedCredentialTypeId credentialTypeId, CancellationToken cancellationToken)
public async Task TriggerDismantlerAsync(string bpn, CancellationToken cancellationToken)
{
using var httpClient = await tokenService.GetAuthorizedClient<CustodianService>(_settings, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);

var requestBody = new CustodianDismantlerRequest
(
bpn,
credentialTypeId
bpn
);

await httpClient.PostAsJsonAsync("/api/credentials/issuer/dismantler", requestBody, Options, cancellationToken)
Expand Down
6 changes: 2 additions & 4 deletions src/externalsystems/Custodian.Library/ICustodianService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ public interface ICustodianService
/// Issue a verifiable credential for a use case
/// </summary>
/// <param name="bpn">BusinessPartnerNumber of the company to issue the credentials for</param>
/// <param name="useCaseDetailData">Additional data needed for the endpoint</param>
/// <param name="cancellationToken">CancellationToken</param>
Task TriggerFrameworkAsync(string bpn, UseCaseDetailData useCaseDetailData, CancellationToken cancellationToken);
Task TriggerFrameworkAsync(string bpn, CancellationToken cancellationToken);

/// <summary>
/// Issue a verifiable credential for a dismantler
/// </summary>
/// <param name="bpn">BusinessPartnerNumber of the company to issue the credentials for</param>
/// <param name="credentialTypeId">The credential type id</param>
/// <param name="cancellationToken">CancellationToken</param>
Task TriggerDismantlerAsync(string bpn, VerifiedCredentialTypeId credentialTypeId, CancellationToken cancellationToken);
Task TriggerDismantlerAsync(string bpn, CancellationToken cancellationToken);
}
Loading

0 comments on commit a392441

Please sign in to comment.