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
31 changes: 19 additions & 12 deletions datatypes-examples.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,15 @@
</payment-bank>
</invoice-payment>

<opening-receipt xmlns="http://api.digipost.no/schema/datatypes">
<group>aarsoppgave-bedriftAS-2025</group>
</opening-receipt>

<opening-receipt-accepted xmlns="http://api.digipost.no/schema/datatypes"/>

<payslip xmlns="http://api.digipost.no/schema/datatypes">
<payment-date>2020-09-21</payment-date>
<net-amount>5000</net-amount>
<payment-date>2025-01-01</payment-date>
<net-amount>42000.00</net-amount>
</payslip>

<pickup-notice xmlns="http://api.digipost.no/schema/datatypes">
Expand Down Expand Up @@ -407,12 +413,6 @@

<share-documents-request-sharing-stopped xmlns="http://api.digipost.no/schema/datatypes"/>

<opening-receipt xmlns="http://api.digipost.no/schema/datatypes">
<group>aarsoppgave-bedriftAS-2025</group>
</opening-receipt>

<opening-receipt-accepted xmlns="http://api.digipost.no/schema/datatypes"/>

<signedDocument xmlns="http://api.digipost.no/schema/datatypes">
<document-issuer>Bedrift AS</document-issuer>
<document-subject>Ansettelseskontrakt</document-subject>
Expand All @@ -424,9 +424,16 @@
<valid-from>2025-01-01T10:00:00+02:00</valid-from>
<valid-until>2030-01-01T10:00:00+02:00</valid-until>
<title>Drivers Licence</title>
<description>This document confirms that the holder has a license to drive vehicles under the specified
categories.
</description>
<description>This document confirms that the holder has a license to drive vehicles under the specified categories.</description>
</verifiable-credential-notice>

</datatypes>
<verifiable-presentation-notice xmlns="http://api.digipost.no/schema/datatypes">
<title>Driver’s License</title>
<description>We would like to verify your driver’s license.</description>
<simpleQuery>
<type>driversLicence</type>
<format>JWT_VC_JSON</format>
</simpleQuery>
</verifiable-presentation-notice>

</datatypes>
2,334 changes: 1,845 additions & 489 deletions datatypes.xsd

Large diffs are not rendered by default.

