[java-idp-plugin-vci] 01/02: credentials endpoint review, OP conventions, error codes, key proof checks, DPoP htu from issuer, SD-JWT VC format rules - reserved claims, PKIX noise removed
Codeberg
noreply at shibboleth.net
Thu Nov 26 09:35:09 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch dec/REVIEWCREDFLOW
in repository java-idp-plugin-vci.
View the commit online:
https://codeberg.org/Shibboleth/java-idp-plugin-vci/commit/91b43c46f9a9cbb182bcf6f8d06da2a2f53c9040
commit 91b43c46f9a9cbb182bcf6f8d06da2a2f53c9040
Author: Janne Lauros <janne.lauros at csc.fi>
AuthorDate: Thu Nov 26 11:33:57 2026 +0200
credentials endpoint review, OP conventions, error codes, key proof checks, DPoP htu from issuer, SD-JWT VC format rules - reserved claims, PKIX noise removed
---
README.md | 65 +++++---
.../step-1/metadata/verifiable-credentials.json | 2 +-
.../step-2/metadata/verifiable-credentials.json | 4 +-
.../step-3/metadata/verifiable-credentials.json | 6 +-
.../step-4/metadata/verifiable-credentials.json | 6 +-
.../step-5/metadata/verifiable-credentials.json | 6 +-
.../step-6/metadata/verifiable-credentials.json | 2 +-
.../openidvci/credential/ClaimDisclosure.java | 45 +++---
.../credential/CredentialConfiguration.java | 4 +-
.../openidvci/profile/OpenIDVCIEventIds.java | 10 ++
.../CredentialIssuanceConfigurationTest.java | 21 ++-
.../impl/SelectiveDisclosureClaimTree.java | 41 ++++-
.../impl/OpenIDVCICredentialsRequestDecoder.java | 2 +-
.../impl/OpenIDVCICredentialsRequest.java | 74 ++++++---
.../DefaultOpenIDVCICredentialsConfiguration.java | 5 +
.../openidvci/profile/impl/AddCredentialShell.java | 20 +--
.../profile/impl/AddMobileSecurityObjectShell.java | 6 +-
.../BuildCredentialErrorResponseFromEvent.java | 2 +-
...FormJsonLdSelectiveDisclosureJWTCredential.java | 59 ++++----
.../FormOutboundCredentialsResponseMessage.java | 27 ++--
.../impl/FormSelectiveDisclosureJWTCredential.java | 57 ++++++-
.../openidvci/profile/impl/ParseAccessToken.java | 7 +-
.../plugin/openidvci/profile/impl/ParseProof.java | 80 +++++++---
.../openidvci/profile/impl/SignJWTCredential.java | 34 +----
.../profile/impl/SignMobileSecurityObject.java | 2 +-
.../profile/impl/ValidateExpectedGrantType.java | 101 -------------
.../profile/impl/ValidateRequestedCredential.java | 71 ++++++++-
.../security/impl/CertificateChainTrust.java | 11 +-
.../security/impl/DPoPHttpUriClaimsValidator.java | 58 ++++++--
.../META-INF/net.shibboleth.idp/postconfig.xml | 20 +++
.../openid/vci/credentials/credentials-beans.xml | 46 ++++--
.../openid/vci/credentials/credentials-flow.xml | 12 +-
.../idp/service/relying-party/postconfig.xml | 7 +-
.../openidvci/metadata/verifiable-credentials.json | 2 +-
.../impl/SelectiveDisclosureClaimTreeTest.java | 19 +++
.../OpenIDVCICredentialsRequestDecoderTest.java | 73 +++++++++
.../impl/OpenIDVCICredentialsRequestTest.java | 46 +++++-
...faultOpenIDVCICredentialsConfigurationTest.java | 37 +++++
.../profile/impl/AddCredentialShellTest.java | 26 ++++
.../BuildCredentialErrorResponseFromEventTest.java | 84 +++++++++++
...JsonLdSelectiveDisclosureJWTCredentialTest.java | 108 ++++++++++++++
.../FormSelectiveDisclosureJWTCredentialTest.java | 97 ++++++++++++
.../profile/impl/ParseAccessTokenTest.java | 165 +++++++++++++++++++++
.../openidvci/profile/impl/ParseProofTest.java | 133 +++++++++++++++++
.../profile/impl/SignJWTCredentialTest.java | 75 ++++++++++
.../impl/ValidateExpectedGrantTypeTest.java | 112 --------------
.../impl/ValidateRequestedCredentialTest.java | 27 +++-
.../security/impl/CertificateChainTrustTest.java | 47 ++++++
.../impl/DPoPHttpUriClaimsValidatorTest.java | 52 ++++++-
49 files changed, 1552 insertions(+), 464 deletions(-)
diff --git a/README.md b/README.md
index 9ca2884..fe53e43 100644
--- a/README.md
+++ b/README.md
@@ -96,6 +96,7 @@ The following optional features are not currently supported.
| Credential Offer by reference, `credential_offer_uri` | No |
| `issuer_state` | No, by design |
| Proof type `di_vp` | No |
+| Holder key as `x5c` in a `jwt` proof | No |
| Credential Response encryption | No |
| Credential Request encryption | No |
| Deferred Credential Endpoint | No |
@@ -302,7 +303,7 @@ with details that depend on the credential format. The notes below clarify only
"credential_configurations_supported": {
"GeantIncubatorDiploma_SDJWT": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_SDJWT",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_SDJWT",
"scope": "GeantIncubatorDiploma_SDJWT",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -341,6 +342,9 @@ The configuration ID, `GeantIncubatorDiploma_SDJWT` in this example, is used in
The wallet includes it in credential requests, it is used as the `scope` value, and claim values in
the access token are grouped under this ID. Use the exact same string everywhere.
+The `vct` is the type of the credential. Use a URL or URN under a domain you control, as
+[SD-JWT VC](https://datatracker.ietf.org/doc/draft-ietf-oauth-sd-jwt-vc/) requires a collision-resistant name.
+
#### Settings of your own, per credential
The `_issuance_configuration` member is not published. It controls the credential's validity
@@ -353,7 +357,7 @@ It goes inside the credential's own configuration, next to `format` and `vct`:
"credential_configurations_supported": {
"GeantIncubatorDiploma_SDJWT": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_SDJWT",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_SDJWT",
"_issuance_configuration": {
"lifetime": "P365D",
"not_before": "2026-08-01T06:00Z",
@@ -373,7 +377,7 @@ It goes inside the credential's own configuration, next to `format` and `vct`:
| `issuer` | String | `openidvci.issuer` | What the credential says issued it. `did:jwk`, `did:web` or `url`. See [Step 2](#step-2-add-a-did-web-credential) and [Step 3](#step-3-add-a-plain-url-credential). |
| `oidfed` | Boolean | `true` | Whether the credential carries the Entity Identifier of this deployment, once the deployment is in OpenID Federation. See [Step 4](#step-4-make-the-url-credential-an-openid-federation-credential). |
| `claim_types` | Array | | Type of a claim value in an mdoc where JSON has none, a date for example, `{"path": [...], "type": ...}`. See [The mdoc credential](#the-mdoc-credential) and [Complex claims](#complex-claims). |
-| `sd` | Array | | Arrays disclosed element by element as in [Disclosures for Array Elements](https://datatracker.ietf.org/doc/draft-ietf-oauth-selective-disclosure-jwt/) of SD-JWT, `{"path": [..., null], "sd": "always"}`. See [Complex claims](#complex-claims). |
+| `sd` | Array | | Arrays disclosed element by element as in [Disclosures for Array Elements](https://datatracker.ietf.org/doc/draft-ietf-oauth-selective-disclosure-jwt/) of SD-JWT, `{"path": [..., null], "sd": "always"}`, and claims that are not selectively disclosable, `{"path": [...], "sd": "never"}`. See [Complex claims](#complex-claims). |
All of these settings are optional, as is the `_issuance_configuration` member itself.
@@ -396,10 +400,10 @@ What ends up in the credential:
| Format | Members carrying the window |
|---|---|
| `dc+sd-jwt` | `iat` is the instant of issuance, `exp` closes the window, and `nbf` opens it whenever that is not the instant of issuance |
-| `vc+sd-jwt` | The same three, plus [`validFrom` and `validUntil`](https://www.w3.org/TR/vc-data-model-2.0/#validity-period), which represent the same start and end of the window |
+| `vc+sd-jwt` | `iat` and `exp`, plus [`validFrom` and `validUntil`](https://www.w3.org/TR/vc-data-model-2.0/#validity-period), which represent the start and end of the window. No `nbf` |
| `mso_mdoc` | `validityInfo` of the mobile security object: `signed` is the instant of issuance, and `validFrom` and `validUntil` are the two ends of the window |
-If the validity window starts at issuance, the credential has no `nbf` claim. By default, the
+If the validity window starts at issuance, a `dc+sd-jwt` credential has no `nbf` claim. By default, the
issuance timestamp is rounded down to the start of the hour. To use a different precision, set
`openidvci.credentialTimestampPrecision` in *conf/openid-vci.properties*:
@@ -1338,7 +1342,7 @@ The files below show their state after this step, with changes marked:
"credential_configurations_supported": {
"GeantIncubatorDiploma_SDJWT": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_SDJWT",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_SDJWT",
"scope": "GeantIncubatorDiploma_SDJWT",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -1367,7 +1371,7 @@ The files below show their state after this step, with changes marked:
+ },
+ "GeantIncubatorDiploma_DIDWEB": {
+ "format": "dc+sd-jwt",
-+ "vct": "GeantIncubatorDiploma_DIDWEB",
++ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_DIDWEB",
+ "scope": "GeantIncubatorDiploma_DIDWEB",
+ "cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
+ "credential_signing_alg_values_supported": ["ES256"],
@@ -1782,7 +1786,7 @@ The files below show their state after this step, with changes marked:
"credential_configurations_supported": {
"GeantIncubatorDiploma_SDJWT": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_SDJWT",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_SDJWT",
"scope": "GeantIncubatorDiploma_SDJWT",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -1811,7 +1815,7 @@ The files below show their state after this step, with changes marked:
},
"GeantIncubatorDiploma_DIDWEB": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_DIDWEB",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_DIDWEB",
"scope": "GeantIncubatorDiploma_DIDWEB",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -1839,7 +1843,7 @@ The files below show their state after this step, with changes marked:
+ },
+ "GeantIncubatorDiploma_URL": {
+ "format": "dc+sd-jwt",
-+ "vct": "GeantIncubatorDiploma_URL",
++ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_URL",
+ "scope": "GeantIncubatorDiploma_URL",
+ "cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
+ "credential_signing_alg_values_supported": ["ES256"],
@@ -2254,7 +2258,7 @@ unless it has `"oidfed": false`. We want only the URL-based credential to be par
"credential_configurations_supported": {
"GeantIncubatorDiploma_SDJWT": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_SDJWT",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_SDJWT",
"scope": "GeantIncubatorDiploma_SDJWT",
+ "_issuance_configuration": {
+ "oidfed": false
@@ -2286,7 +2290,7 @@ unless it has `"oidfed": false`. We want only the URL-based credential to be par
},
"GeantIncubatorDiploma_DIDWEB": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_DIDWEB",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_DIDWEB",
"scope": "GeantIncubatorDiploma_DIDWEB",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -2316,7 +2320,7 @@ unless it has `"oidfed": false`. We want only the URL-based credential to be par
},
"GeantIncubatorDiploma_URL": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_URL",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_URL",
"scope": "GeantIncubatorDiploma_URL",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -2596,7 +2600,7 @@ The files below show their state after this step, with changes marked:
"credential_configurations_supported": {
"GeantIncubatorDiploma_SDJWT": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_SDJWT",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_SDJWT",
"scope": "GeantIncubatorDiploma_SDJWT",
"_issuance_configuration": {
"oidfed": false
@@ -2700,7 +2704,7 @@ The files below show their state after this step, with changes marked:
},
"GeantIncubatorDiploma_DIDWEB": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_DIDWEB",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_DIDWEB",
"scope": "GeantIncubatorDiploma_DIDWEB",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -2729,7 +2733,7 @@ The files below show their state after this step, with changes marked:
},
"GeantIncubatorDiploma_URL": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_URL",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_URL",
"scope": "GeantIncubatorDiploma_URL",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -3249,10 +3253,10 @@ attestation required:
- "GeantIncubatorDiploma_SDJWT": {
+ "GeantIncubatorDiploma_HAIP": {
"format": "dc+sd-jwt",
-- "vct": "GeantIncubatorDiploma_SDJWT",
+- "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_SDJWT",
- "scope": "GeantIncubatorDiploma_SDJWT",
- "cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
-+ "vct": "GeantIncubatorDiploma_HAIP",
++ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_HAIP",
+ "scope": "GeantIncubatorDiploma_HAIP",
+ "cryptographic_binding_methods_supported": ["jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -3339,7 +3343,7 @@ change that.
"credential_configurations_supported": {
"GeantIncubatorDiploma_HAIP": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_HAIP",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_HAIP",
"scope": "GeantIncubatorDiploma_HAIP",
"cryptographic_binding_methods_supported": ["jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -3966,7 +3970,7 @@ Master of Science in Computer Science and another in Mathematics gets two creden
"credential_configurations_supported": {
"UniversityDegree": {
"format": "dc+sd-jwt",
- "vct": "UniversityDegree",
+ "vct": "https://issuer.example.org/vct/UniversityDegree",
"scope": "UniversityDegree",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -4114,7 +4118,7 @@ Foundation conformance suite, the mdoc with the EUDI Reference Wallet and the co
"credential_configurations_supported": {
"ComplexCredential_SDJWT": {
"format": "dc+sd-jwt",
- "vct": "ComplexCredential_SDJWT",
+ "vct": "https://issuer.example.org/vct/ComplexCredential_SDJWT",
"scope": "ComplexCredential_SDJWT",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -4404,6 +4408,17 @@ For a `vc+sd-jwt` credential the path starts with `credentialSubject`. An array
is one value, as in [Disclosures for Object Properties](https://datatracker.ietf.org/doc/draft-ietf-oauth-selective-disclosure-jwt/).
You give an array always as one value, the path has no `null` and no index.
+A claim with `"sd": "never"` is in the credential as it is, not selectively disclosable. Use it for members a
+verifier needs to process a `vc+sd-jwt` credential, such as a `type` inside `credentialSubject`:
+
+```json
+"_issuance_configuration": {
+ "sd": [
+ { "path": ["credentialSubject", "type"], "sd": "never" }
+ ]
+}
+```
+
#### mdoc values
<details>
@@ -4949,7 +4964,7 @@ The `_issuance_configuration` member of a credential configuration. It is not pu
| `issuer` | String | `openidvci.issuer` | `did:jwk`, `did:web`, `url` or the identifier itself. |
| `oidfed` | Boolean | `true` | Whether the credential carries the Entity Identifier, when *conf/openid-vci-oidfed.xml* is imported. |
| `claim_types` | Array | | `{"path": [...], "type": ...}` per claim of an mdoc. `full-date`, `tdate`, `bstr`, `int` or `bool`. The path is a Claims Path Pointer, `null` for every element of an array, see [Complex claims](#complex-claims). |
-| `sd` | Array | | `{"path": [..., null], "sd": "always"}` per array of a `dc+sd-jwt` or `vc+sd-jwt` credential that is disclosed as in [Disclosures for Array Elements](https://datatracker.ietf.org/doc/draft-ietf-oauth-selective-disclosure-jwt/) of SD-JWT. For `vc+sd-jwt` the path starts with `credentialSubject`. See [Complex claims](#complex-claims). |
+| `sd` | Array | | `{"path": [..., null], "sd": "always"}` per array of a `dc+sd-jwt` or `vc+sd-jwt` credential that is disclosed as in [Disclosures for Array Elements](https://datatracker.ietf.org/doc/draft-ietf-oauth-selective-disclosure-jwt/) of SD-JWT, and `{"path": [...], "sd": "never"}` per claim that is in the credential as it is, not selectively disclosable. For `vc+sd-jwt` the path starts with `credentialSubject`. See [Complex claims](#complex-claims). |
The following members of a `vc+sd-jwt` credential are defined by [W3C VCDM 2.0](https://www.w3.org/TR/vc-data-model-2.0/). You set them in
`credential_definition`. Their contents are entirely up to you; the plugin does not validate them. Only
@@ -4997,7 +5012,8 @@ The plugin installs this file but does not import it automatically. Import it in
A list replaces the OP’s credentials; it does not add to them. The first key that supports the
algorithm is used for signing. The other keys are published in the `did:web` document and the Entity Configuration.
They also sign the Status List Tokens of the `did:jwk` credentials they signed. Only EC keys are supported. A key with
-certificates includes `x5c` when the issuer is an HTTPS URL. See
+certificates includes `x5c` when the issuer is an HTTPS URL. The certificate then needs a subjectAltName URI equal to
+the issuer URL. See
[Step 7](#step-7-rolling-the-signing-key).
### Beans
@@ -5038,7 +5054,8 @@ Beans you can define or reference. Define your own beans in *conf/global.xml* or
| **openidvci.issuerMetadata.TemplateContext** | Map | `$issuer`, `$baseUrl`, `$host` | Velocity variables of the Credential Issuer metadata template. |
| **openidvci.jwtVcIssuer.TemplateContext** | Map | as above | The same for JWT VC issuer metadata. |
| **openidvci.authorizationServer.TemplateContext** | Map | as above | The same for authorization server metadata. |
-| **openidvci.credentials.MappedErrors** | Map | built in | Events of the credential endpoint mapped to error responses. |
+| **openidvci.credentials.MappedErrors** | Map | built in | Events of the credential endpoint mapped to error responses, in place of the built-in map. |
+| **openidvci.SdJwtVcReservedClaimNames** | List | `iss` `iat` `nbf` `exp` `cnf` `vct` `vct#integrity` `aka_vcts` `status` `fed` `_sd_alg` | Top-level claims of a `dc+sd-jwt` credential that are not taken from the credential content, in place of the built-in list. |
| **openidvci.token.MappedErrors** | Map | built in | Events of the token endpoint mapped to error responses, in place of the built-in map. |
### Properties
diff --git a/docs/example/step-1/metadata/verifiable-credentials.json b/docs/example/step-1/metadata/verifiable-credentials.json
index 7b52ad0..5fdeba4 100644
--- a/docs/example/step-1/metadata/verifiable-credentials.json
+++ b/docs/example/step-1/metadata/verifiable-credentials.json
@@ -2,7 +2,7 @@
"credential_configurations_supported": {
"GeantIncubatorDiploma_SDJWT": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_SDJWT",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_SDJWT",
"scope": "GeantIncubatorDiploma_SDJWT",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
diff --git a/docs/example/step-2/metadata/verifiable-credentials.json b/docs/example/step-2/metadata/verifiable-credentials.json
index a524103..5f7273d 100644
--- a/docs/example/step-2/metadata/verifiable-credentials.json
+++ b/docs/example/step-2/metadata/verifiable-credentials.json
@@ -2,7 +2,7 @@
"credential_configurations_supported": {
"GeantIncubatorDiploma_SDJWT": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_SDJWT",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_SDJWT",
"scope": "GeantIncubatorDiploma_SDJWT",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -31,7 +31,7 @@
},
"GeantIncubatorDiploma_DIDWEB": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_DIDWEB",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_DIDWEB",
"scope": "GeantIncubatorDiploma_DIDWEB",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
diff --git a/docs/example/step-3/metadata/verifiable-credentials.json b/docs/example/step-3/metadata/verifiable-credentials.json
index 725e933..b4d1a99 100644
--- a/docs/example/step-3/metadata/verifiable-credentials.json
+++ b/docs/example/step-3/metadata/verifiable-credentials.json
@@ -2,7 +2,7 @@
"credential_configurations_supported": {
"GeantIncubatorDiploma_SDJWT": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_SDJWT",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_SDJWT",
"scope": "GeantIncubatorDiploma_SDJWT",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -31,7 +31,7 @@
},
"GeantIncubatorDiploma_DIDWEB": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_DIDWEB",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_DIDWEB",
"scope": "GeantIncubatorDiploma_DIDWEB",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -59,7 +59,7 @@
},
"GeantIncubatorDiploma_URL": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_URL",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_URL",
"scope": "GeantIncubatorDiploma_URL",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
diff --git a/docs/example/step-4/metadata/verifiable-credentials.json b/docs/example/step-4/metadata/verifiable-credentials.json
index 6591401..1f2212d 100644
--- a/docs/example/step-4/metadata/verifiable-credentials.json
+++ b/docs/example/step-4/metadata/verifiable-credentials.json
@@ -2,7 +2,7 @@
"credential_configurations_supported": {
"GeantIncubatorDiploma_SDJWT": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_SDJWT",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_SDJWT",
"scope": "GeantIncubatorDiploma_SDJWT",
"_issuance_configuration": {
"oidfed": false
@@ -34,7 +34,7 @@
},
"GeantIncubatorDiploma_DIDWEB": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_DIDWEB",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_DIDWEB",
"scope": "GeantIncubatorDiploma_DIDWEB",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -63,7 +63,7 @@
},
"GeantIncubatorDiploma_URL": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_URL",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_URL",
"scope": "GeantIncubatorDiploma_URL",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
diff --git a/docs/example/step-5/metadata/verifiable-credentials.json b/docs/example/step-5/metadata/verifiable-credentials.json
index 16482e0..86cc8b8 100644
--- a/docs/example/step-5/metadata/verifiable-credentials.json
+++ b/docs/example/step-5/metadata/verifiable-credentials.json
@@ -2,7 +2,7 @@
"credential_configurations_supported": {
"GeantIncubatorDiploma_SDJWT": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_SDJWT",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_SDJWT",
"scope": "GeantIncubatorDiploma_SDJWT",
"_issuance_configuration": {
"oidfed": false
@@ -106,7 +106,7 @@
},
"GeantIncubatorDiploma_DIDWEB": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_DIDWEB",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_DIDWEB",
"scope": "GeantIncubatorDiploma_DIDWEB",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
@@ -135,7 +135,7 @@
},
"GeantIncubatorDiploma_URL": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_URL",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_URL",
"scope": "GeantIncubatorDiploma_URL",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
diff --git a/docs/example/step-6/metadata/verifiable-credentials.json b/docs/example/step-6/metadata/verifiable-credentials.json
index aa2ceb5..9b7af47 100644
--- a/docs/example/step-6/metadata/verifiable-credentials.json
+++ b/docs/example/step-6/metadata/verifiable-credentials.json
@@ -2,7 +2,7 @@
"credential_configurations_supported": {
"GeantIncubatorDiploma_HAIP": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_HAIP",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_HAIP",
"scope": "GeantIncubatorDiploma_HAIP",
"cryptographic_binding_methods_supported": ["jwk"],
"credential_signing_alg_values_supported": ["ES256"],
diff --git a/openid-vci-api/src/main/java/org/geant/shibboleth/plugin/openidvci/credential/ClaimDisclosure.java b/openid-vci-api/src/main/java/org/geant/shibboleth/plugin/openidvci/credential/ClaimDisclosure.java
index 4c835fa..46df92d 100644
--- a/openid-vci-api/src/main/java/org/geant/shibboleth/plugin/openidvci/credential/ClaimDisclosure.java
+++ b/openid-vci-api/src/main/java/org/geant/shibboleth/plugin/openidvci/credential/ClaimDisclosure.java
@@ -38,17 +38,21 @@ public final class ClaimDisclosure {
@Nonnull
public static final String ALWAYS = "always";
- /** Supported values. */
+ /** The claim is never selectively disclosable. */
@Nonnull
- private static final Set<String> VALUES = Set.of(ALWAYS);
+ public static final String NEVER = "never";
- /** Path of the claim, a claims path pointer. */
+ /** Selective disclosures supported. */
+ @Nonnull
+ private static final Set<String> VALUES = Set.of(ALWAYS, NEVER);
+
+ /** Path of the claim. */
@Nonnull
private final List<Object> path;
- /** Names of the array whose elements the path selects. */
+ /** Names on the path, without the closing null of an array. */
@Nonnull
- private final List<String> arrayPath;
+ private final List<String> names;
/** Selective disclosure of the claim. */
@Nonnull
@@ -57,30 +61,35 @@ public final class ClaimDisclosure {
/**
* Constructor.
*
- * @param claimPath path of the claim, a claims path pointer
+ * @param claimPath path of the claim, ending in null for the elements of an array with 'always'
* @param disclosure selective disclosure of the claim
*/
@JsonCreator
private ClaimDisclosure(@JsonProperty("path") final List<Object> claimPath,
@JsonProperty("sd") final String disclosure) {
- if (claimPath == null || claimPath.size() < 2 || claimPath.get(claimPath.size() - 1) != null) {
- throw new IllegalArgumentException("sd entry " + claimPath
- + " is not a path of names ending in null, the elements of an array");
- }
if (disclosure == null || !VALUES.contains(disclosure)) {
throw new IllegalArgumentException("sd entry " + claimPath + " has sd '" + disclosure
+ "', not one of " + VALUES);
}
- final List<String> names = new ArrayList<>(claimPath.size() - 1);
- for (final Object element : claimPath.subList(0, claimPath.size() - 1)) {
+ final boolean always = ALWAYS.equals(disclosure);
+ if (always && (claimPath == null || claimPath.size() < 2 || claimPath.get(claimPath.size() - 1) != null)) {
+ throw new IllegalArgumentException("sd entry " + claimPath
+ + " is not a path of names ending in null, the elements of an array");
+ }
+ if (!always && (claimPath == null || claimPath.isEmpty())) {
+ throw new IllegalArgumentException("sd entry " + claimPath + " is not a path of names");
+ }
+ final List<Object> named = always ? claimPath.subList(0, claimPath.size() - 1) : claimPath;
+ final List<String> collected = new ArrayList<>(named.size());
+ for (final Object element : named) {
if (!(element instanceof String)) {
throw new IllegalArgumentException("sd entry " + claimPath + " has path element '" + element
+ "', not a name");
}
- names.add((String) element);
+ collected.add((String) element);
}
path = Collections.unmodifiableList(new ArrayList<>(claimPath));
- arrayPath = List.copyOf(names);
+ names = List.copyOf(collected);
sd = disclosure;
}
@@ -95,13 +104,13 @@ public final class ClaimDisclosure {
}
/**
- * Get the names of the array whose elements the path selects.
+ * Get the names on the path, without the closing null of an array.
*
- * @return names of the array
+ * @return names on the path
*/
@Nonnull
- public List<String> getArrayPath() {
- return arrayPath;
+ public List<String> getNames() {
+ return names;
}
/**
diff --git a/openid-vci-api/src/main/java/org/geant/shibboleth/plugin/openidvci/credential/CredentialConfiguration.java b/openid-vci-api/src/main/java/org/geant/shibboleth/plugin/openidvci/credential/CredentialConfiguration.java
index b267044..f9dcb03 100644
--- a/openid-vci-api/src/main/java/org/geant/shibboleth/plugin/openidvci/credential/CredentialConfiguration.java
+++ b/openid-vci-api/src/main/java/org/geant/shibboleth/plugin/openidvci/credential/CredentialConfiguration.java
@@ -296,8 +296,8 @@ public final class CredentialConfiguration {
private void validateClaimDisclosures(@Nonnull final List<ClaimDisclosure> disclosures) {
for (final ClaimDisclosure disclosure : disclosures) {
if ("vc+sd-jwt".equals(format)) {
- if (disclosure.getArrayPath().size() < 2
- || !"credentialSubject".equals(disclosure.getArrayPath().get(0))) {
+ if (disclosure.getNames().size() < 2
+ || !"credentialSubject".equals(disclosure.getNames().get(0))) {
throw new IllegalArgumentException("sd path " + disclosure.getPath()
+ " of a vc+sd-jwt does not start with credentialSubject and a claim");
}
diff --git a/openid-vci-api/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/OpenIDVCIEventIds.java b/openid-vci-api/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/OpenIDVCIEventIds.java
index fe3946d..da74f29 100644
--- a/openid-vci-api/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/OpenIDVCIEventIds.java
+++ b/openid-vci-api/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/OpenIDVCIEventIds.java
@@ -64,6 +64,16 @@ public final class OpenIDVCIEventIds {
@NotEmpty
public static final String NO_CREDENTIALS_FOR_REQUEST = "NoCredentialsForRequest";
+ /** ID of event returned if the access token does not grant the requested credential configuration. */
+ @Nonnull
+ @NotEmpty
+ public static final String CREDENTIAL_NOT_GRANTED = "CredentialNotGranted";
+
+ /** ID of event returned if the DPoP access token does not grant the requested credential configuration. */
+ @Nonnull
+ @NotEmpty
+ public static final String CREDENTIAL_NOT_GRANTED_DPOP = "CredentialNotGrantedDPoP";
+
/**
* ID of event returned if the credential identifier of the request was not issued.
*/
diff --git a/openid-vci-api/src/test/java/org/geant/shibboleth/plugin/openidvci/credential/CredentialIssuanceConfigurationTest.java b/openid-vci-api/src/test/java/org/geant/shibboleth/plugin/openidvci/credential/CredentialIssuanceConfigurationTest.java
index 0402387..dff9339 100644
--- a/openid-vci-api/src/test/java/org/geant/shibboleth/plugin/openidvci/credential/CredentialIssuanceConfigurationTest.java
+++ b/openid-vci-api/src/test/java/org/geant/shibboleth/plugin/openidvci/credential/CredentialIssuanceConfigurationTest.java
@@ -150,9 +150,9 @@ public class CredentialIssuanceConfigurationTest {
Assert.assertEquals(settings.getClaimDisclosures().size(), 2);
Assert.assertEquals(settings.getClaimDisclosures().get(0).getPath(), Arrays.asList("ga4gh_visas", null));
- Assert.assertEquals(settings.getClaimDisclosures().get(0).getArrayPath(), List.of("ga4gh_visas"));
+ Assert.assertEquals(settings.getClaimDisclosures().get(0).getNames(), List.of("ga4gh_visas"));
Assert.assertEquals(settings.getClaimDisclosures().get(0).getSd(), ClaimDisclosure.ALWAYS);
- Assert.assertEquals(settings.getClaimDisclosures().get(1).getArrayPath(), List.of("passport", "visas"));
+ Assert.assertEquals(settings.getClaimDisclosures().get(1).getNames(), List.of("passport", "visas"));
}
@Test
@@ -164,6 +164,21 @@ public class CredentialIssuanceConfigurationTest {
Assert.assertTrue(settings.getClaimDisclosures().isEmpty());
}
+ @Test
+ public void neverDisclosedClaim() throws JsonProcessingException {
+
+ final CredentialIssuanceConfiguration settings = CredentialConfiguration
+ .parse(withSettings("{\"sd\":[{\"path\":[\"address\",\"country\"],\"sd\":\"never\"}]}"))
+ .getIssuanceConfiguration();
+
+ Assert.assertEquals(settings.getClaimDisclosures().get(0).getSd(), ClaimDisclosure.NEVER);
+ Assert.assertEquals(settings.getClaimDisclosures().get(0).getNames(), List.of("address", "country"));
+ Assert.assertThrows(() -> CredentialConfiguration
+ .parse(withSettings("{\"sd\":[{\"path\":[],\"sd\":\"never\"}]}")));
+ Assert.assertThrows(() -> CredentialConfiguration
+ .parse(withSettings("{\"sd\":[{\"path\":[\"address\",0],\"sd\":\"never\"}]}")));
+ }
+
@Test
public void unsupportedClaimDisclosuresAreRefused() {
@@ -190,7 +205,7 @@ public class CredentialIssuanceConfigurationTest {
+ ",\"_issuance_configuration\":{\"sd\":[{\"path\":[\"credentialSubject\",\"visas\",null],"
+ "\"sd\":\"always\"}]}}").getIssuanceConfiguration();
- Assert.assertEquals(settings.getClaimDisclosures().get(0).getArrayPath(),
+ Assert.assertEquals(settings.getClaimDisclosures().get(0).getNames(),
List.of("credentialSubject", "visas"));
Assert.assertThrows(() -> CredentialConfiguration.parse(vcSdJwt
+ ",\"_issuance_configuration\":{\"sd\":[{\"path\":[\"visas\",null],\"sd\":\"always\"}]}}"));
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/credential/impl/SelectiveDisclosureClaimTree.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/credential/impl/SelectiveDisclosureClaimTree.java
index d6b7b21..746cad9 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/credential/impl/SelectiveDisclosureClaimTree.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/credential/impl/SelectiveDisclosureClaimTree.java
@@ -100,9 +100,41 @@ public class SelectiveDisclosureClaimTree {
*/
public SelectiveDisclosureClaimTree(@Nonnull final Collection<CredentialOfferRequestedClaim> requested,
@Nonnull final Collection<List<String>> disclosedArrays, @Nonnull final String algorithm) {
+ this(requested, disclosedArrays, List.of(), algorithm);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param requested claims to disclose
+ * @param disclosedArrays paths of the arrays whose elements are disclosed one by one
+ * @param plainClaims paths of the claims that are not selectively disclosable
+ *
+ * @throws IllegalArgumentException if the claims cannot form a tree
+ */
+ public SelectiveDisclosureClaimTree(@Nonnull final Collection<CredentialOfferRequestedClaim> requested,
+ @Nonnull final Collection<List<String>> disclosedArrays,
+ @Nonnull final Collection<List<String>> plainClaims) {
+ this(requested, disclosedArrays, plainClaims, "sha-256");
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param requested claims to disclose
+ * @param disclosedArrays paths of the arrays whose elements are disclosed one by one
+ * @param plainClaims paths of the claims that are not selectively disclosable
+ * @param algorithm digest algorithm of disclosures
+ *
+ * @throws IllegalArgumentException if the claims cannot form a tree
+ */
+ public SelectiveDisclosureClaimTree(@Nonnull final Collection<CredentialOfferRequestedClaim> requested,
+ @Nonnull final Collection<List<String>> disclosedArrays,
+ @Nonnull final Collection<List<String>> plainClaims, @Nonnull final String algorithm) {
this.algorithm = algorithm;
validate(requested);
+ claims = new LinkedHashMap<>();
// Claims of same parent are disclosed together.
final Map<List<String>, Map<String, Object>> levels = new LinkedHashMap<>();
@@ -111,6 +143,14 @@ public class SelectiveDisclosureClaimTree {
final List<String> path = claim.getPath();
final List<String> parent = List.copyOf(path.subList(0, path.size() - 1));
Object value = claim.getValue();
+ if (plainClaims.contains(path)) {
+ if (disclosedArrays.contains(path)) {
+ throw new IllegalArgumentException("Claim " + String.join("/", path)
+ + " is both not selectively disclosable and disclosed element by element");
+ }
+ resolve(parent).put(path.get(path.size() - 1), value);
+ continue;
+ }
if (disclosedArrays.contains(path)) {
if (!(value instanceof List)) {
throw new IllegalArgumentException("Claim " + String.join("/", path)
@@ -124,7 +164,6 @@ public class SelectiveDisclosureClaimTree {
levels.computeIfAbsent(parent, k -> new LinkedHashMap<>()).put(path.get(path.size() - 1), value);
}
- claims = new LinkedHashMap<>();
for (final Map.Entry<List<String>, Map<String, Object>> level : levels.entrySet()) {
final SelectiveDisclosureClaimSetUtil disclosed = new SelectiveDisclosureClaimSetUtil(level.getValue(),
algorithm);
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCICredentialsRequestDecoder.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCICredentialsRequestDecoder.java
index f06890e..544717b 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCICredentialsRequestDecoder.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCICredentialsRequestDecoder.java
@@ -65,7 +65,7 @@ public class OpenIDVCICredentialsRequestDecoder extends BaseOAuth2RequestDecoder
return message == null ? null
: MoreObjects.toStringHelper(this).omitNullValues()
- .add("credential_identifier", message.getCredentialConfigurationId())
+ .add("credential_identifier", message.getCredentialIdentifier())
.add("credential_configuration_id", message.getCredentialConfigurationId())
.add("proofs", message.getProofs())
.add("credential_response_encryption", message.getCredentialResponseEncryption()).toString();
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/messaging/impl/OpenIDVCICredentialsRequest.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/messaging/impl/OpenIDVCICredentialsRequest.java
index 72be61d..60f9640 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/messaging/impl/OpenIDVCICredentialsRequest.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/messaging/impl/OpenIDVCICredentialsRequest.java
@@ -34,7 +34,6 @@ import com.nimbusds.oauth2.sdk.http.HTTPRequest;
import com.nimbusds.oauth2.sdk.token.AccessToken;
import com.nimbusds.oauth2.sdk.token.AccessTokenType;
import com.nimbusds.oauth2.sdk.token.BearerAccessToken;
-import com.nimbusds.oauth2.sdk.token.BearerTokenError;
import com.nimbusds.oauth2.sdk.token.DPoPAccessToken;
/**
@@ -77,14 +76,10 @@ public class OpenIDVCICredentialsRequest extends ProtectedResourceRequest {
* request is intended, {@code null} if not specified (if,
* for example, the {@link #toHTTPRequest()} method will not
* be used).
- * @param accessToken OAuth2 access token.
+ * @param accessToken OAuth2 access token, {@code null} if the request has none.
*/
- protected OpenIDVCICredentialsRequest(@Nullable final URI uri, @Nonnull final AccessToken accessToken) {
+ protected OpenIDVCICredentialsRequest(@Nullable final URI uri, @Nullable final AccessToken accessToken) {
super(uri, accessToken);
-
- if (accessToken == null) {
- throw new IllegalArgumentException("The access token must not be null");
- }
}
/**
@@ -178,25 +173,27 @@ public class OpenIDVCICredentialsRequest extends ProtectedResourceRequest {
* @return parsed request.
* @throws ParseException if parsing failed.
*/
- @SuppressWarnings("unchecked")
public static OpenIDVCICredentialsRequest parse(final HTTPRequest httpRequest) throws ParseException {
httpRequest.ensureMethod(HTTPRequest.Method.POST);
httpRequest.ensureEntityContentType(ContentType.APPLICATION_JSON);
- final String authorization = httpRequest.getAuthorization();
- if (authorization == null) {
- throw new ParseException("Missing access token in Authorization header", BearerTokenError.MISSING_TOKEN);
+ final AccessToken accessToken = parseAccessToken(httpRequest.getAuthorization());
+ final String body = httpRequest.getBody();
+ if (body == null || body.isBlank()) {
+ throw new ParseException("Request body is missing",
+ OAuth2Error.INVALID_REQUEST.appendDescription(": request body is missing"));
}
- final AccessToken accessToken = authorization.regionMatches(true, 0, AccessTokenType.DPOP.getValue(), 0,
- AccessTokenType.DPOP.getValue().length()) ? DPoPAccessToken.parse(authorization)
- : BearerAccessToken.parse(authorization);
final Map<String, Object> payload;
try {
- payload = new ObjectMapper().readValue(httpRequest.getBody(), new TypeReference<Map<String, Object>>() {
+ payload = new ObjectMapper().readValue(body, new TypeReference<Map<String, Object>>() {
});
} catch (final JsonProcessingException e1) {
throw new ParseException(e1.getMessage(),
OAuth2Error.INVALID_REQUEST.appendDescription(": request body is not a JSON object"));
}
+ if (payload == null) {
+ throw new ParseException("Request body is not a JSON object",
+ OAuth2Error.INVALID_REQUEST.appendDescription(": request body is not a JSON object"));
+ }
final URI uri;
try {
uri = httpRequest.getURL().toURI();
@@ -208,9 +205,52 @@ public class OpenIDVCICredentialsRequest extends ProtectedResourceRequest {
(payload.get(CREDENTIAL_IDENTIFIER_KEY) instanceof String value) ? value : null);
request.setCredentialConfigurationId(
(payload.get(CREDENTIAL_CONFIGURATION_ID_KEY) instanceof String value) ? value : null);
- request.setProofs((Map<String, Object>) payload.get(PROOFS_KEY));
- request.setCredentialResponseEncryption((Map<String, Object>) payload.get(CREDENTIAL_RESPONSE_ENCRYPTION_KEY));
+ request.setProofs(objectMember(payload, PROOFS_KEY));
+ request.setCredentialResponseEncryption(objectMember(payload, CREDENTIAL_RESPONSE_ENCRYPTION_KEY));
return request;
}
+ /**
+ * Parse the access token of an Authorization header.
+ *
+ * @param authorization Authorization header value
+ * @return access token, or {@code null} if the header has no Bearer or DPoP access token
+ */
+ @Nullable
+ private static AccessToken parseAccessToken(@Nullable final String authorization) {
+ if (authorization == null) {
+ return null;
+ }
+ try {
+ return authorization.regionMatches(true, 0, AccessTokenType.DPOP.getValue(), 0,
+ AccessTokenType.DPOP.getValue().length()) ? DPoPAccessToken.parse(authorization)
+ : BearerAccessToken.parse(authorization);
+ } catch (final ParseException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Get a member of the request that must be a JSON object.
+ *
+ * @param payload request
+ * @param key member name
+ * @return member, or {@code null} if the request does not have it
+ * @throws ParseException if the member is not a JSON object
+ */
+ @SuppressWarnings("unchecked")
+ @Nullable
+ private static Map<String, Object> objectMember(@Nonnull final Map<String, Object> payload,
+ @Nonnull final String key) throws ParseException {
+ final Object value = payload.get(key);
+ if (value == null) {
+ return null;
+ }
+ if (!(value instanceof Map)) {
+ throw new ParseException(key + " is not a JSON object",
+ OAuth2Error.INVALID_REQUEST.appendDescription(": " + key + " is not a JSON object"));
+ }
+ return (Map<String, Object>) value;
+ }
+
}
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/config/impl/DefaultOpenIDVCICredentialsConfiguration.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/config/impl/DefaultOpenIDVCICredentialsConfiguration.java
index c13bc99..88575da 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/config/impl/DefaultOpenIDVCICredentialsConfiguration.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/config/impl/DefaultOpenIDVCICredentialsConfiguration.java
@@ -26,6 +26,7 @@ import org.opensaml.profile.context.ProfileRequestContext;
import net.shibboleth.oidc.jwt.claims.ClaimsValidator;
import net.shibboleth.oidc.profile.oauth2.config.OAuth2TokenValidatingProfileConfiguration;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.logic.FunctionSupport;
@@ -33,6 +34,10 @@ import net.shibboleth.shared.logic.FunctionSupport;
public class DefaultOpenIDVCICredentialsConfiguration extends AbstractOpenIDVCIConfiguration
implements OAuth2TokenValidatingProfileConfiguration {
+ /** Credentials profile counter name. */
+ @Nonnull @NotEmpty public static final String PROFILE_COUNTER =
+ "net.shibboleth.idp.profiles.openid.vci.credentials";
+
/** Validation of JWT claims for issued tokens. */
@Nonnull
private Function<ProfileRequestContext, ClaimsValidator> issuedClaimsValidatorLookupStrategy;
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AddCredentialShell.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AddCredentialShell.java
index c427552..25a6b05 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AddCredentialShell.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AddCredentialShell.java
@@ -48,6 +48,7 @@ import org.geant.shibboleth.plugin.openidvci.security.impl.DidSupport;
import org.geant.shibboleth.plugin.openidvci.messaging.context.CredentialsContext;
import org.opensaml.messaging.context.navigate.ChildContextLookup;
import org.opensaml.profile.action.ActionSupport;
+import org.opensaml.profile.action.EventIds;
import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
@@ -225,7 +226,7 @@ public class AddCredentialShell extends AbstractProfileAction {
rpCtx = relyingPartyContextLookupStrategy.apply(profileRequestContext);
if (rpCtx == null) {
- log.debug("{} No relying party context associated with this profile request", getLogPrefix());
+ log.error("{} No relying party context associated with this profile request", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, IdPEventIds.INVALID_RELYING_PARTY_CTX);
return false;
}
@@ -239,9 +240,8 @@ public class AddCredentialShell extends AbstractProfileAction {
ctx = profileRequestContext.getInboundMessageContext() == null ? null
: profileRequestContext.getInboundMessageContext().getSubcontext(CredentialsContext.class);
if (ctx == null) {
- // TODO: A missing credentials context is not a relying party problem.
- log.debug("{} No credentials context associated with this profile request", getLogPrefix());
- ActionSupport.buildEvent(profileRequestContext, IdPEventIds.INVALID_RELYING_PARTY_CTX);
+ log.error("{} No credentials context associated with this profile request", getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_PROFILE_CTX);
return false;
}
@@ -265,7 +265,7 @@ public class AddCredentialShell extends AbstractProfileAction {
issuerId = issuerLookupStrategy.apply(profileRequestContext);
if (issuerId == null) {
- log.error("{} Unable to determine issuer to check audience", getLogPrefix());
+ log.error("{} Unable to determine the credential issuer", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, IdPEventIds.INVALID_PROFILE_CONFIG);
return false;
}
@@ -297,13 +297,13 @@ public class AddCredentialShell extends AbstractProfileAction {
try {
final Map<String, Object> cnf = buildCnf(proofs.get(ordinal));
if (cnf == null) {
- log.error("{} Proof carries no holder key this issuer binds to", getLogPrefix());
+ log.warn("{} Proof carries no holder key this issuer binds to", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
return;
}
shell.setClaim("cnf", cnf);
} catch (final Exception e) {
- log.error("{} Failed to build cnf", getLogPrefix(), e);
+ log.warn("{} Failed to build cnf: {}", getLogPrefix(), e.getMessage());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
return;
}
@@ -405,11 +405,11 @@ public class AddCredentialShell extends AbstractProfileAction {
shell.setIssuer(new Issuer(issuerId));
shell.setClaim("iat", issuedAt.getEpochSecond());
- if (!notBefore.equals(issuedAt)) {
- shell.setClaim("nbf", notBefore.getEpochSecond());
- }
shell.setClaim("exp", expiresAt.getEpochSecond());
if ("dc+sd-jwt".equals(ctx.getCredentialConfiguration().getFormat())) {
+ if (!notBefore.equals(issuedAt)) {
+ shell.setClaim("nbf", notBefore.getEpochSecond());
+ }
shell.setClaim("vct", ctx.getCredentialConfiguration().getVct());
if (inOIDFederation()) {
shell.setClaim("fed", entityIdentifier);
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AddMobileSecurityObjectShell.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AddMobileSecurityObjectShell.java
index 9bd2909..cd305b3 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AddMobileSecurityObjectShell.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AddMobileSecurityObjectShell.java
@@ -111,7 +111,7 @@ public class AddMobileSecurityObjectShell extends AbstractProfileAction {
}
if ((ctx.getProofs() == null || ctx.getProofs().isEmpty())
&& (ctx.getAttestedKeys() == null || ctx.getAttestedKeys().isEmpty())) {
- log.error("{} An mdoc is bound to a device key, the request carries no proof", getLogPrefix());
+ log.warn("{} An mdoc is bound to a device key, the request carries no proof", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
return false;
}
@@ -133,14 +133,14 @@ public class AddMobileSecurityObjectShell extends AbstractProfileAction {
try {
deviceKey = attested ? ecPublicKey(attestedKeys.get(ordinal)) : deviceKey(proofs.get(ordinal));
if (deviceKey == null) {
- log.error("{} Proof carries no EC holder key this issuer binds to", getLogPrefix());
+ log.warn("{} Proof carries no EC holder key this issuer binds to", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
return;
}
mso = new MobileSecurityObject(docType, CoseKeySupport.toCoseKey(deviceKey), ctx.getIssuedAt(),
ctx.getNotBefore(), ctx.getExpiresAt());
} catch (final ParseException | JOSEException | EncodingException e) {
- log.error("{} Failed to read the holder key", getLogPrefix(), e);
+ log.warn("{} Failed to read the holder key: {}", getLogPrefix(), e.getMessage());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
return;
}
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/BuildCredentialErrorResponseFromEvent.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/BuildCredentialErrorResponseFromEvent.java
index 5e0a248..7db08db 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/BuildCredentialErrorResponseFromEvent.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/BuildCredentialErrorResponseFromEvent.java
@@ -130,7 +130,7 @@ public class BuildCredentialErrorResponseFromEvent
final SecurityParametersContext securityParameters =
securityParametersContextLookupStrategy.apply(profileRequestContext);
final SignatureValidationParameters validationParameters =
- securityParameters.getSignatureValidationParameters();
+ securityParameters != null ? securityParameters.getSignatureValidationParameters() : null;
final List<JWSAlgorithm> algorithms = new ArrayList<>();
if (validationParameters != null) {
for (final JWSAlgorithm candidate : algorithmCandidates) {
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormJsonLdSelectiveDisclosureJWTCredential.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormJsonLdSelectiveDisclosureJWTCredential.java
index dee21b4..cd67b99 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormJsonLdSelectiveDisclosureJWTCredential.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormJsonLdSelectiveDisclosureJWTCredential.java
@@ -19,14 +19,13 @@ package org.geant.shibboleth.plugin.openidvci.profile.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.geant.shibboleth.plugin.openidvci.credential.ClaimDisclosure;
import org.geant.shibboleth.plugin.openidvci.credential.CredentialDefinition;
import org.geant.shibboleth.plugin.openidvci.credential.CredentialIssuanceConfiguration;
-import org.geant.shibboleth.plugin.openidvci.profile.logic.CredentialIssuerLookupFunction;
import org.geant.shibboleth.plugin.openidvci.messaging.context.CredentialsContext;
import org.geant.shibboleth.plugin.openidvci.messaging.impl.CredentialOfferRequestedCredential;
import org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds;
@@ -39,7 +38,6 @@ import org.slf4j.LoggerFactory;
import net.shibboleth.idp.profile.AbstractProfileAction;
import net.shibboleth.shared.annotation.constraint.NonnullBeforeExec;
-import net.shibboleth.shared.logic.Constraint;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.oauth2.sdk.ParseException;
@@ -76,27 +74,6 @@ public class FormJsonLdSelectiveDisclosureJWTCredential extends AbstractProfileA
@NonnullBeforeExec
private CredentialOfferRequestedCredential credential;
- /** Strategy used to obtain the response issuer value. */
- @Nonnull
- private Function<ProfileRequestContext, String> issuerLookupStrategy;
-
- /**
- * Constructor.
- */
- public FormJsonLdSelectiveDisclosureJWTCredential() {
- issuerLookupStrategy = new CredentialIssuerLookupFunction();
- }
-
- /**
- * Set the strategy used to locate the issuer value to use.
- *
- * @param strategy lookup strategy
- */
- public void setIssuerLookupStrategy(@Nonnull final Function<ProfileRequestContext, String> strategy) {
- checkSetterPreconditions();
- issuerLookupStrategy = Constraint.isNotNull(strategy, "IssuerLookupStrategy lookup strategy cannot be null");
- }
-
/** {@inheritDoc} */
@Override
protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
@@ -117,11 +94,13 @@ public class FormJsonLdSelectiveDisclosureJWTCredential extends AbstractProfileA
}
credential = ctx.getCredentialContent();
if (credential == null) {
- log.warn("{} No credential content in context, nothing to do", getLogPrefix());
+ log.error("{} No credential content in context", getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_CREDENTIAL);
return false;
}
if (ctx.getCredentialShells() == null || ctx.getCredentialShells().isEmpty()) {
- log.warn("{} No shells stored to context, nothing to do", getLogPrefix());
+ log.error("{} No credential shells in context", getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_CREDENTIAL);
return false;
}
@@ -134,18 +113,16 @@ public class FormJsonLdSelectiveDisclosureJWTCredential extends AbstractProfileA
final CredentialIssuanceConfiguration settings = ctx.getCredentialConfiguration().getIssuanceConfiguration();
// The paths name 'credentialSubject' first, the claims are inside it.
- final List<List<String>> disclosedArrays = settings == null ? List.of()
- : settings.getClaimDisclosures().stream()
- .map(disclosure -> disclosure.getArrayPath().subList(1, disclosure.getArrayPath().size()))
- .toList();
+ final List<List<String>> disclosedArrays = paths(settings, ClaimDisclosure.ALWAYS);
+ final List<List<String>> plainClaims = paths(settings, ClaimDisclosure.NEVER);
final List<JWTClaimsSet> credentials = new ArrayList<>();
final List<String> disclosures = new ArrayList<>();
- final String issuer = issuerLookupStrategy.apply(profileRequestContext);
for (final ClaimsSet cred : ctx.getCredentialShells()) {
// A tree per credential, so that salts, digests and disclosures are not shared within a batch.
final SelectiveDisclosureClaimTree tree;
try {
- tree = new SelectiveDisclosureClaimTree(credential.getRequestedCredential(), disclosedArrays);
+ tree = new SelectiveDisclosureClaimTree(credential.getRequestedCredential(), disclosedArrays,
+ plainClaims);
} catch (final IllegalArgumentException e) {
log.error("{} Unable to disclose the requested claims", getLogPrefix(), e);
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_CREDENTIAL);
@@ -160,6 +137,7 @@ public class FormJsonLdSelectiveDisclosureJWTCredential extends AbstractProfileA
.claim("type", definition.getType());
definition.getCredentialMembers()
.forEach((name, value) -> builder.claim(name, combine(cred.getClaim(name), value)));
+ final String issuer = cred.getIssuer() != null ? cred.getIssuer().getValue() : null;
credentials.add(builder.claim("issuer", issuer).claim("credentialSubject", tree.getClaims())
.claim("_sd_alg", tree.getAlgorithm()).build());
disclosures.add(tree.getFormattedDisclosures());
@@ -204,4 +182,19 @@ public class FormJsonLdSelectiveDisclosureJWTCredential extends AbstractProfileA
list.add(value);
}
}
-}
\ No newline at end of file
+
+ /**
+ * Get the paths of the claims with a selective disclosure, inside 'credentialSubject'.
+ *
+ * @param settings issuance configuration, or null
+ * @param sd selective disclosure
+ * @return paths of the claims
+ */
+ @Nonnull
+ private static List<List<String>> paths(@Nullable final CredentialIssuanceConfiguration settings,
+ @Nonnull final String sd) {
+ return settings == null ? List.of()
+ : settings.getClaimDisclosures().stream().filter(disclosure -> sd.equals(disclosure.getSd()))
+ .map(disclosure -> disclosure.getNames().subList(1, disclosure.getNames().size())).toList();
+ }
+}
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormOutboundCredentialsResponseMessage.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormOutboundCredentialsResponseMessage.java
index fb827ea..632f0cb 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormOutboundCredentialsResponseMessage.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormOutboundCredentialsResponseMessage.java
@@ -33,7 +33,6 @@ import org.slf4j.LoggerFactory;
import net.shibboleth.idp.plugin.oidc.op.profile.impl.AbstractOIDCResponseAction;
import net.shibboleth.shared.annotation.constraint.NonnullBeforeExec;
-import com.fasterxml.jackson.core.JsonProcessingException;
/**
* Action forming {@link CredentialSuccessResponse}.
@@ -75,22 +74,16 @@ public class FormOutboundCredentialsResponseMessage extends AbstractOIDCResponse
ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MSG_CTX);
return;
}
- try {
- final List<String> signed = ctx.getSignedCredentials();
- final List<String> disclosures = ctx.getDisclosures();
- final List<String> credentials = new ArrayList<>();
- for (int ordinal = 0; ordinal < signed.size(); ordinal++) {
- final String disclosed = disclosures != null && ordinal < disclosures.size()
- ? disclosures.get(ordinal)
- : null;
- credentials.add(signed.get(ordinal) + (disclosed != null ? "~" + disclosed + "~" : ""));
- }
- final CredentialSuccessResponse response = new CredentialSuccessResponse(credentials);
- log.info("Setting response as {}", response.toJSONString());
- profileRequestContext.ensureOutboundMessageContext().setMessage(response);
- } catch (final JsonProcessingException e) {
- log.error("{} Error occurred while parsing objects {}", getLogPrefix(), e);
- ActionSupport.buildEvent(profileRequestContext, EventIds.IO_ERROR);
+ final List<String> signed = ctx.getSignedCredentials();
+ final List<String> disclosures = ctx.getDisclosures();
+ final List<String> credentials = new ArrayList<>();
+ for (int ordinal = 0; ordinal < signed.size(); ordinal++) {
+ final String disclosed = disclosures != null && ordinal < disclosures.size()
+ ? disclosures.get(ordinal)
+ : null;
+ credentials.add(signed.get(ordinal) + (disclosed != null ? "~" + disclosed + "~" : ""));
}
+ log.debug("{} Credential response with {} credentials", getLogPrefix(), credentials.size());
+ profileRequestContext.ensureOutboundMessageContext().setMessage(new CredentialSuccessResponse(credentials));
}
}
\ No newline at end of file
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormSelectiveDisclosureJWTCredential.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormSelectiveDisclosureJWTCredential.java
index 6006526..e7cb5e3 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormSelectiveDisclosureJWTCredential.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormSelectiveDisclosureJWTCredential.java
@@ -20,10 +20,12 @@ import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.geant.shibboleth.plugin.openidvci.credential.ClaimDisclosure;
import org.geant.shibboleth.plugin.openidvci.credential.CredentialIssuanceConfiguration;
import org.geant.shibboleth.plugin.openidvci.messaging.context.CredentialsContext;
+import org.geant.shibboleth.plugin.openidvci.messaging.impl.CredentialOfferRequestedClaim;
import org.geant.shibboleth.plugin.openidvci.messaging.impl.CredentialOfferRequestedCredential;
import org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds;
import org.geant.shibboleth.plugin.openidvci.credential.impl.SelectiveDisclosureClaimTree;
@@ -41,8 +43,7 @@ import com.nimbusds.oauth2.sdk.ParseException;
import com.nimbusds.openid.connect.sdk.claims.ClaimsSet;
/**
- * Action that forms
- * {@link https://datatracker.ietf.org/doc/draft-ietf-oauth-sd-jwt-vc/13/}.
+ * Action that forms an SD-JWT VC.
*
*
* Action verifies first that we are indeed forming 'dc+sd-jwt' type credential
@@ -68,6 +69,20 @@ public class FormSelectiveDisclosureJWTCredential extends AbstractProfileAction
@NonnullBeforeExec
private CredentialOfferRequestedCredential credential;
+ /** Names of top-level claims that are not taken from the credential content. */
+ @Nonnull
+ private List<String> reservedClaimNames = List.of();
+
+ /**
+ * Set the names of top-level claims that are not taken from the credential content.
+ *
+ * @param claimNames claim names
+ */
+ public void setReservedClaimNames(@Nullable final List<String> claimNames) {
+ checkSetterPreconditions();
+ reservedClaimNames = claimNames != null ? List.copyOf(claimNames) : List.of();
+ }
+
/** {@inheritDoc} */
@Override
protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
@@ -88,11 +103,13 @@ public class FormSelectiveDisclosureJWTCredential extends AbstractProfileAction
}
credential = ctx.getCredentialContent();
if (credential == null) {
- log.warn("{} No credential content in context, nothingh to do", getLogPrefix());
+ log.error("{} No credential content in context", getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_CREDENTIAL);
return false;
}
if (ctx.getCredentialShells() == null || ctx.getCredentialShells().isEmpty()) {
- log.warn("{} No shells stored to context, nothing to do", getLogPrefix());
+ log.error("{} No credential shells in context", getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_CREDENTIAL);
return false;
}
return true;
@@ -103,16 +120,25 @@ public class FormSelectiveDisclosureJWTCredential extends AbstractProfileAction
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
final CredentialIssuanceConfiguration settings = ctx.getCredentialConfiguration().getIssuanceConfiguration();
- final List<List<String>> disclosedArrays = settings == null ? List.of()
- : settings.getClaimDisclosures().stream().map(ClaimDisclosure::getArrayPath).toList();
+ final List<List<String>> disclosedArrays = paths(settings, ClaimDisclosure.ALWAYS);
+ final List<List<String>> plainClaims = paths(settings, ClaimDisclosure.NEVER);
// Claims of this format are on top level of the credential.
final List<JWTClaimsSet> credentials = new ArrayList<>();
final List<String> disclosures = new ArrayList<>();
+ final List<CredentialOfferRequestedClaim> claims = new ArrayList<>();
+ for (final CredentialOfferRequestedClaim claim : credential.getRequestedCredential()) {
+ if (!claim.getPath().isEmpty() && reservedClaimNames.contains(claim.getPath().get(0))) {
+ log.debug("{} Claim has a reserved name ({}), not added to the credential", getLogPrefix(),
+ claim.getPath().get(0));
+ continue;
+ }
+ claims.add(claim);
+ }
for (final ClaimsSet cred : ctx.getCredentialShells()) {
// A tree per credential, so that salts, digests and disclosures are not shared within a batch.
final SelectiveDisclosureClaimTree tree;
try {
- tree = new SelectiveDisclosureClaimTree(credential.getRequestedCredential(), disclosedArrays);
+ tree = new SelectiveDisclosureClaimTree(claims, disclosedArrays, plainClaims);
} catch (final IllegalArgumentException e) {
log.error("{} Unable to disclose the requested claims", getLogPrefix(), e);
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_CREDENTIAL);
@@ -132,4 +158,19 @@ public class FormSelectiveDisclosureJWTCredential extends AbstractProfileAction
ctx.setJWTCredentials(credentials);
ctx.setDisclosures(disclosures);
}
-}
\ No newline at end of file
+
+ /**
+ * Get the paths of the claims with a selective disclosure.
+ *
+ * @param settings issuance configuration, or null
+ * @param sd selective disclosure
+ * @return paths of the claims
+ */
+ @Nonnull
+ private static List<List<String>> paths(@Nullable final CredentialIssuanceConfiguration settings,
+ @Nonnull final String sd) {
+ return settings == null ? List.of()
+ : settings.getClaimDisclosures().stream().filter(disclosure -> sd.equals(disclosure.getSd()))
+ .map(ClaimDisclosure::getNames).toList();
+ }
+}
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseAccessToken.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseAccessToken.java
index f99072d..415e625 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseAccessToken.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseAccessToken.java
@@ -54,6 +54,7 @@ import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.resolver.CriteriaSet;
import net.shibboleth.shared.resolver.ResolverException;
+import net.shibboleth.shared.security.DataExpiredException;
import net.shibboleth.shared.security.DataSealer;
import net.shibboleth.shared.security.DataSealerException;
@@ -148,7 +149,7 @@ public class ParseAccessToken extends AbstractOpenIDVCICredentialsValidationResp
final AccessToken token = getCredentialsRequest().getAccessToken();
if (token == null) {
- log.error("{} Token missing from request", getLogPrefix());
+ log.warn("{} Token missing from request", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, invalidTokenId);
return;
}
@@ -224,6 +225,8 @@ public class ParseAccessToken extends AbstractOpenIDVCICredentialsValidationResp
assert signedJWT != null;
assert dataSealer != null;
return AccessTokenClaimsSet.parse(signedJWT, dataSealer);
+ } catch (final DataExpiredException e) {
+ log.info("{} Sealed data within the JWT access token has expired", getLogPrefix());
} catch (final DataSealerException | ParseException e) {
}
@@ -232,6 +235,8 @@ public class ParseAccessToken extends AbstractOpenIDVCICredentialsValidationResp
try {
assert dataSealer != null;
return AccessTokenClaimsSet.parse(tokenValue, dataSealer);
+ } catch (final DataExpiredException e) {
+ log.info("{} Opaque access token has expired", getLogPrefix());
} catch (final DataSealerException | ParseException e) {
}
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseProof.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseProof.java
index bf83e87..0642d39 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseProof.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseProof.java
@@ -37,6 +37,7 @@ import org.geant.shibboleth.plugin.openidvci.messaging.impl.OpenIDVCICredentials
import org.geant.shibboleth.plugin.openidvci.metadata.CredentialIssuerMetadata;
import org.geant.shibboleth.plugin.openidvci.metadata.resolver.CredentialIssuerMetadataResolver;
import org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds;
+import org.geant.shibboleth.plugin.openidvci.security.impl.DidSupport;
import org.geant.shibboleth.plugin.openidvci.security.impl.KeyAttestationValidator;
import org.opensaml.messaging.context.navigate.ChildContextLookup;
import org.opensaml.profile.action.ActionSupport;
@@ -233,7 +234,7 @@ public class ParseProof extends AbstractProfileAction {
}
if (proof == null) {
if (isProofRequired(profileRequestContext)) {
- log.error("{} Requested credential configuration requires a key proof, request carries none",
+ log.warn("{} Requested credential configuration requires a key proof, request carries none",
getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
return false;
@@ -253,17 +254,17 @@ public class ParseProof extends AbstractProfileAction {
return;
}
if (proofToken == null) {
- log.error("{} Only proofs of type 'jwt' and 'attestation' are supported {}", getLogPrefix(), proof);
+ log.warn("{} Only proofs of type 'jwt' and 'attestation' are supported {}", getLogPrefix(), proof);
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.PROOF_TYPE_UNSUPPORTED);
return;
}
if (!(proofToken instanceof List<?> tokens) || tokens.isEmpty()) {
- log.error("{} Key proofs of type 'jwt' are not a non-empty array", getLogPrefix());
+ log.warn("{} Key proofs of type 'jwt' are not a non-empty array", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
return;
}
if (tokens.size() > batchSize) {
- log.error("{} Request carries {} key proofs, at most {} are accepted", getLogPrefix(), tokens.size(),
+ log.warn("{} Request carries {} key proofs, at most {} are accepted", getLogPrefix(), tokens.size(),
batchSize);
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
return;
@@ -271,21 +272,21 @@ public class ParseProof extends AbstractProfileAction {
final List<SignedJWT> proofs = new ArrayList<SignedJWT>();
for (final Object token : tokens) {
if (!(token instanceof String strToken)) {
- log.error("{} Key proof is not a string", getLogPrefix());
+ log.warn("{} Key proof is not a string", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
return;
}
+ SignedJWT singleProof = null;
try {
- final SignedJWT singleProof = SignedJWT.parse(strToken);
+ singleProof = SignedJWT.parse(strToken);
validateJWTProof(singleProof, profileRequestContext);
validateKeyAttestation(singleProof, profileRequestContext);
proofs.add(singleProof);
} catch (final DPoPProofNonceJWTValidationException e) {
- log.error("{} proof carries an invalid nonce.", getLogPrefix(), e);
- ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_NONCE);
+ buildNonceEvent(profileRequestContext, singleProof, "Key proof", e);
return;
} catch (final Exception e) {
- log.error("{} proof parsing failed.", getLogPrefix(), e);
+ log.warn("{} Key proof is invalid: {}", getLogPrefix(), e.getMessage());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
return;
}
@@ -308,7 +309,7 @@ public class ParseProof extends AbstractProfileAction {
@Nonnull final Object proofToken) {
final ProofTypeSupported attestationProofs = resolveProofType(profileRequestContext, PROOF_TYPE_ATTESTATION);
if (attestationProofs == null) {
- log.error("{} Requested credential configuration does not support proofs of type 'attestation'",
+ log.warn("{} Requested credential configuration does not support proofs of type 'attestation'",
getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.PROOF_TYPE_UNSUPPORTED);
return;
@@ -321,28 +322,28 @@ public class ParseProof extends AbstractProfileAction {
}
if (!(proofToken instanceof List<?> tokens) || tokens.size() != 1
|| !(tokens.get(0) instanceof String attestation)) {
- log.error("{} Key proofs of type 'attestation' are not an array of exactly one string", getLogPrefix());
+ log.warn("{} Key proofs of type 'attestation' are not an array of exactly one string", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
return;
}
final List<JWK> attested;
+ SignedJWT parsed = null;
try {
- final SignedJWT parsed = SignedJWT.parse(attestation);
+ parsed = SignedJWT.parse(attestation);
proofSigningAlgValuesSupported = attestationProofs.getProofSigningAlgValuesSupported();
validateAlgorithm(parsed.getHeader().getAlgorithm());
attested = keyAttestationValidator.validate(profileRequestContext, parsed,
attestationProofs.getKeyAttestationsRequired(), keyAttestationClaimsValidator, false);
} catch (final DPoPProofNonceJWTValidationException e) {
- log.error("{} Key attestation carries an invalid nonce.", getLogPrefix(), e);
- ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_NONCE);
+ buildNonceEvent(profileRequestContext, parsed, "Key attestation", e);
return;
} catch (final Exception e) {
- log.error("{} Key attestation parsing failed.", getLogPrefix(), e);
+ log.warn("{} Key attestation is invalid: {}", getLogPrefix(), e.getMessage());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
return;
}
if (attested.size() > batchSize) {
- log.error("{} Key attestation attests {} keys, at most {} are accepted", getLogPrefix(), attested.size(),
+ log.warn("{} Key attestation attests {} keys, at most {} are accepted", getLogPrefix(), attested.size(),
batchSize);
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
return;
@@ -351,6 +352,43 @@ public class ParseProof extends AbstractProfileAction {
.setAttestedKeys(attested);
}
+ /**
+ * Build the event of a nonce failure, invalid_proof for a JWT without nonce and invalid_nonce otherwise.
+ *
+ * @param profileRequestContext profile request context
+ * @param jwt JWT the nonce failure is of, or null
+ * @param what what the JWT is, for the log
+ * @param e nonce failure
+ */
+ private void buildNonceEvent(@Nonnull final ProfileRequestContext profileRequestContext,
+ @Nullable final SignedJWT jwt, @Nonnull final String what,
+ @Nonnull final DPoPProofNonceJWTValidationException e) {
+ if (!hasNonce(jwt)) {
+ log.warn("{} {} carries no nonce", getLogPrefix(), what);
+ ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_PROOF);
+ return;
+ }
+ log.warn("{} {} carries an invalid nonce: {}", getLogPrefix(), what, e.getMessage());
+ ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_NONCE);
+ }
+
+ /**
+ * Whether a JWT has a nonce claim.
+ *
+ * @param jwt JWT, or null
+ * @return true if the JWT has a nonce claim
+ */
+ private static boolean hasNonce(@Nullable final SignedJWT jwt) {
+ if (jwt == null) {
+ return false;
+ }
+ try {
+ return jwt.getJWTClaimsSet().getClaim("nonce") != null;
+ } catch (final ParseException e) {
+ return false;
+ }
+ }
+
/**
* Validate a jwt proof per the OpenID4VCI specification.
*
@@ -369,7 +407,7 @@ public class ParseProof extends AbstractProfileAction {
if (JWSAlgorithm.Family.HMAC_SHA.contains(jwtProof.getHeader().getAlgorithm())) {
throw new IllegalArgumentException("HMAC algorithm used: " + jwtProof.getHeader().getAlgorithm().getName());
}
- if (!jwtProof.getHeader().getType().equals(new JOSEObjectType("openid4vci-proof+jwt"))) {
+ if (!new JOSEObjectType("openid4vci-proof+jwt").equals(jwtProof.getHeader().getType())) {
throw new IllegalArgumentException("typ should be openid4vci-proof+jwt: " + jwtProof.getHeader().getType());
}
final int fields = (jwtProof.getHeader().getJWK() != null ? 1 : 0)
@@ -379,6 +417,14 @@ public class ParseProof extends AbstractProfileAction {
if (fields != 1) {
throw new IllegalArgumentException("Exactly one of jwk, x5c, or kid must be present");
}
+ if (jwtProof.getHeader().getX509CertChain() != null) {
+ throw new IllegalArgumentException("Key proofs with x5c are not supported");
+ }
+ final String kid = jwtProof.getHeader().getKeyID();
+ if (kid != null && !kid.startsWith(DidSupport.DID_JWK_PREFIX)) {
+ throw new IllegalArgumentException("Key proofs with a kid other than a did:jwk URL are not supported: "
+ + kid);
+ }
validateAlgorithm(jwtProof.getHeader().getAlgorithm());
final JWTClaimsSet claims = JWTClaimsSet.parse(jwtProof.getPayload().toJSONObject());
validateIssueTime(claims.getIssueTime());
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/SignJWTCredential.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/SignJWTCredential.java
index f5bf6b9..b694be0 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/SignJWTCredential.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/SignJWTCredential.java
@@ -40,7 +40,6 @@ import net.shibboleth.idp.plugin.oidc.op.profile.impl.AbstractOIDCResponseAction
import net.shibboleth.oidc.security.jose.SignatureException;
import net.shibboleth.oidc.security.jose.SignatureSigningParameters;
import net.shibboleth.oidc.security.jose.context.SecurityParametersContext;
-import net.shibboleth.profile.context.navigate.IssuerLookupFunction;
import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
import net.shibboleth.shared.annotation.constraint.NonnullBeforeExec;
import net.shibboleth.shared.logic.Constraint;
@@ -69,10 +68,6 @@ public class SignJWTCredential extends AbstractOIDCResponseAction {
@Nonnull
private Function<ProfileRequestContext, SecurityParametersContext> securityParametersLookupStrategy;
- /** Strategy used to obtain the response issuer value. */
- @Nonnull
- private Function<ProfileRequestContext, String> issuerLookupStrategy;
-
/** The signature signing parameters. */
@NonnullAfterInit
private SignatureSigningParameters signatureSigningParameters;
@@ -83,7 +78,6 @@ public class SignJWTCredential extends AbstractOIDCResponseAction {
SecurityParametersContext.class).compose(new OutboundMessageContextLookup());
assert splcs != null;
securityParametersLookupStrategy = splcs;
- issuerLookupStrategy = (Function<ProfileRequestContext, String>) new IssuerLookupFunction();
}
/**
@@ -99,16 +93,6 @@ public class SignJWTCredential extends AbstractOIDCResponseAction {
"SecurityParameterContext lookup strategy cannot be null");
}
- /**
- * Set the strategy used to locate the issuer value to use.
- *
- * @param strategy lookup strategy
- */
- public void setIssuerLookupStrategy(@Nonnull final Function<ProfileRequestContext, String> strategy) {
- checkSetterPreconditions();
- issuerLookupStrategy = Constraint.isNotNull(strategy, "IssuerLookupStrategy lookup strategy cannot be null");
- }
-
/**
* Get the signing parameters to apply.
*
@@ -133,18 +117,10 @@ public class SignJWTCredential extends AbstractOIDCResponseAction {
return false;
}
final SecurityParametersContext secParamCtx = securityParametersLookupStrategy.apply(profileRequestContext);
- if (secParamCtx == null) {
- log.debug("{} no security parameters context is available", getLogPrefix());
- return false;
- }
-
- signatureSigningParameters = secParamCtx.getSignatureSigningParameters();
- if (signatureSigningParameters == null) {
- log.debug("{} no signature signing parameters available", getLogPrefix());
- return false;
- }
- if (signatureSigningParameters.getSigningCredential() == null) {
- log.debug("{} no signature signing credential available", getLogPrefix());
+ signatureSigningParameters = secParamCtx != null ? secParamCtx.getSignatureSigningParameters() : null;
+ if (signatureSigningParameters == null || signatureSigningParameters.getSigningCredential() == null) {
+ log.error("{} No signing credential for the credentials", getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_SEC_CFG);
return false;
}
return true;
@@ -173,7 +149,7 @@ public class SignJWTCredential extends AbstractOIDCResponseAction {
}
}
ctx.setSignedCredentials(credentials);
- log.info("Signed {} credentials", credentials.size());
+ log.debug("{} Signed {} credentials", getLogPrefix(), credentials.size());
}
}
\ No newline at end of file
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/SignMobileSecurityObject.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/SignMobileSecurityObject.java
index f694700..41e82fb 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/SignMobileSecurityObject.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/SignMobileSecurityObject.java
@@ -157,7 +157,7 @@ public class SignMobileSecurityObject extends AbstractProfileAction {
return;
}
ctx.setSignedCredentials(credentials);
- log.info("{} Signed {} mdoc credentials", getLogPrefix(), credentials.size());
+ log.debug("{} Signed {} mdoc credentials", getLogPrefix(), credentials.size());
}
}
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateExpectedGrantType.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateExpectedGrantType.java
deleted file mode 100644
index 0945a37..0000000
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateExpectedGrantType.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2025, GÉANT
- *
- * Licensed under the Apache License, Version 2.0 (the “License”); you may not
- * use this file except in compliance with the License. You may obtain a copy
- * of the License at
- *
- * http://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.
- */
-
-package org.geant.shibboleth.plugin.openidvci.profile.impl;
-
-import java.util.Set;
-import javax.annotation.Nonnull;
-
-import org.geant.shibboleth.plugin.openidvci.messaging.impl.OpenIDVCITokenRequest;
-import org.opensaml.profile.action.ActionSupport;
-import org.opensaml.profile.action.EventIds;
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import com.nimbusds.oauth2.sdk.GrantType;
-import com.nimbusds.oauth2.sdk.ParseException;
-
-import net.shibboleth.idp.profile.AbstractProfileAction;
-import net.shibboleth.oidc.metadata.context.OIDCMetadataContext;
-import net.shibboleth.oidc.profile.core.OidcEventIds;
-import net.shibboleth.shared.logic.Constraint;
-
-/**
- * An action that validates expected grant type is registered for the relying
- * party. Action does not check the existence or value of the grant in the
- * actual request.
- *
- * TODO, as the second grant type is introduced this implementation needs revisiting.
- */
-public class ValidateExpectedGrantType extends AbstractProfileAction {
-
- /** Class logger. */
- @Nonnull
- private Logger log = LoggerFactory.getLogger(ValidateExpectedGrantType.class);
-
- /** Grant type the flow expects. */
- @Nonnull
- private String expectedGrantType = OpenIDVCITokenRequest.GRANT_TYPE_VALUE_PRE_AUTH;
-
- /** OIDC Metadata context. */
- private OIDCMetadataContext oidcMetadataContext;
-
- /**
- * Set expected grant type.
- *
- * @param type expected grant type
- */
- public void setExpectedGrantType(@Nonnull final String type) {
- Constraint.isNotEmpty(type, "Expected grant type must not be null or empty");
- expectedGrantType = type;
- }
-
- /** {@inheritDoc} */
- @Override
- protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
-
- if (!super.doPreExecute(profileRequestContext)) {
- return false;
- }
- if (profileRequestContext.getInboundMessageContext() == null) {
- log.error("{} No inbound message context", getLogPrefix());
- ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_PROFILE_CTX);
- return false;
- }
- oidcMetadataContext = profileRequestContext.getInboundMessageContext().getSubcontext(OIDCMetadataContext.class);
- if (oidcMetadataContext == null) {
- log.info("{} No metadata found for relying party. Grant type will not be validated", getLogPrefix());
- return false;
- }
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
- final Set<GrantType> registeredTypes = oidcMetadataContext.getClientInformation().getMetadata().getGrantTypes();
- try {
- if (registeredTypes == null || registeredTypes.isEmpty()
- || !registeredTypes.contains(GrantType.parse(expectedGrantType))) {
- log.error("{} The grant type {} is not registered for this RP", getLogPrefix(), expectedGrantType);
- ActionSupport.buildEvent(profileRequestContext, OidcEventIds.INVALID_GRANT_TYPE);
- }
- } catch (final ParseException e) {
- log.error("{} Unable to parse grant type from {}", getLogPrefix(), expectedGrantType);
- ActionSupport.buildEvent(profileRequestContext, OidcEventIds.INVALID_GRANT_TYPE);
- }
- }
-}
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateRequestedCredential.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateRequestedCredential.java
index b10719f..b88b950 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateRequestedCredential.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateRequestedCredential.java
@@ -21,6 +21,7 @@ import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
+import java.util.function.Predicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -33,6 +34,7 @@ import org.geant.shibboleth.plugin.openidvci.messaging.context.navigate.RequestC
import org.geant.shibboleth.plugin.openidvci.messaging.context.navigate.RequestCredentialIdentifierLookupFunction;
import org.geant.shibboleth.plugin.openidvci.messaging.impl.CredentialDataset;
import org.geant.shibboleth.plugin.openidvci.messaging.impl.CredentialOfferRequest;
+import org.geant.shibboleth.plugin.openidvci.messaging.impl.OpenIDVCICredentialsRequest;
import org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds;
import org.geant.shibboleth.plugin.openidvci.profile.config.OpenIDVCIConfiguration;
import org.geant.shibboleth.plugin.openidvci.profile.logic.OpenIDVCITokenManipulationStrategy;
@@ -47,6 +49,8 @@ import org.slf4j.LoggerFactory;
import net.shibboleth.idp.plugin.oidc.op.messaging.context.OIDCAuthenticationResponseContext;
import net.shibboleth.profile.context.RelyingPartyContext;
+import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
+import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.logic.Constraint;
/**
@@ -78,6 +82,14 @@ public class ValidateRequestedCredential extends AbstractCredentialValidationAct
@Nonnull
private BiFunction<ProfileRequestContext, String, List<CredentialDataset>> credentialContentLookupStrategy;
+ /** Condition for a request with a DPoP access token. */
+ @NonnullAfterInit
+ private Predicate<ProfileRequestContext> dpopAccessTokenCondition;
+
+ /** Condition for a request asking for an encrypted credential response. */
+ @Nonnull
+ private Predicate<ProfileRequestContext> responseEncryptionRequestedCondition;
+
/** Strategy used to locate the {@link RelyingPartyContext}. */
@Nonnull
private Function<ProfileRequestContext, RelyingPartyContext> relyingPartyContextLookupStrategy;
@@ -96,6 +108,30 @@ public class ValidateRequestedCredential extends AbstractCredentialValidationAct
requestCredentialIdentifierLookupStrategy = new RequestCredentialIdentifierLookupFunction();
credentialContentLookupStrategy = new PotentialCredentialLookupFunction();
relyingPartyContextLookupStrategy = new ChildContextLookup<>(RelyingPartyContext.class);
+ responseEncryptionRequestedCondition = prc -> prc.getInboundMessageContext() != null
+ && prc.getInboundMessageContext().getMessage() instanceof OpenIDVCICredentialsRequest request
+ && request.getCredentialResponseEncryption() != null;
+ }
+
+ /**
+ * Set the condition for a request with a DPoP access token.
+ *
+ * @param condition condition
+ */
+ public void setDpopAccessTokenCondition(@Nonnull final Predicate<ProfileRequestContext> condition) {
+ checkSetterPreconditions();
+ dpopAccessTokenCondition = Constraint.isNotNull(condition, "DPoP access token condition cannot be null");
+ }
+
+ /**
+ * Set the condition for a request asking for an encrypted credential response.
+ *
+ * @param condition condition
+ */
+ public void setResponseEncryptionRequestedCondition(@Nonnull final Predicate<ProfileRequestContext> condition) {
+ checkSetterPreconditions();
+ responseEncryptionRequestedCondition = Constraint.isNotNull(condition,
+ "Response encryption requested condition cannot be null");
}
/**
@@ -149,6 +185,15 @@ public class ValidateRequestedCredential extends AbstractCredentialValidationAct
"RelyingPartyContext lookup strategy cannot be null");
}
+ /** {@inheritDoc} */
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
+ super.doInitialize();
+ if (dpopAccessTokenCondition == null) {
+ throw new ComponentInitializationException("DPoP access token condition cannot be null");
+ }
+ }
+
/** {@inheritDoc} */
@Override
protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
@@ -179,10 +224,16 @@ public class ValidateRequestedCredential extends AbstractCredentialValidationAct
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
+ if (responseEncryptionRequestedCondition.test(profileRequestContext)) {
+ log.warn("{} Request has credential_response_encryption, encrypted responses are not supported",
+ getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.NO_CREDENTIAL_REQUEST);
+ return;
+ }
final String configurationId = requestCredentialConfigurationIdLookupStrategy.apply(profileRequestContext);
final String identifier = requestCredentialIdentifierLookupStrategy.apply(profileRequestContext);
if ((configurationId == null) == (identifier == null)) {
- log.error("{} Request must have either credential_identifier or credential_configuration_id",
+ log.warn("{} Request must have either credential_identifier or credential_configuration_id",
getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.NO_CREDENTIAL_REQUEST);
return;
@@ -212,40 +263,46 @@ public class ValidateRequestedCredential extends AbstractCredentialValidationAct
}
final String selectedConfigurationId = identifier != null ? issuedConfigurationId : configurationId;
if (identifier != null && issuedConfigurationId == null) {
- log.error("{} Credential identifier {} was not issued", getLogPrefix(), identifier);
+ log.warn("{} Credential identifier {} was not issued", getLogPrefix(), identifier);
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.UNKNOWN_CREDENTIAL_IDENTIFIER);
return;
}
if (identifier == null && getCredentialConfigurations().get(configurationId) == null) {
- log.error("{} Credential configuration {} is unknown", getLogPrefix(), configurationId);
+ log.warn("{} Credential configuration {} is unknown", getLogPrefix(), configurationId);
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.NO_CREDENTIALS_FOR_REQUEST);
return;
}
if (identifier == null && issuedIdentifiers != null && !issuedIdentifiers.isEmpty()
&& !allowCredentialConfigurationIdWithIdentifiers) {
- log.error("{} Request has credential_configuration_id {} although credential identifiers were issued",
+ log.warn("{} Request has credential_configuration_id {} although credential identifiers were issued",
getLogPrefix(), configurationId);
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.NO_CREDENTIAL_REQUEST);
return;
}
final CredentialConfiguration configuration = getCredentialConfigurations().get(selectedConfigurationId);
if (configuration == null) {
- log.error("{} Credential configuration {} is unknown", getLogPrefix(), selectedConfigurationId);
+ log.warn("{} Credential configuration {} is unknown", getLogPrefix(), selectedConfigurationId);
ActionSupport.buildEvent(profileRequestContext, identifier != null
? OpenIDVCIEventIds.UNKNOWN_CREDENTIAL_IDENTIFIER : OpenIDVCIEventIds.NO_CREDENTIALS_FOR_REQUEST);
return;
}
final List<CredentialDataset> datasets =
credentialContentLookupStrategy.apply(profileRequestContext, selectedConfigurationId);
+ if (identifier == null && datasets == null) {
+ log.warn("{} Access token does not grant credential configuration {}", getLogPrefix(), configurationId);
+ ActionSupport.buildEvent(profileRequestContext, dpopAccessTokenCondition.test(profileRequestContext)
+ ? OpenIDVCIEventIds.CREDENTIAL_NOT_GRANTED_DPOP : OpenIDVCIEventIds.CREDENTIAL_NOT_GRANTED);
+ return;
+ }
if (identifier == null && datasets != null && datasets.size() > 1) {
- log.error("{} Credential configuration {} has several datasets, credential_identifier is required",
+ log.warn("{} Credential configuration {} has several datasets, credential_identifier is required",
getLogPrefix(), configurationId);
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.NO_CREDENTIAL_REQUEST);
return;
}
final CredentialDataset dataset = selectDataset(datasets, issuedDatasetId);
if (dataset == null) {
- log.error("{} No matching credential content found for requested credential {}", getLogPrefix(),
+ log.warn("{} No matching credential content found for requested credential {}", getLogPrefix(),
identifier != null ? identifier : configurationId);
ActionSupport.buildEvent(profileRequestContext, identifier != null
? OpenIDVCIEventIds.UNKNOWN_CREDENTIAL_IDENTIFIER : OpenIDVCIEventIds.NO_CREDENTIALS_FOR_REQUEST);
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/impl/CertificateChainTrust.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/impl/CertificateChainTrust.java
index c61b380..f16a09a 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/impl/CertificateChainTrust.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/impl/CertificateChainTrust.java
@@ -26,9 +26,12 @@ import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import javax.security.auth.x500.X500Principal;
import org.opensaml.security.SecurityException;
import org.opensaml.security.credential.Credential;
@@ -198,7 +201,8 @@ public class CertificateChainTrust extends AbstractInitializableComponent {
}
/**
- * Evaluate the PKIX trust of a chain against each trust anchor, with the CRLs the anchor has issued.
+ * Evaluate the PKIX trust of a chain against each trust anchor that issued one of its certificates, with the
+ * CRLs the anchor has issued.
*
* @param chain certificate chain, the leaf first
*
@@ -215,8 +219,13 @@ public class CertificateChainTrust extends AbstractInitializableComponent {
}
final BasicX509Credential untrusted = new BasicX509Credential(chain.get(0));
untrusted.setEntityCertificateChain(chain);
+ final Set<X500Principal> issuers =
+ chain.stream().map(X509Certificate::getIssuerX500Principal).collect(Collectors.toSet());
try {
for (final X509Certificate anchor : trustAnchors) {
+ if (!issuers.contains(anchor.getSubjectX500Principal())) {
+ continue;
+ }
final List<X509CRL> issued = current.stream()
.filter(crl -> crl.getIssuerX500Principal().equals(anchor.getSubjectX500Principal()))
.toList();
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/impl/DPoPHttpUriClaimsValidator.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/impl/DPoPHttpUriClaimsValidator.java
index f4a9188..3f89ee2 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/impl/DPoPHttpUriClaimsValidator.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/impl/DPoPHttpUriClaimsValidator.java
@@ -36,8 +36,8 @@ import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.primitive.LoggerFactory;
/**
- * Validator of the 'htu' claim of a DPoP proof, matched against the request URI after RFC 3986 syntax and scheme
- * based normalization, ignoring the query and fragment parts.
+ * Validator of the 'htu' claim of a DPoP proof, matched against the https URI of the issuer host and the request path
+ * after RFC 3986 syntax and scheme based normalization, ignoring the query and fragment parts.
*/
public class DPoPHttpUriClaimsValidator extends AbstractClaimsValidator {
@@ -49,28 +49,59 @@ public class DPoPHttpUriClaimsValidator extends AbstractClaimsValidator {
@Nonnull
private final Logger log = LoggerFactory.getLogger(DPoPHttpUriClaimsValidator.class);
- /** Strategy used to locate the request URI. */
+ /** Issuer whose host the claim must have. */
@NonnullAfterInit
- private BiFunction<ProfileRequestContext, JWTClaimsSet, String> requestUriLookupStrategy;
+ private String issuer;
+
+ /** Strategy used to locate the request path. */
+ @NonnullAfterInit
+ private BiFunction<ProfileRequestContext, JWTClaimsSet, String> requestPathLookupStrategy;
+
+ /** Scheme and authority of the issuer. */
+ @NonnullAfterInit
+ private String issuerBase;
+
+ /**
+ * Set the issuer whose host the claim must have.
+ *
+ * @param value issuer
+ */
+ public void setIssuer(@Nonnull final String value) {
+ checkSetterPreconditions();
+ issuer = Constraint.isNotNull(value, "Issuer cannot be null");
+ }
/**
- * Set the strategy used to locate the request URI.
+ * Set the strategy used to locate the request path.
*
* @param strategy lookup strategy
*/
- public void setRequestUriLookupStrategy(
+ public void setRequestPathLookupStrategy(
@Nonnull final BiFunction<ProfileRequestContext, JWTClaimsSet, String> strategy) {
- ifInitializedThrowUnmodifiabledComponentException();
- requestUriLookupStrategy = Constraint.isNotNull(strategy, "Request URI lookup strategy cannot be null");
+ checkSetterPreconditions();
+ requestPathLookupStrategy = Constraint.isNotNull(strategy, "Request path lookup strategy cannot be null");
}
/** {@inheritDoc} */
@Override
protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
- if (requestUriLookupStrategy == null) {
- throw new ComponentInitializationException("Request URI lookup strategy cannot be null");
+ if (requestPathLookupStrategy == null) {
+ throw new ComponentInitializationException("Request path lookup strategy cannot be null");
+ }
+ if (issuer == null) {
+ throw new ComponentInitializationException("Issuer cannot be null");
+ }
+ final URI base;
+ try {
+ base = new URI(issuer);
+ } catch (final URISyntaxException e) {
+ throw new ComponentInitializationException("Issuer '" + issuer + "' is not an https url with a host");
+ }
+ if (!"https".equals(base.getScheme()) || base.getHost() == null) {
+ throw new ComponentInitializationException("Issuer '" + issuer + "' is not an https url with a host");
}
+ issuerBase = "https://" + base.getRawAuthority();
}
/** {@inheritDoc} */
@@ -81,10 +112,11 @@ public class DPoPHttpUriClaimsValidator extends AbstractClaimsValidator {
if (!(claim instanceof String htu)) {
throw new JWTValidationException("Claim '" + HTU + "' does not exist or is not a string");
}
- final String expected = requestUriLookupStrategy.apply(context, claims);
- if (expected == null) {
- throw new JWTValidationException("No request URI to match claim '" + HTU + "' against");
+ final String path = requestPathLookupStrategy.apply(context, claims);
+ if (path == null) {
+ throw new JWTValidationException("No request path to match claim '" + HTU + "' against");
}
+ final String expected = issuerBase + path;
if (!normalize(htu).equals(normalize(expected))) {
throw new JWTValidationException("JWT \"" + HTU + "\" claim has value " + htu + " but should be "
+ expected);
diff --git a/openid-vci-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml b/openid-vci-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
index 12ab95a..cf1df57 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
@@ -298,4 +298,24 @@
lazy-init="true"
c:path="%{openidvci.authorizationServer.template:%{idp.home}/static/oauth-authorization-server.json}" />
+ <!-- Top-level claims of an SD-JWT VC that are not taken from the credential content. -->
+ <bean id="openidvci.DefaultSdJwtVcReservedClaimNames" lazy-init="true"
+ class="org.springframework.beans.factory.config.ListFactoryBean">
+ <property name="sourceList">
+ <list>
+ <value>iss</value>
+ <value>iat</value>
+ <value>nbf</value>
+ <value>exp</value>
+ <value>cnf</value>
+ <value>vct</value>
+ <value>vct#integrity</value>
+ <value>aka_vcts</value>
+ <value>status</value>
+ <value>fed</value>
+ <value>_sd_alg</value>
+ </list>
+ </property>
+ </bean>
+
</beans>
diff --git a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credentials/credentials-beans.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credentials/credentials-beans.xml
index c166763..7ecbb35 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credentials/credentials-beans.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credentials/credentials-beans.xml
@@ -11,9 +11,13 @@
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
default-init-method="initialize" default-destroy-method="destroy">
- <bean id="openidvci.profileId" class="java.lang.String" c:_0="http://geant.org/ns/profiles/openid/vci/credentials"/>
+ <bean id="openidvci.profileId" class="java.lang.String"
+ c:_0="#{T(org.geant.shibboleth.plugin.openidvci.profile.config.OpenIDVCIConfiguration).PROFILE_ID_CREDENTIALS}"/>
<bean id="openidvci.loggingId" class="java.lang.String"
c:_0="%{openidvci.logging.credentials:OpenID.VCI.Credentials}"/>
+
+ <util:constant id="shibboleth.metrics.ProfileCounter"
+ static-field="org.geant.shibboleth.plugin.openidvci.profile.config.impl.DefaultOpenIDVCICredentialsConfiguration.PROFILE_COUNTER"/>
<bean id="OpenIDVCIDecodeMessage" class="org.opensaml.profile.action.impl.DecodeMessage" scope="prototype">
<constructor-arg>
@@ -32,12 +36,22 @@
</property>
</bean>
+ <bean id="ValidateClientIDAgainstPolicy"
+ class="net.shibboleth.idp.plugin.oidc.op.oauth2.profile.impl.ValidateClientIDAgainstPolicy" scope="prototype"
+ p:clientIDLookupStrategy-ref="shibboleth.ClientIDLookupStrategy"
+ p:unregisteredClientPolicyEnforcer="#{getObject('shibboleth.oidc.UnregisteredClientPolicyEnforcer') ?: getObject('shibboleth.oidc.DefaultUnregisteredClientPolicyEnforcer')}" />
+
<bean id="ValidateAccessTokenBinding"
class="org.geant.shibboleth.plugin.openidvci.profile.impl.ValidateAccessTokenBinding" scope="prototype" />
<bean id="ValidateRequestedCredential"
class="org.geant.shibboleth.plugin.openidvci.profile.impl.ValidateRequestedCredential"
- p:credentialConfigurationsResolver-ref="openidvci.CredentialConfigurationsResolver" scope="prototype" />
+ p:credentialConfigurationsResolver-ref="openidvci.CredentialConfigurationsResolver" scope="prototype">
+ <property name="dpopAccessTokenCondition">
+ <bean class="net.shibboleth.idp.plugin.oidc.op.profile.logic.DPoPAccessTokenInRequestCondition"
+ p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier"/>
+ </property>
+ </bean>
<bean id="ParseProof"
class="org.geant.shibboleth.plugin.openidvci.profile.impl.ParseProof" scope="prototype"
@@ -110,12 +124,6 @@
<bean id="RelyingPartyCredentialResolver" class="net.shibboleth.profile.relyingparty.RelyingPartyCredentialResolver"
c:_0-ref="shibboleth.RelyingPartyResolverService" />
- <bean id="ValidateExpectedGrantType" class="org.geant.shibboleth.plugin.openidvci.profile.impl.ValidateExpectedGrantType"
- scope="prototype"/>
-
- <bean id="InitializeAuthenticationContext" class="net.shibboleth.idp.saml.profile.impl.InitializeAuthenticationContext"
- scope="prototype" />
-
<bean id="PopulateCredentialsSignatureSigningParameters"
class="net.shibboleth.oidc.profile.impl.PopulateJWTSignatureSigningParameters"
scope="prototype" p:noResultIsError="true"
@@ -158,14 +166,14 @@
p:metadataResolver-ref="#{'%{openidvci.issuerMetadata.resolver:openidvci.DefaultCredentialIssuerMetadataResolver}'.trim()}" />
<bean id="OptionallyFormSelectiveDisclosureJWTCredential" class="org.geant.shibboleth.plugin.openidvci.profile.impl.FormSelectiveDisclosureJWTCredential"
- scope="prototype" />
+ scope="prototype"
+ p:reservedClaimNames="#{getObject('openidvci.SdJwtVcReservedClaimNames') ?: getObject('openidvci.DefaultSdJwtVcReservedClaimNames')}" />
<bean id="OptionallyFormJsonLdSelectiveDisclosureJWTCredential" class="org.geant.shibboleth.plugin.openidvci.profile.impl.FormJsonLdSelectiveDisclosureJWTCredential"
- scope="prototype" p:issuerLookupStrategy-ref="openidvci.IssuerLookupStrategy" />
+ scope="prototype" />
<bean id="SignJWTCredential" class="org.geant.shibboleth.plugin.openidvci.profile.impl.SignJWTCredential"
- scope="prototype" p:issuerLookupStrategy-ref="shibboleth.ResponderIdLookup.Simple"
- p:activationCondition-ref="openidvci.NotMdocCondition">
+ scope="prototype" p:activationCondition-ref="openidvci.NotMdocCondition">
<property name="securityParametersLookupStrategy">
<bean parent="shibboleth.Functions.Compose"
c:g-ref="shibboleth.oidc.ChildLookup.JWTSecurityParameters"
@@ -191,11 +199,13 @@
<bean id="OpenIDVCIFormOutboundMessage" class="org.geant.shibboleth.plugin.openidvci.profile.impl.FormOutboundCredentialsResponseMessage"
scope="prototype" />
- <!-- Error vocabulary of the Credential Endpoint, OpenID4VCI 1.0 section 8.4. -->
- <bean id="openidvci.credentials.MappedErrors" parent="shibboleth.oidc.DefaultOAuth2ProtectedApiMappedErrors"
+ <!-- Error vocabulary of the Credential Endpoint, OpenID4VCI 1.0 section 8.3.1.2. -->
+ <bean id="openidvci.credentials.DefaultMappedErrors" parent="shibboleth.oidc.DefaultOAuth2ProtectedApiMappedErrors"
class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap">
<map merge="true" value-type="com.nimbusds.oauth2.sdk.ErrorObject">
+ <entry key="#{T(org.opensaml.profile.action.EventIds).UNABLE_TO_DECODE}"
+ value="#{T(org.geant.shibboleth.plugin.openidvci.messaging.error.OpenIDVCIError).INVALID_CREDENTIAL_REQUEST}" />
<entry key="#{T(org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds).NO_CREDENTIALS_REQUEST}"
value="#{T(org.geant.shibboleth.plugin.openidvci.messaging.error.OpenIDVCIError).INVALID_CREDENTIAL_REQUEST}" />
<entry key="#{T(org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds).NO_CREDENTIAL_REQUEST}"
@@ -204,6 +214,10 @@
value="#{T(org.geant.shibboleth.plugin.openidvci.messaging.error.OpenIDVCIError).UNKNOWN_CREDENTIAL_CONFIGURATION}" />
<entry key="#{T(org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds).NO_CREDENTIALS_FOR_REQUEST}"
value="#{T(org.geant.shibboleth.plugin.openidvci.messaging.error.OpenIDVCIError).UNKNOWN_CREDENTIAL_CONFIGURATION}" />
+ <entry key="#{T(org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds).CREDENTIAL_NOT_GRANTED}"
+ value="#{T(com.nimbusds.oauth2.sdk.token.BearerTokenError).INSUFFICIENT_SCOPE}" />
+ <entry key="#{T(org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds).CREDENTIAL_NOT_GRANTED_DPOP}"
+ value="#{T(com.nimbusds.oauth2.sdk.token.DPoPTokenError).INSUFFICIENT_SCOPE}" />
<entry key="#{T(org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds).UNKNOWN_CREDENTIAL_IDENTIFIER}"
value="#{T(org.geant.shibboleth.plugin.openidvci.messaging.error.OpenIDVCIError).UNKNOWN_CREDENTIAL_IDENTIFIER}" />
<entry key="#{T(org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds).PROOF_TYPE_UNSUPPORTED}"
@@ -213,7 +227,7 @@
<entry key="#{T(org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds).INVALID_NONCE}"
value="#{T(org.geant.shibboleth.plugin.openidvci.messaging.error.OpenIDVCIError).INVALID_NONCE}" />
<entry key="#{T(org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds).INVALID_CREDENTIAL}"
- value="#{T(org.geant.shibboleth.plugin.openidvci.messaging.error.OpenIDVCIError).CREDENTIAL_REQUEST_DENIED}" />
+ value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).SERVER_ERROR}" />
<entry key="#{T(org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds).VALIDITY_WINDOW_CLOSED}"
value="#{T(org.geant.shibboleth.plugin.openidvci.messaging.error.OpenIDVCIError).CREDENTIAL_REQUEST_DENIED}" />
<entry key="#{T(org.opensaml.profile.action.EventIds).INVALID_PROFILE_CTX}"
@@ -231,7 +245,7 @@
<bean id="OpenIDVCIBuildErrorResponseFromEvent"
class="org.geant.shibboleth.plugin.openidvci.profile.impl.BuildCredentialErrorResponseFromEvent" scope="prototype"
p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier"
- p:mappedErrors="#{getObject('openidvci.credentials.MappedErrors')}"
+ p:mappedErrors="#{getObject('openidvci.credentials.MappedErrors') ?: getObject('openidvci.credentials.DefaultMappedErrors')}"
p:securityParametersContextLookupStrategy-ref="DPoPSecurityParametersContextProfileRequestContextLookup"
p:algorithmCandidates="%{idp.oauth2.dpop.proofAlgorithms:RS256,RS384,RS512,PS256,PS384,PS512,ES256,ES384,ES512}"
>
diff --git a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credentials/credentials-flow.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credentials/credentials-flow.xml
index e6b328f..69f0dde 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credentials/credentials-flow.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credentials/credentials-flow.xml
@@ -14,6 +14,7 @@
<transition on="proceed" to="DecodeMessage">
<set name="flowScope.transitionAfterDecode" value="'PostDecodeMessage'" />
<set name="flowScope.skipOAuth2ClientAuth" value="true" />
+ <set name="flowScope.transitionAfterInboundIntercept" value="'CallMessageHandler'" />
</transition>
</action-state>
@@ -21,12 +22,17 @@
<evaluate expression="ParseAccessToken" />
<evaluate expression="'proceed'" />
- <transition on="proceed" to="DoMetadataLookup">
- <set name="flowScope.skipOAuth2ClientAuth" value="true" />
- </transition>
+ <transition on="proceed" to="DoMetadataLookup" />
+ </action-state>
+
+ <action-state id="CallMessageHandler">
+ <evaluate expression="CallInboundMessageHandler" />
+ <evaluate expression="'proceed'" />
+ <transition on="proceed" to="DoDPoPProofValidation" />
</action-state>
<action-state id="ResumeAfterDoDPoPProofValidation">
+ <evaluate expression="ValidateClientIDAgainstPolicy" />
<evaluate expression="ValidateAccessTokenBinding" />
<evaluate expression="ValidateRequestedCredential" />
<evaluate expression="ParseProof" />
diff --git a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/service/relying-party/postconfig.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/service/relying-party/postconfig.xml
index 6542287..e4875a9 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/service/relying-party/postconfig.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/service/relying-party/postconfig.xml
@@ -166,9 +166,10 @@
p:customObject-ref="shibboleth.HttpServletRequestSupplier"/>
</property>
</bean>
- <bean class="org.geant.shibboleth.plugin.openidvci.security.impl.DPoPHttpUriClaimsValidator">
- <property name="requestUriLookupStrategy">
- <bean parent="shibboleth.BiFunctions.Expression" c:expression="#custom.get().getRequestURL().toString()"
+ <bean class="org.geant.shibboleth.plugin.openidvci.security.impl.DPoPHttpUriClaimsValidator"
+ p:issuer="#{getObject('shibboleth.oidc.issuer')}">
+ <property name="requestPathLookupStrategy">
+ <bean parent="shibboleth.BiFunctions.Expression" c:expression="#custom.get().getRequestURI()"
p:customObject-ref="shibboleth.HttpServletRequestSupplier"/>
</property>
</bean>
diff --git a/openid-vci-impl/src/main/resources/org/geant/shibboleth/plugin/openidvci/metadata/verifiable-credentials.json b/openid-vci-impl/src/main/resources/org/geant/shibboleth/plugin/openidvci/metadata/verifiable-credentials.json
index 7b52ad0..5fdeba4 100644
--- a/openid-vci-impl/src/main/resources/org/geant/shibboleth/plugin/openidvci/metadata/verifiable-credentials.json
+++ b/openid-vci-impl/src/main/resources/org/geant/shibboleth/plugin/openidvci/metadata/verifiable-credentials.json
@@ -2,7 +2,7 @@
"credential_configurations_supported": {
"GeantIncubatorDiploma_SDJWT": {
"format": "dc+sd-jwt",
- "vct": "GeantIncubatorDiploma_SDJWT",
+ "vct": "https://issuer.example.org/vct/GeantIncubatorDiploma_SDJWT",
"scope": "GeantIncubatorDiploma_SDJWT",
"cryptographic_binding_methods_supported": ["did:jwk", "jwk"],
"credential_signing_alg_values_supported": ["ES256"],
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/credential/impl/SelectiveDisclosureClaimTreeTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/credential/impl/SelectiveDisclosureClaimTreeTest.java
index cabef27..5e0c374 100644
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/credential/impl/SelectiveDisclosureClaimTreeTest.java
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/credential/impl/SelectiveDisclosureClaimTreeTest.java
@@ -68,6 +68,25 @@ public class SelectiveDisclosureClaimTreeTest {
return names;
}
+ @Test
+ public void testPlainClaimIsNotDisclosed() throws Exception {
+ final SelectiveDisclosureClaimTree tree = new SelectiveDisclosureClaimTree(
+ List.of(claim("Person", "type"), claim("John", "given_name"), claim("Anytown", "address", "locality"),
+ claim("US", "address", "country")),
+ List.of(), List.of(List.of("type"), List.of("address", "country")), "sha-256");
+
+ Assert.assertEquals(tree.getClaims().get("type"), "Person");
+ Assert.assertEquals(object(tree.getClaims(), "address").get("country"), "US");
+ Assert.assertEquals(sd(object(tree.getClaims(), "address")).size(), 1);
+ Assert.assertEquals(disclosedNames(tree), Set.of("given_name", "locality"));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testPlainAndDisclosedArrayRefused() throws Exception {
+ new SelectiveDisclosureClaimTree(List.of(claim(List.of("a", "b"), "list")),
+ List.of(List.of("list")), List.of(List.of("list")), "sha-256");
+ }
+
@Test
public void testFlatClaimsAreDisclosedAtRoot() throws Exception {
final SelectiveDisclosureClaimTree tree = new SelectiveDisclosureClaimTree(
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCICredentialsRequestDecoderTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCICredentialsRequestDecoderTest.java
new file mode 100644
index 0000000..ce7ca90
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCICredentialsRequestDecoderTest.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2025, GÉANT
+ *
+ * Licensed under the Apache License, Version 2.0 (the “License”); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://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.
+ */
+
+package org.geant.shibboleth.plugin.openidvci.decoding.impl;
+
+import java.nio.charset.StandardCharsets;
+
+import org.geant.shibboleth.plugin.openidvci.messaging.impl.OpenIDVCICredentialsRequest;
+import org.opensaml.messaging.decoder.MessageDecodingException;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import jakarta.servlet.http.HttpServletRequest;
+import net.shibboleth.shared.primitive.NonnullSupplier;
+
+/**
+ * Unit tests for {@link OpenIDVCICredentialsRequestDecoder}.
+ */
+public class OpenIDVCICredentialsRequestDecoderTest {
+
+ private MockHttpServletRequest httpRequest;
+
+ private OpenIDVCICredentialsRequestDecoder decoder;
+
+ @BeforeMethod
+ protected void setUp() throws Exception {
+ httpRequest = new MockHttpServletRequest();
+ httpRequest.setMethod("POST");
+ httpRequest.setRequestURI("/idp/profile/openid/vci/credentials");
+ httpRequest.addHeader("Content-Type", "application/json");
+ httpRequest.addHeader("Authorization", "Bearer dGVzdDp0ZXN0");
+ httpRequest.setContent("{\"credential_identifier\":\"degree-1\"}".getBytes(StandardCharsets.UTF_8));
+ decoder = new OpenIDVCICredentialsRequestDecoder();
+ decoder.setHttpServletRequestSupplier(new NonnullSupplier<>() {
+ public HttpServletRequest get() {
+ return httpRequest;
+ }
+ });
+ decoder.initialize();
+ }
+
+ @Test
+ public void testIdentifierLogged() throws MessageDecodingException {
+ decoder.decode();
+ final String logged =
+ decoder.getMessageToLog((OpenIDVCICredentialsRequest) decoder.getMessageContext().getMessage());
+ Assert.assertTrue(logged.contains("credential_identifier=degree-1"), logged);
+ Assert.assertFalse(logged.contains("credential_configuration_id"), logged);
+ }
+
+ @Test(expectedExceptions = MessageDecodingException.class)
+ public void testProofsNotObject() throws MessageDecodingException {
+ httpRequest.setContent(
+ "{\"credential_identifier\":\"degree-1\",\"proofs\":[]}".getBytes(StandardCharsets.UTF_8));
+ decoder.decode();
+ }
+
+}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/messaging/impl/OpenIDVCICredentialsRequestTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/messaging/impl/OpenIDVCICredentialsRequestTest.java
index 9841284..52b4f6b 100644
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/messaging/impl/OpenIDVCICredentialsRequestTest.java
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/messaging/impl/OpenIDVCICredentialsRequestTest.java
@@ -75,18 +75,54 @@ public class OpenIDVCICredentialsRequestTest {
Assert.assertEquals(request.getAccessToken().getValue(), "dGVzdDp0ZXN0");
}
- @Test(expectedExceptions = ParseException.class)
- public void failTokenInQuery() throws Exception {
+ @Test
+ public void tokenInQueryIgnored() throws Exception {
final HTTPRequest queryRequest = new HTTPRequest(HTTPRequest.Method.POST,
new URI("http://example.com?access_token=dGVzdDp0ZXN0"));
queryRequest.setContentType("application/json");
queryRequest.setBody("{\"credential_configuration_id\": \"org.iso.18013.5.1.mDL\"}");
- OpenIDVCICredentialsRequest.parse(queryRequest);
+ Assert.assertNull(OpenIDVCICredentialsRequest.parse(queryRequest).getAccessToken());
}
- @Test(expectedExceptions = ParseException.class)
- public void failNoToken() throws ParseException {
+ @Test
+ public void noToken() throws ParseException {
httpRequest.setAuthorization(null);
+ Assert.assertNull(OpenIDVCICredentialsRequest.parse(httpRequest).getAccessToken());
+ }
+
+ @Test
+ public void otherAuthorizationScheme() throws ParseException {
+ httpRequest.setAuthorization("Basic dGVzdDp0ZXN0");
+ Assert.assertNull(OpenIDVCICredentialsRequest.parse(httpRequest).getAccessToken());
+ }
+
+ @Test
+ public void bearerWithoutValue() throws ParseException {
+ httpRequest.setAuthorization("Bearer");
+ Assert.assertNull(OpenIDVCICredentialsRequest.parse(httpRequest).getAccessToken());
+ }
+
+ @Test(expectedExceptions = ParseException.class)
+ public void failProofsNotObject() throws ParseException {
+ httpRequest.setBody("{\"credential_configuration_id\": \"a\", \"proofs\": [\"jwt\"]}");
+ OpenIDVCICredentialsRequest.parse(httpRequest);
+ }
+
+ @Test(expectedExceptions = ParseException.class)
+ public void failResponseEncryptionNotObject() throws ParseException {
+ httpRequest.setBody("{\"credential_configuration_id\": \"a\", \"credential_response_encryption\": \"x\"}");
+ OpenIDVCICredentialsRequest.parse(httpRequest);
+ }
+
+ @Test(expectedExceptions = ParseException.class)
+ public void failEmptyBody() throws ParseException {
+ httpRequest.setBody(null);
+ OpenIDVCICredentialsRequest.parse(httpRequest);
+ }
+
+ @Test(expectedExceptions = ParseException.class)
+ public void failBodyJsonArray() throws ParseException {
+ httpRequest.setBody("[]");
OpenIDVCICredentialsRequest.parse(httpRequest);
}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/config/impl/DefaultOpenIDVCICredentialsConfigurationTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/config/impl/DefaultOpenIDVCICredentialsConfigurationTest.java
new file mode 100644
index 0000000..284ae8b
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/config/impl/DefaultOpenIDVCICredentialsConfigurationTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025, GÉANT
+ *
+ * Licensed under the Apache License, Version 2.0 (the “License”); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://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.
+ */
+
+package org.geant.shibboleth.plugin.openidvci.profile.config.impl;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/** Tests for {@link DefaultOpenIDVCICredentialsConfiguration}. */
+public class DefaultOpenIDVCICredentialsConfigurationTest {
+
+ @Test
+ public void testId() {
+ Assert.assertEquals(new DefaultOpenIDVCICredentialsConfiguration().getId(),
+ "http://geant.org/ns/profiles/openid/vci/credentials");
+ }
+
+ @Test
+ public void testCounter() {
+ Assert.assertEquals(DefaultOpenIDVCICredentialsConfiguration.PROFILE_COUNTER,
+ "net.shibboleth.idp.profiles.openid.vci.credentials");
+ }
+
+}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AddCredentialShellTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AddCredentialShellTest.java
index fb99944..469b674 100644
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AddCredentialShellTest.java
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AddCredentialShellTest.java
@@ -26,6 +26,7 @@ import org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds;
import org.geant.shibboleth.plugin.openidvci.profile.config.impl.DefaultOpenIDVCICredentialsConfiguration;
import org.geant.shibboleth.plugin.openidvci.security.impl.DidSupport;
import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.profile.action.EventIds;
import org.opensaml.profile.context.ProfileRequestContext;
import org.springframework.webflow.execution.RequestContext;
import org.testng.Assert;
@@ -117,6 +118,12 @@ public class AddCredentialShellTest {
holderKey.computeThumbprint());
}
+ @Test
+ public void testNoCredentialsContext() throws Exception {
+ profileRequestCtx.getInboundMessageContext().removeSubcontext(CredentialsContext.class);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_PROFILE_CTX);
+ }
+
@Test
public void testDidJwkAdvertisedKeepsKid() throws Exception {
configuration("[\"did:jwk\",\"jwk\"]");
@@ -156,6 +163,25 @@ public class AddCredentialShellTest {
Assert.assertEquals(cnf(), Map.of("kid", didJwk));
}
+ @Test
+ public void testNotBeforeOnSdJwtVc() throws Exception {
+ configuration(null);
+ credentialsCtx.setNotBefore(credentialsCtx.getIssuedAt().plusSeconds(60));
+ ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
+ Assert.assertNotNull(credentialsCtx.getCredentialShells().get(0).getClaim("nbf"));
+ }
+
+ @Test
+ public void testNoNotBeforeOnVcdm() throws Exception {
+ credentialsCtx.setCredentialConfiguration(new ObjectMapper().readValue("{\"format\":\"vc+sd-jwt\","
+ + "\"credential_definition\":{\"@context\":[\"https://www.w3.org/ns/credentials/v2\"],"
+ + "\"type\":[\"VerifiableCredential\"]}}", CredentialConfiguration.class));
+ credentialsCtx.setNotBefore(credentialsCtx.getIssuedAt().plusSeconds(60));
+ ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
+ Assert.assertNull(credentialsCtx.getCredentialShells().get(0).getClaim("nbf"));
+ Assert.assertNotNull(credentialsCtx.getCredentialShells().get(0).getClaim("validFrom"));
+ }
+
@Test
public void testAttestedKeyIsJwk() throws Exception {
configuration("[\"jwk\"]");
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/BuildCredentialErrorResponseFromEventTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/BuildCredentialErrorResponseFromEventTest.java
new file mode 100644
index 0000000..30693da
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/BuildCredentialErrorResponseFromEventTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2025, GÉANT
+ *
+ * Licensed under the Apache License, Version 2.0 (the “License”); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://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.
+ */
+
+package org.geant.shibboleth.plugin.openidvci.profile.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.geant.shibboleth.plugin.openidvci.messaging.impl.CredentialErrorResponse;
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.profile.context.EventContext;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.nimbusds.oauth2.sdk.OAuth2Error;
+import com.nimbusds.oauth2.sdk.token.DPoPTokenError;
+
+import net.shibboleth.oidc.profile.core.OidcEventIds;
+import net.shibboleth.oidc.security.jose.context.SecurityParametersContext;
+
+/**
+ * Unit tests for {@link BuildCredentialErrorResponseFromEvent}.
+ */
+public class BuildCredentialErrorResponseFromEventTest {
+
+ private ProfileRequestContext prc;
+
+ private BuildCredentialErrorResponseFromEvent action;
+
+ @BeforeMethod
+ protected void setUp() {
+ prc = new ProfileRequestContext();
+ prc.setOutboundMessageContext(new MessageContext());
+ action = new BuildCredentialErrorResponseFromEvent(null);
+ action.setMappedErrors(Map.of(OidcEventIds.INVALID_DPOP_PROOF, DPoPTokenError.INVALID_DPOP_PROOF,
+ OidcEventIds.INVALID_ACCESS_TOKEN, OAuth2Error.INVALID_GRANT));
+ action.setAlgorithmCandidates(List.of("ES256"));
+ }
+
+ private CredentialErrorResponse execute(final String event) throws Exception {
+ action.initialize();
+ prc.ensureSubcontext(EventContext.class).setEvent(event);
+ action.execute(prc);
+ return (CredentialErrorResponse) prc.getOutboundMessageContext().getMessage();
+ }
+
+ @Test
+ public void testDPoPErrorWithoutSecurityParameters() throws Exception {
+ action.setSecurityParametersContextLookupStrategy(input -> null);
+ final CredentialErrorResponse response = execute(OidcEventIds.INVALID_DPOP_PROOF);
+ Assert.assertEquals(response.getErrorObject().getCode(), DPoPTokenError.INVALID_DPOP_PROOF.getCode());
+ Assert.assertEquals(response.getErrorObject().getHTTPStatusCode(), 401);
+ }
+
+ @Test
+ public void testDPoPErrorWithoutValidationParameters() throws Exception {
+ action.setSecurityParametersContextLookupStrategy(input -> new SecurityParametersContext());
+ final CredentialErrorResponse response = execute(OidcEventIds.INVALID_DPOP_PROOF);
+ Assert.assertEquals(response.getErrorObject().getCode(), DPoPTokenError.INVALID_DPOP_PROOF.getCode());
+ }
+
+ @Test
+ public void testOtherError() throws Exception {
+ action.setSecurityParametersContextLookupStrategy(input -> null);
+ final CredentialErrorResponse response = execute(OidcEventIds.INVALID_ACCESS_TOKEN);
+ Assert.assertEquals(response.getErrorObject().getCode(), OAuth2Error.INVALID_GRANT.getCode());
+ }
+
+}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormJsonLdSelectiveDisclosureJWTCredentialTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormJsonLdSelectiveDisclosureJWTCredentialTest.java
new file mode 100644
index 0000000..ba3292d
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormJsonLdSelectiveDisclosureJWTCredentialTest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2025, GÉANT
+ *
+ * Licensed under the Apache License, Version 2.0 (the “License”); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://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.
+ */
+
+package org.geant.shibboleth.plugin.openidvci.profile.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.geant.shibboleth.plugin.openidvci.credential.CredentialConfiguration;
+import org.geant.shibboleth.plugin.openidvci.messaging.context.CredentialsContext;
+import org.geant.shibboleth.plugin.openidvci.messaging.impl.CredentialOfferRequestedCredential;
+import org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds;
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.springframework.webflow.execution.RequestContext;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.nimbusds.oauth2.sdk.id.Issuer;
+import com.nimbusds.openid.connect.sdk.claims.ClaimsSet;
+
+import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
+import net.shibboleth.idp.profile.testing.ActionTestingSupport;
+import net.shibboleth.idp.profile.testing.RequestContextBuilder;
+
+/**
+ * Unit tests for {@link FormJsonLdSelectiveDisclosureJWTCredential}.
+ */
+public class FormJsonLdSelectiveDisclosureJWTCredentialTest {
+
+ private RequestContext requestCtx;
+
+ private CredentialsContext credentialsCtx;
+
+ private FormJsonLdSelectiveDisclosureJWTCredential action;
+
+ @BeforeMethod
+ protected void setUp() throws Exception {
+ requestCtx = new RequestContextBuilder().buildRequestContext();
+ final ProfileRequestContext profileRequestCtx =
+ new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
+ profileRequestCtx.setInboundMessageContext(new MessageContext());
+ credentialsCtx = profileRequestCtx.getInboundMessageContext().ensureSubcontext(CredentialsContext.class);
+ credentialsCtx.setCredentialConfiguration(CredentialConfiguration.parse("{\"format\":\"vc+sd-jwt\","
+ + "\"credential_definition\":{\"@context\":[\"https://www.w3.org/ns/credentials/v2\"],"
+ + "\"type\":[\"VerifiableCredential\"]}}"));
+ action = new FormJsonLdSelectiveDisclosureJWTCredential();
+ action.initialize();
+ }
+
+ @Test
+ public void testIssuerFromShell() throws Exception {
+ final ClaimsSet shell = new ClaimsSet();
+ shell.setIssuer(new Issuer("https://issuer.example.org"));
+ credentialsCtx.setCredentialShells(List.of(shell));
+ credentialsCtx.setCredentialContent(
+ CredentialOfferRequestedCredential.parse("[{\"path\":[\"mail\"],\"value\":\"a at example.org\"}]"));
+ ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
+ Assert.assertEquals(credentialsCtx.getJWTCredentials().get(0).getClaim("issuer"),
+ "https://issuer.example.org");
+ }
+
+ @Test
+ public void testNeverDisclosedType() throws Exception {
+ credentialsCtx.setCredentialConfiguration(CredentialConfiguration.parse("{\"format\":\"vc+sd-jwt\","
+ + "\"credential_definition\":{\"@context\":[\"https://www.w3.org/ns/credentials/v2\"],"
+ + "\"type\":[\"VerifiableCredential\"]},\"_issuance_configuration\":{\"sd\":["
+ + "{\"path\":[\"credentialSubject\",\"type\"],\"sd\":\"never\"}]}}"));
+ final ClaimsSet shell = new ClaimsSet();
+ shell.setIssuer(new Issuer("https://issuer.example.org"));
+ credentialsCtx.setCredentialShells(List.of(shell));
+ credentialsCtx.setCredentialContent(CredentialOfferRequestedCredential.parse(
+ "[{\"path\":[\"type\"],\"value\":\"Person\"},{\"path\":[\"mail\"],\"value\":\"a at example.org\"}]"));
+ ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
+ final Map<String, Object> subject =
+ credentialsCtx.getJWTCredentials().get(0).getJSONObjectClaim("credentialSubject");
+ Assert.assertEquals(subject.get("type"), "Person");
+ Assert.assertEquals(credentialsCtx.getDisclosures().get(0).split("~").length, 1);
+ }
+
+ @Test
+ public void testNoContent() {
+ credentialsCtx.setCredentialShells(List.of(new ClaimsSet()));
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.INVALID_CREDENTIAL);
+ }
+
+ @Test
+ public void testNoShells() throws Exception {
+ credentialsCtx.setCredentialContent(
+ CredentialOfferRequestedCredential.parse("[{\"path\":[\"mail\"],\"value\":\"a at example.org\"}]"));
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.INVALID_CREDENTIAL);
+ }
+
+}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormSelectiveDisclosureJWTCredentialTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormSelectiveDisclosureJWTCredentialTest.java
new file mode 100644
index 0000000..e5811d9
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormSelectiveDisclosureJWTCredentialTest.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2025, GÉANT
+ *
+ * Licensed under the Apache License, Version 2.0 (the “License”); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://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.
+ */
+
+package org.geant.shibboleth.plugin.openidvci.profile.impl;
+
+import java.util.List;
+
+import org.geant.shibboleth.plugin.openidvci.credential.CredentialConfiguration;
+import org.geant.shibboleth.plugin.openidvci.messaging.context.CredentialsContext;
+import org.geant.shibboleth.plugin.openidvci.messaging.impl.CredentialOfferRequestedCredential;
+import org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds;
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.springframework.webflow.execution.RequestContext;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.nimbusds.oauth2.sdk.id.Issuer;
+import com.nimbusds.openid.connect.sdk.claims.ClaimsSet;
+
+import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
+import net.shibboleth.idp.profile.testing.ActionTestingSupport;
+import net.shibboleth.idp.profile.testing.RequestContextBuilder;
+
+/**
+ * Unit tests for {@link FormSelectiveDisclosureJWTCredential}.
+ */
+public class FormSelectiveDisclosureJWTCredentialTest {
+
+ private RequestContext requestCtx;
+
+ private CredentialsContext credentialsCtx;
+
+ private FormSelectiveDisclosureJWTCredential action;
+
+ @BeforeMethod
+ protected void setUp() throws Exception {
+ requestCtx = new RequestContextBuilder().buildRequestContext();
+ final ProfileRequestContext profileRequestCtx =
+ new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
+ profileRequestCtx.setInboundMessageContext(new MessageContext());
+ credentialsCtx = profileRequestCtx.getInboundMessageContext().ensureSubcontext(CredentialsContext.class);
+ credentialsCtx.setCredentialConfiguration(
+ CredentialConfiguration.parse("{\"format\":\"dc+sd-jwt\",\"vct\":\"Diploma\"}"));
+ action = new FormSelectiveDisclosureJWTCredential();
+ action.initialize();
+ }
+
+ @Test
+ public void testReservedClaimNotDisclosed() throws Exception {
+ final ClaimsSet shell = new ClaimsSet();
+ shell.setIssuer(new Issuer("https://issuer.example.org"));
+ shell.setClaim("vct", "https://issuer.example.org/vct/Diploma");
+ credentialsCtx.setCredentialShells(List.of(shell));
+ credentialsCtx.setCredentialContent(CredentialOfferRequestedCredential.parse(
+ "[{\"path\":[\"iss\"],\"value\":\"https://evil.example\"},"
+ + "{\"path\":[\"vct\"],\"value\":\"Other\"},"
+ + "{\"path\":[\"mail\"],\"value\":\"a at example.org\"}]"));
+ action = new FormSelectiveDisclosureJWTCredential();
+ action.setReservedClaimNames(List.of("iss", "vct"));
+ action.initialize();
+ ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
+ Assert.assertEquals(credentialsCtx.getJWTCredentials().get(0).getIssuer(), "https://issuer.example.org");
+ Assert.assertEquals(credentialsCtx.getJWTCredentials().get(0).getClaim("vct"),
+ "https://issuer.example.org/vct/Diploma");
+ final String disclosures = credentialsCtx.getDisclosures().get(0);
+ Assert.assertEquals(disclosures.split("~").length, 1);
+ }
+
+ @Test
+ public void testNoContent() {
+ credentialsCtx.setCredentialShells(List.of(new ClaimsSet()));
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.INVALID_CREDENTIAL);
+ }
+
+ @Test
+ public void testNoShells() throws Exception {
+ credentialsCtx.setCredentialContent(
+ CredentialOfferRequestedCredential.parse("[{\"path\":[\"mail\"],\"value\":\"a at example.org\"}]"));
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.INVALID_CREDENTIAL);
+ }
+
+}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseAccessTokenTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseAccessTokenTest.java
new file mode 100644
index 0000000..8dc591e
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseAccessTokenTest.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2025, GÉANT
+ *
+ * Licensed under the Apache License, Version 2.0 (the “License”); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://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.
+ */
+
+package org.geant.shibboleth.plugin.openidvci.profile.impl;
+
+import java.net.URI;
+import java.time.Instant;
+
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+
+import org.geant.shibboleth.plugin.openidvci.messaging.impl.OpenIDVCICredentialsRequest;
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.springframework.webflow.execution.RequestContext;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.nimbusds.oauth2.sdk.http.HTTPRequest;
+import com.nimbusds.oauth2.sdk.id.ClientID;
+
+import net.shibboleth.idp.plugin.oidc.op.messaging.context.OIDCAuthenticationResponseContext;
+import net.shibboleth.idp.plugin.oidc.op.token.support.AccessTokenClaimsSet;
+import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
+import net.shibboleth.idp.profile.testing.ActionTestingSupport;
+import net.shibboleth.idp.profile.testing.RequestContextBuilder;
+import net.shibboleth.oidc.profile.core.OidcEventIds;
+import net.shibboleth.shared.collection.Pair;
+import net.shibboleth.shared.logic.PredicateSupport;
+import net.shibboleth.shared.security.DataSealer;
+import net.shibboleth.shared.security.DataSealerKeyStrategy;
+
+/**
+ * Unit tests for {@link ParseAccessToken}.
+ */
+public class ParseAccessTokenTest {
+
+ private DataSealer sealer;
+
+ private RequestContext requestCtx;
+
+ private ProfileRequestContext profileRequestCtx;
+
+ private ParseAccessToken action;
+
+ @BeforeMethod
+ protected void setUp() throws Exception {
+ final KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
+ keyGenerator.init(128);
+ sealer = new DataSealer();
+ sealer.setKeyStrategy(new FixedKeyStrategy(keyGenerator.generateKey()));
+ sealer.initialize();
+ requestCtx = new RequestContextBuilder().buildRequestContext();
+ profileRequestCtx = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
+ profileRequestCtx.setInboundMessageContext(new MessageContext());
+ profileRequestCtx.setOutboundMessageContext(new MessageContext());
+ profileRequestCtx.getOutboundMessageContext().ensureSubcontext(OIDCAuthenticationResponseContext.class);
+ action = new ParseAccessToken();
+ action.setDataSealer(sealer);
+ action.setDpopAccessTokenCondition(PredicateSupport.alwaysFalse());
+ }
+
+ @AfterMethod
+ protected void tearDown() {
+ sealer.destroy();
+ }
+
+ private void setRequest(final String authorization) throws Exception {
+ final HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.POST,
+ new URI("https://issuer.example.org/idp/profile/openid/vci/credentials"));
+ if (authorization != null) {
+ httpRequest.setAuthorization(authorization);
+ }
+ httpRequest.setContentType("application/json");
+ httpRequest.setBody("{\"credential_configuration_id\":\"GeantIncubatorDiploma\"}");
+ profileRequestCtx.getInboundMessageContext().setMessage(OpenIDVCICredentialsRequest.parse(httpRequest));
+ }
+
+ private String token(final Instant expiresAt) throws Exception {
+ return new AccessTokenClaimsSet.Builder().setJWTID("jti").setClientID(new ClientID("client"))
+ .setIssuer("https://issuer.example.org").setPrincipal("principal").setSubject("subject")
+ .setIssuedAt(Instant.now().minusSeconds(120)).setExpiresAt(expiresAt)
+ .setAuthenticationTime(Instant.now().minusSeconds(120)).build().serialize(sealer);
+ }
+
+ @Test
+ public void testValidToken() throws Exception {
+ action.initialize();
+ setRequest("Bearer " + token(Instant.now().plusSeconds(60)));
+ ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
+ }
+
+ @Test
+ public void testNoToken() throws Exception {
+ action.initialize();
+ setRequest(null);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OidcEventIds.INVALID_ACCESS_TOKEN);
+ }
+
+ @Test
+ public void testNoTokenDPoP() throws Exception {
+ action.setDpopAccessTokenCondition(PredicateSupport.alwaysTrue());
+ action.initialize();
+ setRequest(null);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OidcEventIds.INVALID_DPOP_ACCESS_TOKEN);
+ }
+
+ @Test
+ public void testGarbageToken() throws Exception {
+ action.initialize();
+ setRequest("Bearer bm90LWEtdG9rZW4");
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OidcEventIds.INVALID_ACCESS_TOKEN);
+ }
+
+ @Test
+ public void testExpiredToken() throws Exception {
+ action.initialize();
+ setRequest("Bearer " + token(Instant.now().minusSeconds(60)));
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OidcEventIds.INVALID_ACCESS_TOKEN);
+ }
+
+ /** Key strategy of one fixed key. */
+ private static class FixedKeyStrategy implements DataSealerKeyStrategy {
+
+ private final SecretKey key;
+
+ FixedKeyStrategy(final SecretKey secretKey) {
+ key = secretKey;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @SuppressWarnings("removal")
+ public Pair<String, SecretKey> getDefaultKey() {
+ return new Pair<>("default", key);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public NamedKey getDefaultKeyRecord() {
+ return new NamedKey("default", key);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public SecretKey getKey(final String name) {
+ return key;
+ }
+ }
+
+}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseProofTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseProofTest.java
index aa76d34..a45e7a2 100644
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseProofTest.java
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ParseProofTest.java
@@ -18,12 +18,19 @@ package org.geant.shibboleth.plugin.openidvci.profile.impl;
import java.net.URI;
import java.time.Duration;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Nonnull;
import org.geant.shibboleth.plugin.openidvci.credential.CredentialConfiguration;
import org.geant.shibboleth.plugin.openidvci.messaging.context.CredentialsContext;
import org.geant.shibboleth.plugin.openidvci.messaging.impl.OpenIDVCICredentialsRequest;
import org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds;
import org.geant.shibboleth.plugin.openidvci.profile.config.impl.DefaultOpenIDVCICredentialsConfiguration;
+import org.geant.shibboleth.plugin.openidvci.credential.KeyAttestationsRequired;
+import org.geant.shibboleth.plugin.openidvci.security.impl.DidSupport;
+import org.geant.shibboleth.plugin.openidvci.security.impl.KeyAttestationValidator;
import org.opensaml.messaging.context.MessageContext;
import org.opensaml.profile.context.ProfileRequestContext;
import org.springframework.webflow.execution.RequestContext;
@@ -32,13 +39,28 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.nimbusds.jose.JOSEObjectType;
+import com.nimbusds.jose.JWSAlgorithm;
+import com.nimbusds.jose.JWSHeader;
+import com.nimbusds.jose.crypto.ECDSASigner;
+import com.nimbusds.jose.jwk.Curve;
+import com.nimbusds.jose.jwk.ECKey;
+import com.nimbusds.jose.jwk.JWK;
+import com.nimbusds.jose.jwk.gen.ECKeyGenerator;
+import com.nimbusds.jose.util.Base64;
+import com.nimbusds.jwt.JWTClaimsSet;
+import com.nimbusds.jwt.SignedJWT;
import com.nimbusds.oauth2.sdk.ParseException;
import com.nimbusds.oauth2.sdk.http.HTTPRequest;
+import net.shibboleth.idp.plugin.oidc.op.security.jwt.claims.impl.DPoPProofNonceJWTValidationException;
import net.shibboleth.idp.profile.IdPEventIds;
import net.shibboleth.idp.profile.testing.ActionTestingSupport;
import net.shibboleth.idp.profile.testing.RequestContextBuilder;
import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
+import net.shibboleth.oidc.jwt.claims.AbstractClaimsValidator;
+import net.shibboleth.oidc.jwt.claims.ClaimsValidator;
+import net.shibboleth.oidc.jwt.claims.JWTValidationException;
import net.shibboleth.profile.context.RelyingPartyContext;
/**
@@ -188,6 +210,117 @@ public class ParseProofTest {
ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.INVALID_PROOF);
}
+ @Test
+ public void testMissingTyp() throws Exception {
+ setProofs(proof(new JWSHeader.Builder(JWSAlgorithm.ES256).jwk(key().toPublicJWK()).build(), "n"));
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.INVALID_PROOF);
+ }
+
+ @Test
+ public void testX5cProof() throws Exception {
+ setProofs(proof(new JWSHeader.Builder(JWSAlgorithm.ES256).type(new JOSEObjectType("openid4vci-proof+jwt"))
+ .x509CertChain(List.of(Base64.encode("certificate"))).build(), "n"));
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.INVALID_PROOF);
+ }
+
+ @Test
+ public void testDidWebKid() throws Exception {
+ setProofs(proof(new JWSHeader.Builder(JWSAlgorithm.ES256).type(new JOSEObjectType("openid4vci-proof+jwt"))
+ .keyID("did:web:wallet.example.org#key-1").build(), "n"));
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.INVALID_PROOF);
+ }
+
+ @Test
+ public void testDidJwkKid() throws Exception {
+ final ECKey holder = key();
+ setProofs(proof(new JWSHeader.Builder(JWSAlgorithm.ES256).type(new JOSEObjectType("openid4vci-proof+jwt"))
+ .keyID(DidSupport.toDidJwk(holder.toECPublicKey()) + "#0").build(), "n"));
+ ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
+ }
+
+ @Test
+ public void testMissingNonce() throws Exception {
+ configuration.setProofClaimsValidator(nonceValidator(false));
+ setProofs(proof(proofHeader(), null));
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.INVALID_PROOF);
+ }
+
+ @Test
+ public void testInvalidNonce() throws Exception {
+ configuration.setProofClaimsValidator(nonceValidator(true));
+ setProofs(proof(proofHeader(), "n"));
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.INVALID_NONCE);
+ }
+
+ @Test
+ public void testAttestationProofWithoutNonce() throws Exception {
+ profileRequestCtx.getInboundMessageContext().ensureSubcontext(CredentialsContext.class)
+ .setCredentialConfiguration(new ObjectMapper()
+ .readValue("{\"format\":\"dc+sd-jwt\",\"vct\":\"TestCredential\","
+ + "\"proof_types_supported\":{\"attestation\":{\"proof_signing_alg_values_supported\":"
+ + "[\"ES256\"],\"key_attestations_required\":{}}}}",
+ CredentialConfiguration.class));
+ final ParseProof attestationAction = new ParseProof();
+ attestationAction.setKeyAttestationValidator(new KeyAttestationValidator() {
+ @Override
+ @Nonnull
+ public List<JWK> validate(@Nonnull final ProfileRequestContext prc, @Nonnull final SignedJWT attestation,
+ final KeyAttestationsRequired required, final ClaimsValidator claimsValidator,
+ final boolean expirationRequired) throws JWTValidationException {
+ throw new DPoPProofNonceJWTValidationException("Mandatory value is missing");
+ }
+ });
+ attestationAction.initialize();
+ httpRequest.setBody("{\"credential_configuration_id\":\"a\",\"proofs\":{\"attestation\":[\""
+ + proof(new JWSHeader.Builder(JWSAlgorithm.ES256).type(new JOSEObjectType("key-attestation+jwt"))
+ .build(), null) + "\"]}}");
+ profileRequestCtx.getInboundMessageContext().setMessage(OpenIDVCICredentialsRequest.parse(httpRequest));
+ ActionTestingSupport.assertEvent(attestationAction.execute(requestCtx), OpenIDVCIEventIds.INVALID_PROOF);
+ }
+
+ private ECKey key() throws Exception {
+ return new ECKeyGenerator(Curve.P_256).generate();
+ }
+
+ private JWSHeader proofHeader() throws Exception {
+ return new JWSHeader.Builder(JWSAlgorithm.ES256).type(new JOSEObjectType("openid4vci-proof+jwt"))
+ .jwk(key().toPublicJWK()).build();
+ }
+
+ private String proof(final JWSHeader header, final String nonce) throws Exception {
+ final JWTClaimsSet.Builder claims = new JWTClaimsSet.Builder().audience("https://issuer.example.org")
+ .issueTime(new Date());
+ if (nonce != null) {
+ claims.claim("nonce", nonce);
+ }
+ final SignedJWT jwt = new SignedJWT(header, claims.build());
+ jwt.sign(new ECDSASigner(key()));
+ return jwt.serialize();
+ }
+
+ private void setProofs(final String proof) throws Exception {
+ httpRequest.setBody("{\"credential_configuration_id\":\"a\",\"proofs\":{\"jwt\":[\"" + proof + "\"]}}");
+ profileRequestCtx.getInboundMessageContext().setMessage(OpenIDVCICredentialsRequest.parse(httpRequest));
+ }
+
+ private ClaimsValidator nonceValidator(final boolean rejectNonce) throws Exception {
+ final AbstractClaimsValidator validator = new AbstractClaimsValidator() {
+ @Override
+ protected void doValidate(@Nonnull final JWTClaimsSet claims, @Nonnull final ProfileRequestContext prc)
+ throws JWTValidationException {
+ if (claims.getClaim("nonce") == null) {
+ throw new DPoPProofNonceJWTValidationException("Mandatory value is missing");
+ }
+ if (rejectNonce) {
+ throw new DPoPProofNonceJWTValidationException("Value is expired");
+ }
+ }
+ };
+ validator.setId("nonce");
+ validator.initialize();
+ return validator;
+ }
+
@Test
public void testNoInboundMsgCtx() {
profileRequestCtx.setInboundMessageContext(null);
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/SignJWTCredentialTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/SignJWTCredentialTest.java
new file mode 100644
index 0000000..67fcb65
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/SignJWTCredentialTest.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2025, GÉANT
+ *
+ * Licensed under the Apache License, Version 2.0 (the “License”); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://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.
+ */
+
+package org.geant.shibboleth.plugin.openidvci.profile.impl;
+
+import org.geant.shibboleth.plugin.openidvci.messaging.context.CredentialsContext;
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.profile.action.EventIds;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.springframework.webflow.execution.RequestContext;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import net.shibboleth.idp.plugin.oidc.op.messaging.context.OIDCAuthenticationResponseContext;
+import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
+import net.shibboleth.idp.profile.testing.ActionTestingSupport;
+import net.shibboleth.idp.profile.testing.RequestContextBuilder;
+import net.shibboleth.oidc.security.jose.SignatureSigningParameters;
+import net.shibboleth.oidc.security.jose.context.SecurityParametersContext;
+
+/**
+ * Unit tests for {@link SignJWTCredential}.
+ */
+public class SignJWTCredentialTest {
+
+ private RequestContext requestCtx;
+
+ private ProfileRequestContext profileRequestCtx;
+
+ private SignJWTCredential action;
+
+ @BeforeMethod
+ protected void setUp() throws Exception {
+ requestCtx = new RequestContextBuilder().buildRequestContext();
+ profileRequestCtx = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
+ profileRequestCtx.setInboundMessageContext(new MessageContext());
+ profileRequestCtx.getInboundMessageContext().ensureSubcontext(CredentialsContext.class);
+ profileRequestCtx.setOutboundMessageContext(new MessageContext());
+ profileRequestCtx.getOutboundMessageContext().ensureSubcontext(OIDCAuthenticationResponseContext.class);
+ action = new SignJWTCredential();
+ action.initialize();
+ }
+
+ @Test
+ public void testNoSecurityParameters() {
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_SEC_CFG);
+ }
+
+ @Test
+ public void testNoSigningParameters() {
+ profileRequestCtx.getOutboundMessageContext().ensureSubcontext(SecurityParametersContext.class);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_SEC_CFG);
+ }
+
+ @Test
+ public void testNoSigningCredential() {
+ profileRequestCtx.getOutboundMessageContext().ensureSubcontext(SecurityParametersContext.class)
+ .setSignatureSigningParameters(new SignatureSigningParameters());
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_SEC_CFG);
+ }
+
+}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateExpectedGrantTypeTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateExpectedGrantTypeTest.java
deleted file mode 100644
index 751246e..0000000
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateExpectedGrantTypeTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2025, GÉANT
- *
- * Licensed under the Apache License, Version 2.0 (the “License”); you may not
- * use this file except in compliance with the License. You may obtain a copy
- * of the License at
- *
- * http://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.
- */
-
-package org.geant.shibboleth.plugin.openidvci.profile.impl;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.geant.shibboleth.plugin.openidvci.messaging.impl.OpenIDVCITokenRequest;
-import org.opensaml.messaging.context.MessageContext;
-import org.opensaml.profile.action.EventIds;
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.springframework.webflow.execution.RequestContext;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import com.nimbusds.oauth2.sdk.GrantType;
-import com.nimbusds.oauth2.sdk.ParseException;
-import com.nimbusds.oauth2.sdk.id.ClientID;
-import com.nimbusds.openid.connect.sdk.rp.OIDCClientInformation;
-import com.nimbusds.openid.connect.sdk.rp.OIDCClientMetadata;
-
-import net.shibboleth.idp.profile.testing.ActionTestingSupport;
-import net.shibboleth.idp.profile.testing.RequestContextBuilder;
-import net.shibboleth.oidc.metadata.context.OIDCMetadataContext;
-import net.shibboleth.oidc.profile.core.OidcEventIds;
-import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
-
-/**
- * Unit tests for {@link ValidateExpectedGrantType}.
- */
-public class ValidateExpectedGrantTypeTest {
-
-
- protected RequestContext requestCtx;
-
- protected ProfileRequestContext profileRequestCtx;
-
- private ValidateExpectedGrantType action;
-
- private OIDCClientMetadata metaData;
-
- @BeforeMethod
- protected void setUp() throws Exception {
- requestCtx = new RequestContextBuilder().buildRequestContext();
- profileRequestCtx = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
- action = new ValidateExpectedGrantType();
- action.initialize();
- profileRequestCtx.setInboundMessageContext(new MessageContext());
- OIDCMetadataContext oidcCtx =
- (OIDCMetadataContext) profileRequestCtx.getInboundMessageContext().addSubcontext(new OIDCMetadataContext(), true);
- metaData = new OIDCClientMetadata();
- Set<GrantType> grantTypes = new HashSet<GrantType>();
- grantTypes.add(GrantType.parse("refresh_token"));
- grantTypes.add(GrantType.parse(OpenIDVCITokenRequest.GRANT_TYPE_VALUE_PRE_AUTH));
- metaData.setGrantTypes(grantTypes);
- OIDCClientInformation information =
- new OIDCClientInformation(new ClientID("test"), null, metaData, null, null, null);
- oidcCtx.setClientInformation(information);
-
- }
-
- @Test
- public void testSuccess() {
- ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
- }
-
- @Test
- public void testFailNotRegistered() throws ParseException {
- Set<GrantType> grantTypes = new HashSet<GrantType>();
- grantTypes.add(GrantType.parse("refresh_token"));
- metaData.setGrantTypes(grantTypes);
- ActionTestingSupport.assertEvent(action.execute(requestCtx), OidcEventIds.INVALID_GRANT_TYPE);
- }
-
- @Test
- public void testSuccessSetValue() throws ParseException, ComponentInitializationException {
- action = new ValidateExpectedGrantType();
- action.setExpectedGrantType("refresh_token");
- action.initialize();
- Set<GrantType> grantTypes = new HashSet<GrantType>();
- grantTypes.add(GrantType.parse("refresh_token"));
- metaData.setGrantTypes(grantTypes);
- ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
- }
-
- @Test
- public void testNoInboundMsgCtx() throws ParseException {
- profileRequestCtx.setInboundMessageContext(null);
- ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_PROFILE_CTX);
- }
-
- @Test
- public void testNoMetadataCtx() throws ParseException {
- profileRequestCtx.getInboundMessageContext().removeSubcontext(OIDCMetadataContext.class);
- ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
- }
-
-}
\ No newline at end of file
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateRequestedCredentialTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateRequestedCredentialTest.java
index f84f124..f5cb581 100644
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateRequestedCredentialTest.java
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateRequestedCredentialTest.java
@@ -45,6 +45,7 @@ import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileR
import net.shibboleth.idp.profile.testing.ActionTestingSupport;
import net.shibboleth.idp.profile.testing.RequestContextBuilder;
import net.shibboleth.profile.context.RelyingPartyContext;
+import net.shibboleth.shared.logic.PredicateSupport;
/**
* Unit tests for {@link ValidateRequestedCredential}.
@@ -78,6 +79,7 @@ public class ValidateRequestedCredentialTest {
resolver.initialize();
action = new ValidateRequestedCredential();
action.setCredentialConfigurationsResolver(resolver);
+ action.setDpopAccessTokenCondition(PredicateSupport.alwaysFalse());
action.initialize();
}
@@ -111,6 +113,29 @@ public class ValidateRequestedCredentialTest {
CredentialDataset.DATASET_ID, datasetId);
}
+ @Test
+ public void testConfigurationNotGrantedDPoP() throws Exception {
+ action = new ValidateRequestedCredential();
+ final FilesystemCredentialConfigurationsResolver resolver = new FilesystemCredentialConfigurationsResolver(
+ new ClassPathResource("conf/verifiable-credentials.json"));
+ resolver.setId("test");
+ resolver.initialize();
+ action.setCredentialConfigurationsResolver(resolver);
+ action.setDpopAccessTokenCondition(PredicateSupport.alwaysTrue());
+ action.initialize();
+ setRequest("{\"credential_configuration_id\":\"GeantIncubatorDiploma2\"}");
+ setGrant(Map.of("GeantIncubatorDiploma", CONTENT), null);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.CREDENTIAL_NOT_GRANTED_DPOP);
+ }
+
+ @Test
+ public void testResponseEncryptionRequested() throws Exception {
+ setRequest("{\"credential_configuration_id\":\"GeantIncubatorDiploma\",\"credential_response_encryption\":"
+ + "{\"jwk\":{\"kty\":\"EC\",\"crv\":\"P-256\",\"x\":\"x\",\"y\":\"y\"},\"enc\":\"A128GCM\"}}");
+ setGrant(Map.of("GeantIncubatorDiploma", CONTENT), null);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.NO_CREDENTIAL_REQUEST);
+ }
+
@Test
public void testValidityWindowOfTheGrant() throws Exception {
setRequest("{\"credential_configuration_id\":\"GeantIncubatorDiploma\"}");
@@ -168,7 +193,7 @@ public class ValidateRequestedCredentialTest {
public void testConfigurationIdNotAuthorized() throws Exception {
setRequest("{\"credential_configuration_id\":\"GeantIncubatorDiploma2\"}");
setGrant(Map.of("GeantIncubatorDiploma", CONTENT), null);
- ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.NO_CREDENTIALS_FOR_REQUEST);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.CREDENTIAL_NOT_GRANTED);
}
@Test
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/security/impl/CertificateChainTrustTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/security/impl/CertificateChainTrustTest.java
index 1d33d56..3aa31dc 100644
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/security/impl/CertificateChainTrustTest.java
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/security/impl/CertificateChainTrustTest.java
@@ -29,7 +29,12 @@ import java.util.List;
import org.opensaml.security.credential.Credential;
import org.opensaml.security.crypto.KeySupport;
+import org.opensaml.security.SecurityException;
import org.opensaml.security.x509.BasicX509Credential;
+import org.opensaml.security.x509.PKIXTrustEvaluator;
+import org.opensaml.security.x509.PKIXValidationInformation;
+import org.opensaml.security.x509.PKIXValidationOptions;
+import org.opensaml.security.x509.X509Credential;
import org.opensaml.security.x509.X509Support;
import org.opensaml.security.x509.impl.CertPathPKIXTrustEvaluator;
import org.opensaml.security.x509.impl.CertPathPKIXValidationOptions;
@@ -166,6 +171,48 @@ public class CertificateChainTrustTest {
Assert.assertThrows(JWTValidationException.class, () -> trust.verify(jwt));
}
+ @Test
+ public void testOnlyIssuingAnchorEvaluated() throws Exception {
+ final CountingEvaluator evaluator = new CountingEvaluator();
+ final CertificateChainTrust trust = new CertificateChainTrust();
+ trust.setTrustAnchors(anchors("attestation-ca.crt", "revocation-ca.crt"));
+ trust.setTrustEvaluator(evaluator);
+ trust.initialize();
+ Assert.assertEquals(trust.verify(jwt).get(0), signerCertificate);
+ Assert.assertEquals(evaluator.calls, 1);
+ }
+
+ @Test
+ public void testUnknownIssuerNotEvaluated() throws Exception {
+ final CountingEvaluator evaluator = new CountingEvaluator();
+ final CertificateChainTrust trust = new CertificateChainTrust();
+ trust.setTrustAnchors(anchors("attestation-ca.crt"));
+ trust.setTrustEvaluator(evaluator);
+ trust.initialize();
+ Assert.assertThrows(JWTValidationException.class, () -> trust.verify(jwt));
+ Assert.assertEquals(evaluator.calls, 0);
+ }
+
+ /** Trust evaluator counting its calls. */
+ private static class CountingEvaluator implements PKIXTrustEvaluator {
+
+ private final CertPathPKIXTrustEvaluator delegate = new CertPathPKIXTrustEvaluator();
+
+ private int calls;
+
+ @Override
+ public boolean validate(final PKIXValidationInformation validationInfo,
+ final X509Credential untrustedCredential) throws SecurityException {
+ calls++;
+ return delegate.validate(validationInfo, untrustedCredential);
+ }
+
+ @Override
+ public PKIXValidationOptions getPKIXValidationOptions() {
+ return delegate.getPKIXValidationOptions();
+ }
+ }
+
@Test(expectedExceptions = JWTValidationException.class)
public void testUnknownAnchor() throws Exception {
final CertificateChainTrust trust = new CertificateChainTrust();
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/security/impl/DPoPHttpUriClaimsValidatorTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/security/impl/DPoPHttpUriClaimsValidatorTest.java
index 7338b02..669e1a9 100644
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/security/impl/DPoPHttpUriClaimsValidatorTest.java
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/security/impl/DPoPHttpUriClaimsValidatorTest.java
@@ -23,13 +23,18 @@ import org.testng.annotations.Test;
import com.nimbusds.jwt.JWTClaimsSet;
import net.shibboleth.oidc.jwt.claims.JWTValidationException;
+import net.shibboleth.shared.component.ComponentInitializationException;
/**
* Unit tests for {@link DPoPHttpUriClaimsValidator}.
*/
public class DPoPHttpUriClaimsValidatorTest {
- private static final String REQUEST_URL = "https://issuer.example.org/idp/profile/openid/vci/credentials";
+ private static final String ISSUER = "https://issuer.example.org";
+
+ private static final String REQUEST_PATH = "/idp/profile/openid/vci/credentials";
+
+ private static final String REQUEST_URL = ISSUER + REQUEST_PATH;
private DPoPHttpUriClaimsValidator validator;
@@ -37,7 +42,8 @@ public class DPoPHttpUriClaimsValidatorTest {
protected void setUp() throws Exception {
validator = new DPoPHttpUriClaimsValidator();
validator.setId("htu");
- validator.setRequestUriLookupStrategy((prc, claims) -> REQUEST_URL);
+ validator.setIssuer(ISSUER);
+ validator.setRequestPathLookupStrategy((prc, claims) -> REQUEST_PATH);
validator.initialize();
}
@@ -84,6 +90,48 @@ public class DPoPHttpUriClaimsValidatorTest {
validate("https://issuer.example.org/idp/profile/openid/vci/token");
}
+ @Test(expectedExceptions = JWTValidationException.class)
+ public void testOtherHost() throws Exception {
+ validate("https://evil.example" + REQUEST_PATH);
+ }
+
+ @Test
+ public void testIssuerPort() throws Exception {
+ validator = new DPoPHttpUriClaimsValidator();
+ validator.setId("htu");
+ validator.setIssuer("https://issuer.example.org:8443/realm");
+ validator.setRequestPathLookupStrategy((prc, claims) -> REQUEST_PATH);
+ validator.initialize();
+ validate("https://issuer.example.org:8443" + REQUEST_PATH);
+ }
+
+ @Test(expectedExceptions = JWTValidationException.class)
+ public void testNoRequestPath() throws Exception {
+ validator = new DPoPHttpUriClaimsValidator();
+ validator.setId("htu");
+ validator.setIssuer(ISSUER);
+ validator.setRequestPathLookupStrategy((prc, claims) -> null);
+ validator.initialize();
+ validate(REQUEST_URL);
+ }
+
+ @Test(expectedExceptions = ComponentInitializationException.class)
+ public void testHttpIssuer() throws Exception {
+ validator = new DPoPHttpUriClaimsValidator();
+ validator.setId("htu");
+ validator.setIssuer("http://issuer.example.org");
+ validator.setRequestPathLookupStrategy((prc, claims) -> REQUEST_PATH);
+ validator.initialize();
+ }
+
+ @Test(expectedExceptions = ComponentInitializationException.class)
+ public void testNoIssuer() throws Exception {
+ validator = new DPoPHttpUriClaimsValidator();
+ validator.setId("htu");
+ validator.setRequestPathLookupStrategy((prc, claims) -> REQUEST_PATH);
+ validator.initialize();
+ }
+
@Test(expectedExceptions = JWTValidationException.class)
public void testMissing() throws Exception {
validate(null);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list