Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,74 +1,84 @@
using System.Text.Json.Serialization;
using Altinn.AccessManagement.Core.Enums;
#nullable enable
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using Altinn.AccessManagement.Core.Enums.ResourceRegistry;

namespace Altinn.AccessManagement.Core.Models.ResourceRegistry
{
/// <summary>
/// Model describing a complete resource from the resource registry.
/// Model describing a complete resource from the resrouce registry
/// </summary>
public class ServiceResource
{
/// <summary>
/// The identifier of the resource
/// </summary>
public string Identifier { get; set; }
[Required]
public string? Identifier { get; set; }

/// <summary>
/// The version of the resource
/// </summary>
public string? Version { get; set; }

/// <summary>
/// The title of service
/// </summary>
public Dictionary<string, string> Title { get; set; }
[Required]
public Dictionary<string, string>? Title { get; set; }

/// <summary>
/// Description
/// </summary>
public Dictionary<string, string> Description { get; set; }
[Required]
public Dictionary<string, string>? Description { get; set; }

/// <summary>
/// Description explaining the rights a recipient will receive if given access to the resource
/// </summary>
public Dictionary<string, string> RightDescription { get; set; }
public Dictionary<string, string>? RightDescription { get; set; }

/// <summary>
/// The homepage
/// </summary>
public string Homepage { get; set; }
public string? Homepage { get; set; }

/// <summary>
/// The status
/// </summary>
public string Status { get; set; }
public string? Status { get; set; }

/// <summary>
/// spatial coverage
/// This property represents that area(s) a Public Service is likely to be available only within, typically the area(s) covered by a particular public authority.
/// </summary>
public List<string> Spatial { get; set; }
public List<string>? Spatial { get; set; }

/// <summary>
/// List of possible contact points
/// </summary>
public List<ContactPoint> ContactPoints { get; set; }
[Required]
public List<ContactPoint>? ContactPoints { get; set; }

/// <summary>
/// Linkes to the outcome of a public service
/// </summary>
public List<string> Produces { get; set; }
public List<string>? Produces { get; set; }

/// <summary>
/// IsPartOf
/// </summary>
public string IsPartOf { get; set; }
public string? IsPartOf { get; set; }

/// <summary>
/// ThematicAreas
/// </summary>
public List<string> ThematicAreas { get; set; }
public List<string>? ThematicAreas { get; set; }

/// <summary>
/// ResourceReference
/// </summary>
public List<ResourceReference> ResourceReferences { get; set; }
public List<ResourceReference>? ResourceReferences { get; set; }

/// <summary>
/// Is this resource possible to delegate to others or not
Expand All @@ -83,12 +93,13 @@ public class ServiceResource
/// <summary>
/// HasCompetentAuthority
/// </summary>
public CompetentAuthority HasCompetentAuthority { get; set; }
[Required]
public CompetentAuthority? HasCompetentAuthority { get; set; }

/// <summary>
/// Keywords
/// </summary>
public List<Keyword> Keywords { get; set; }
public List<Keyword>? Keywords { get; set; }

/// <summary>
/// Sets the access list mode for the resource
Expand All @@ -115,22 +126,37 @@ public class ServiceResource
/// <summary>
/// Available for type defines which type of entity / person that resource targets
/// </summary>
public List<ResourcePartyType> AvailableForType { get; set; }
public List<ResourcePartyType>? AvailableForType { get; set; }

/// <summary>
/// List of autorizationReference attributes to reference this resource in authorization API
/// </summary>
public List<AttributeMatch> AuthorizationReference { get; set; }
public List<AttributeMatch>? AuthorizationReference { get; set; }

/// <summary>
/// Consent template defines which template to use if resource is a consent resource
/// </summary>
public string? ConsentTemplate { get; set; }

/// <summary>
/// Consent text is markdown text used if resource is a consent resource
/// </summary>
public Dictionary<string, string>? ConsentText { get; set; }

/// <summary>
/// Defines consentmetadata for consent resources
/// </summary>
public Dictionary<string, ConsentMetadata>? ConsentMetadata { get; set; }

/// <summary>
/// Defines consentmendtata for consent resources
/// Defines if consent resource is used for one time consents, or consents with an expiry date
/// </summary>
public Dictionary<string,ConsentMetadata> ConsentMetadata { get; set; }
public bool IsOneTimeConsent { get; set; }

/// <summary>
/// The consent template that is used for this resource.
/// Gets or sets the unique identifier for the version of the entity.
/// </summary>
public string ConsentTemplate { get; set; }
public int VersionId { get; set; }

/// <summary>
/// Writes key information when this object is written to Log.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,8 @@ private static void ValidateContext(ConsentContext context, ref ValidationErrorB
}
else
{
ServiceResource resourceDetails = await _resourceRegistryClient.GetResource(consentRight.Resource[0].Value, cancelactionToken);
ConsentResourceAttribute consentResourceAttribute = consentRight.Resource[0];
ServiceResource resourceDetails = await _resourceRegistryClient.GetResource(consentResourceAttribute.Value, cancelactionToken);
if (resourceDetails == null)
{
problemsBuilder.Add(Problems.InvalidConsentResource);
Expand All @@ -744,6 +745,7 @@ private static void ValidateContext(ConsentContext context, ref ValidationErrorB
else
{
ValidateConsentMetadata(ref problemsBuilder, rightIndex, consentRight, resourceDetails);
consentResourceAttribute.Version = resourceDetails.VersionId.ToString();
}

if (resourceDetails != null && string.IsNullOrEmpty(templateId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ public async Task GetConsent_Valid()
Assert.Equal("d5b861c8-8e3b-44cd-9952-5315e5990cf5", consentRequest.From.ValueSpan);
Assert.Equal("8ef5e5fa-94e1-4869-8635-df86b6219181", consentRequest.To.ValueSpan); // TODO FIx
Assert.Equal("urn:altinn:resource", consentRequest.ConsentRights[0].Resource[0].Type);
Assert.Equal("1", consentRequest.ConsentRights[0].Resource[0].Version);
Assert.Equal("4", consentRequest.ConsentRights[1].Resource[0].Version);
Assert.Equal(consentContextExternal.Language, consentRequest.Context.Language);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"iD": "a4253d59-b40f-409a-a3f7-c6395f065192",
"from": "urn:altinn:party:uuid:d5b861c8-8e3b-44cd-9952-5315e5990cf5",
"to": "urn:altinn:party:uuid:8ef5e5fa-94e1-4869-8635-df86b6219181",
Expand All @@ -17,7 +17,8 @@
"resource": [
{
"type": "urn:altinn:resource",
"value": "ttd_skattegrunnlag"
"value": "ttd_skattegrunnlag",
"version": "1"
}
],
"metadata": {
Expand All @@ -32,7 +33,8 @@
"resource": [
{
"type": "urn:altinn:resource",
"value": "ttd_inntektsopplysninger"
"value": "ttd_inntektsopplysninger",
"version": "4"
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"iD": "e2071c55-6adf-487b-af05-9198a230ed44",
"from": "urn:altinn:party:uuid:d5b861c8-8e3b-44cd-9952-5315e5990cf5",
"to": "urn:altinn:party:uuid:8ef5e5fa-94e1-4869-8635-df86b6219181",
Expand All @@ -16,7 +16,8 @@
"resource": [
{
"type": "urn:altinn:resource",
"value": "ttd_skattegrunnlag"
"value": "ttd_skattegrunnlag",
"version": "1"
}
],
"metadata": {
Expand All @@ -31,7 +32,8 @@
"resource": [
{
"type": "urn:altinn:resource",
"value": "ttd_inntektsopplysninger"
"value": "ttd_inntektsopplysninger",
"version": "4"
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"resource": [
{
"type": "urn:altinn:resource",
"value": "ttd_skattegrunnlag"
"value": "ttd_skattegrunnlag",
"version": "1"
}
],
"metadata": {
Expand All @@ -31,7 +32,8 @@
"resource": [
{
"type": "urn:altinn:resource",
"value": "ttd_inntektsopplysninger"
"value": "ttd_inntektsopplysninger",
"version": "4"
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"iD": "e2071c55-6adf-487b-af05-9198a230ed77",
"from": "urn:altinn:party:uuid:00000000-0000-0000-0005-000000006078",
"to": "urn:altinn:party:uuid:8ef5e5fa-94e1-4869-8635-df86b6219181",
Expand All @@ -16,7 +16,8 @@
"resource": [
{
"type": "urn:altinn:resource",
"value": "ttd_skattegrunnlag"
"value": "ttd_skattegrunnlag",
"version": "1"
}
],
"metadata": {
Expand All @@ -31,7 +32,8 @@
"resource": [
{
"type": "urn:altinn:resource",
"value": "ttd_inntektsopplysninger"
"value": "ttd_inntektsopplysninger",
"version": "4"
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"iD": "e579b7a2-7994-4636-9aca-59e114915b70",
"from": "urn:altinn:party:uuid:d5b861c8-8e3b-44cd-9952-5315e5990cf5",
"to": "urn:altinn:party:uuid:8ef5e5fa-94e1-4869-8635-df86b6219181",
Expand All @@ -12,7 +12,8 @@
"resource": [
{
"type": "urn:altinn:resource",
"value": "ttd_skattegrunnlag"
"value": "ttd_skattegrunnlag",
"version": "1"
}
],
"metadata": {
Expand All @@ -27,7 +28,8 @@
"resource": [
{
"type": "urn:altinn:resource",
"value": "ttd_inntektsopplysninger"
"value": "ttd_inntektsopplysninger",
"version": "4"
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"identifier": "ttd_inntektsopplysninger",
"title": {
"en": "Consent Income Resource ",
Expand Down Expand Up @@ -45,5 +45,6 @@
"value": "ttd_inntektsopplysninger"
}
],
"consentTemplate": "sblanesoknad"
"consentTemplate": "sblanesoknad",
"versionId": 4
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"identifier": "ttd_navnescore",
"title": {
"en": "Consent Income Resource ",
Expand Down Expand Up @@ -42,5 +42,6 @@
"value": "ttd_skattegrunnlag"
}
],
"consentTemplate": "default"
"consentTemplate": "default",
"versionId": 3
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"identifier": "ttd_skattegrunnlag",
"title": {
"en": "Consent Income Resource ",
Expand Down Expand Up @@ -46,5 +46,6 @@
"value": "ttd_skattegrunnlag"
}
],
"consentTemplate": "sblanesoknad"
"consentTemplate": "sblanesoknad",
"versionId": 1
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"identifier": "ttd_skattegrunnlag2",
"title": {
"en": "Consent Income Resource ",
Expand Down Expand Up @@ -46,5 +46,6 @@
"value": "ttd_skattegrunnlag"
}
],
"consentTemplate": "sblanesoknad2"
"consentTemplate": "sblanesoknad2",
"versionId": 2
}
Loading