138 changes: 91 additions & 47 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
|[ShareDocumentsRequestSharingStopped](#sharedocumentsrequestsharingstopped)|Stop sharing of documents for ShareDocumentsRequest|
|[SignedDocument](#signeddocument)|Details about a signed document|
|[VerifiableCredentialNotice](#verifiablecredentialnotice)|Represents a legal document (Certificate, Licence, Permit, etc.) issued to a single person.|
|[VerifiablePresentationNotice](#verifiablepresentationnotice)|A request for a verifiable presentation. The request must include a credentials query of either dcql_query og simple_query.|

## Appointment

Expand Down Expand Up @@ -455,24 +456,57 @@ Payment information for an invoice
</invoice-payment>
```

## OpeningReceipt

To open the document the user must accept to send an opening receipt

### Fields

|Name|Type|Required|Description|
|----|----|--------|-----------|
|group|String|yes|This is the group identifier for the opening receipt|

### XML

```xml
<opening-receipt xmlns="http://api.digipost.no/schema/datatypes">
<group>aarsoppgave-bedriftAS-2025</group>
</opening-receipt>
```

## OpeningReceiptAccepted

The document has been opened, and the opening receipt has been accepted and sent.

### Fields

|Name|Type|Required|Description|
|----|----|--------|-----------|


### XML

```xml
<opening-receipt-accepted xmlns="http://api.digipost.no/schema/datatypes"/>
```

Comment on lines +459 to +492
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Samme innspill her om autmoatisk omrokkering. Flytt tilbake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Samme kommentar som over. Generatoren legger de automatisk i alfabetisk rekkefølge, så denne rekkefølgen er riktig

## Payslip

For treating documents as Payslips.

### Fields

| Name | Type | Required | Description |
|-------------|------------|----------|----------------------------------------|
| paymentDate | LocalDate | no | The date when the salary is paid out |
| netAmount | BigDecimal | no | Net salary, the actual amount paid out |

|Name|Type|Required|Description|
|----|----|--------|-----------|
|paymentDate|LocalDate|no|The date when the salary is paid out|
|netAmount|BigDecimal|no|Net salary, the actual amount received|

### XML

```xml
<payslip xmlns="http://api.digipost.no/schema/datatypes">
<payment-date>2020-09-21</payment-date>
<net-amount>5000</net-amount>
<payment-date>2025-01-01</payment-date>
<net-amount>42000.00</net-amount>
</payslip>
```

Expand Down Expand Up @@ -1151,44 +1185,6 @@ Stop sharing of documents for ShareDocumentsRequest
```xml
<share-documents-request-sharing-stopped xmlns="http://api.digipost.no/schema/datatypes"/>
```
```

## OpeningReceipt

To open the document the user must accept to send an opening receipt

### Complemented by:
[OpeningReceiptAccepted](#openingreceiptaccepted)

### Fields

|Name|Type|Required|Description|
|----|----|--------|-----------|
|group|String|yes|This is the group identifier for the opening receipt|

### XML

```xml
<opening-receipt xmlns="http://api.digipost.no/schema/datatypes">
<group>aarsoppgave-bedriftAS-2025</group>
</opening-receipt>
```

## OpeningReceiptAccepted

The document has been opened, and the opening receipt has been accepted and sent.

### Fields

|Name|Type|Required|Description|
|----|----|--------|-----------|


### XML

```xml
<opening-receipt-accepted xmlns="http://api.digipost.no/schema/datatypes"/>
```

## SignedDocument

Expand Down Expand Up @@ -1233,7 +1229,55 @@ Represents a legal document (Certificate, Licence, Permit, etc.) issued to a sin
<credential-id>DL-1234567890</credential-id>
<valid-from>2025-01-01T10:00:00+02:00</valid-from>
<valid-until>2030-01-01T10:00:00+02:00</valid-until>
<title>Drivers Licence</title>
<description>This document confirms that the holder has a license to drive vehicles under the specified categories.</description>
<title>Drivers Licence</title>
<description>This document confirms that the holder has a license to drive vehicles under the specified categories.</description>
</verifiable-credential-notice>
```

## VerifiablePresentationNotice

A request for a verifiable presentation. The request must include a credentials query of either dcql_query og simple_query.

### Fields

|Name|Type|Required|Description|
|----|----|--------|-----------|
|title|String|yes|The title of the presentation request|
|description|String|yes|A detailed explanation of the presentation request.|
|simpleQuery|[SimpleQuery](#verifiablepresentationnoticesimplequery)|no|A simplified credential query format|
|dcqlQuery|[DcqlQuery](#verifiablepresentationnoticedcqlquery)|no|A credentials query following the Digital Credentials Query Language (DCQL) specification.|

### VerifiablePresentationNotice.SimpleQuery

|Name|Type|Required|Description|
|----|----|--------|-----------|
|type|String|no||
|format|[Format](#verifiablepresentationnoticeformat)|no||

### VerifiablePresentationNotice.Format

Valid values:

* JWT_VC_JSON
* MSO_MDOC
* SD_JWT

### VerifiablePresentationNotice.DcqlQuery

|Name|Type|Required|Description|
|----|----|--------|-----------|
|credentials|List|yes|List of credential queries as per DCQL.|
|credentialSets|List|no|Optional credential sets for advanced DCQL queries.|

### XML

```xml
<verifiable-presentation-notice xmlns="http://api.digipost.no/schema/datatypes">
<title>Driver’s License</title>
<description>We would like to verify your driver’s license.</description>
<simpleQuery>
<type>driversLicence</type>
<format>JWT_VC_JSON</format>
</simpleQuery>
</verifiable-presentation-notice>
```
2 changes: 2 additions & 0 deletions src/main/java/no/digipost/api/datatypes/DataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import no.digipost.api.datatypes.types.share.ShareDocumentsRequestDocumentsShared;
import no.digipost.api.datatypes.types.share.ShareDocumentsRequestSharingStopped;
import no.digipost.api.datatypes.types.verifiableCredential.VerifiableCredentialNotice;
import no.digipost.api.datatypes.types.verifiableCredential.VerifiablePresentationNotice;

@JsonTypeInfo(use = JsonTypeInfo.Id.SIMPLE_NAME, property = "type", include = JsonTypeInfo.As.EXISTING_PROPERTY)
@JsonSubTypes({
Expand All @@ -47,6 +48,7 @@
, @JsonSubTypes.Type(OpeningReceipt.class)
, @JsonSubTypes.Type(OpeningReceiptAccepted.class)
, @JsonSubTypes.Type(VerifiableCredentialNotice.class)
, @JsonSubTypes.Type(VerifiablePresentationNotice.class)
})
public interface DataType {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import no.digipost.api.datatypes.types.share.ShareDocumentsRequestDocumentsShared;
import no.digipost.api.datatypes.types.share.ShareDocumentsRequestSharingStopped;
import no.digipost.api.datatypes.types.verifiableCredential.VerifiableCredentialNotice;
import no.digipost.api.datatypes.types.verifiableCredential.VerifiablePresentationNotice;

import java.util.Collections;
import java.util.Map;
Expand Down Expand Up @@ -62,6 +63,7 @@ public enum DataTypeIdentifier {
, OPENING_RECEIPT(OpeningReceipt.class, "OPRC", OpeningReceipt.EXAMPLE)
, OPENING_RECEIPT_ACCEPTED(OpeningReceiptAccepted.class, "OPAC", OpeningReceiptAccepted.EXAMPLE)
, VERIFIABLE_CREDENTIAL_NOTICE(VerifiableCredentialNotice.class, "VCNO", VerifiableCredentialNotice.EXAMPLE)
, VERIFIABLE_PRESENTATION_NOTICE(VerifiablePresentationNotice.class, "VPNO", VerifiablePresentationNotice.EXAMPLE)
;

private final Class<? extends DataType> dataType;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package no.digipost.api.datatypes.types.verifiableCredential;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import lombok.*;
import no.digipost.api.datatypes.documentation.Description;

import java.util.List;

import static no.digipost.api.datatypes.types.verifiableCredential.Format.*;

@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@With
public class DcqlQuery {

@XmlElementWrapper(name = "credentials")
@XmlElement(name = "credential")
@JsonProperty("credentials")
@Description("List of credential queries as per DCQL.")
@NotNull
List<Credential> credentials;

@XmlElementWrapper(name = "credential_sets")
@XmlElement(name = "credential_set")
@JsonProperty("credential_sets")
@Description("Optional credential sets for advanced DCQL queries.")
List<CredentialSet> credentialSets;


@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@With
public static class Credential {
@XmlElement(name = "id")
String id;

@XmlElement(name = "format")
Format format;

@XmlElement(name = "meta")
Meta meta;

@XmlElementWrapper(name = "claims")
@XmlElement(name = "claim")
List<Claim> claims;

@XmlElementWrapper(name = "claim_sets")
@XmlElement(name = "claim_set")
@JsonProperty("claim_sets")
List<ClaimSet> claimSets;

public static Credential jwtVc(String id, List<String> typeValues) {
return new Credential(id, JWT_VC_JSON, new Meta(typeValues, null, null), null, null);
}

public static Credential mdoc(String id, String doctypeValue) {
return new Credential(id, MSO_MDOC, new Meta(null, doctypeValue, null), null, null);
}

public static Credential sdJwt(String id, List<String> vctValues) {
return new Credential(id, SD_JWT, new Meta(null, null, vctValues), null, null);
}
}

@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@With
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class Meta {
@XmlElement(name = "type_values")
@JsonProperty("type_values")
@Description("Must be specified when format is JWT_VC_JSON")
List<String> typeValues;

@XmlElement(name = "doctype_value")
@JsonProperty("doctype_value")
@Description("Must be specified when format is MSO_MDOC")
String doctypeValue;

@XmlElementWrapper(name = "vct_values")
@XmlElement(name = "vct_value")
@JsonProperty("vct_values")
@Description("Must be specified when format is SD_JWT")
List<String> vctValues;
}

@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@With
public static class Claim {
@XmlElementWrapper(name = "path")
@XmlElement(name = "path_element")
List<String> path;

@XmlElement(name = "id")
String id;

@XmlElementWrapper(name = "values")
@XmlElement(name = "value")
List<String> values;
}

@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@With
public static class ClaimSet {
@XmlElementWrapper(name = "claims")
@XmlElement(name = "claim_id")
List<String> claims;
}

@Value
@AllArgsConstructor
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@With
public static class CredentialSet {
@XmlElementWrapper(name = "options")
@XmlElement(name = "option")
List<VerifiablePresentationNotice.Option> options;

@XmlElement(name = "required")
Boolean required;
}
}
Loading