Skip to content

Commit

Permalink
Upgrade sd-jwt library to v0.10.0 (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzarras authored Dec 23, 2024
1 parent 9d172cd commit a89424d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -80,7 +81,7 @@ internal class ValidateSdJwtVc(
trustedIssuers: KeyStore?,
private val audience: Audience,
) {
private val verifier: SdJwtVcVerifier by lazy {
private val verifier: SdJwtVcVerifier<SignedJWT> by lazy {
val x5CShouldBe = trustedIssuers?.let {
X5CShouldBe.fromKeystore(it) {
isRevocationEnabled = false
Expand All @@ -95,7 +96,7 @@ internal class ValidateSdJwtVc(
)
} ?: false
}
SdJwtVcVerifier.usingX5cOrIssuerMetadata(
NimbusSdJwtOps.SdJwtVcVerifier.usingX5cOrIssuerMetadata(
x509CertificateTrust = x509CertificateTrust,
httpClientFactory = DefaultHttpClientFactory,
)
Expand All @@ -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)
Expand Down

0 comments on commit a89424d

Please sign in to comment.