From a89424d4980b7265262feeb5a4bcfd029f84e581 Mon Sep 17 00:00:00 2001 From: Dimitris Zarras <138439389+dzarras@users.noreply.github.com> Date: Mon, 23 Dec 2024 13:06:47 +0200 Subject: [PATCH] Upgrade sd-jwt library to v0.10.0 (#226) --- gradle/libs.versions.toml | 2 +- .../verifier/endpoint/port/input/ValidateSdJwtVc.kt | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 406794f..b2c4bd0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -17,7 +17,7 @@ dependencycheck = "11.1.0" jacoco = "0.8.11" swaggerUi = "5.18.2" waltid = "0.9.0" -sdJwt = "0.9.0" +sdJwt = "0.10.0" [libraries] kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } diff --git a/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/port/input/ValidateSdJwtVc.kt b/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/port/input/ValidateSdJwtVc.kt index aa797fd..33ffe9b 100644 --- a/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/port/input/ValidateSdJwtVc.kt +++ b/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/port/input/ValidateSdJwtVc.kt @@ -18,6 +18,7 @@ package eu.europa.ec.eudi.verifier.endpoint.port.input import arrow.core.Either import arrow.core.getOrElse import arrow.core.toNonEmptyListOrNull +import com.nimbusds.jwt.SignedJWT import eu.europa.ec.eudi.sdjwt.* import eu.europa.ec.eudi.sdjwt.vc.DefaultHttpClientFactory import eu.europa.ec.eudi.sdjwt.vc.SdJwtVcVerifier @@ -80,7 +81,7 @@ internal class ValidateSdJwtVc( trustedIssuers: KeyStore?, private val audience: Audience, ) { - private val verifier: SdJwtVcVerifier by lazy { + private val verifier: SdJwtVcVerifier by lazy { val x5CShouldBe = trustedIssuers?.let { X5CShouldBe.fromKeystore(it) { isRevocationEnabled = false @@ -95,7 +96,7 @@ internal class ValidateSdJwtVc( ) } ?: false } - SdJwtVcVerifier.usingX5cOrIssuerMetadata( + NimbusSdJwtOps.SdJwtVcVerifier.usingX5cOrIssuerMetadata( x509CertificateTrust = x509CertificateTrust, httpClientFactory = DefaultHttpClientFactory, ) @@ -108,10 +109,8 @@ internal class ValidateSdJwtVc( } return Either.catch { - val (presentation, keyBinding) = verifier.verifyPresentation(unverified, challenge).getOrThrow() - checkNotNull(keyBinding) { "KeyBinding JWT cannot be null" } - - val payload = with(DefaultSdJwtOps) { + val (presentation, _) = verifier.verify(unverified, challenge).getOrThrow() + val payload = with(NimbusSdJwtOps) { presentation.recreateClaims(visitor = null) } SdJwtVcValidationResult.Valid(payload)