From d1de89f0ad036b3397126fe96a3863a6867c0a97 Mon Sep 17 00:00:00 2001 From: Marina Ioannou Date: Tue, 4 Jun 2024 15:51:14 +0300 Subject: [PATCH] OpenId4Vp configuration updated to support multiple schemes --- README.md | 8 ++++- changelog.md | 6 ++++ .../-open-id4-vp-config/-builder/index.md | 4 +-- .../-open-id4-vp-config/-builder/scheme.md | 6 ---- .../-open-id4-vp-config/-builder/schemes.md | 6 ++++ .../-builder/with-scheme.md | 13 ++++++++ .../-open-id4-vp-config/index.md | 8 ++++- .../-open-id4-vp-config/scheme.md | 6 ---- .../-open-id4-vp-config/schemes.md | 6 ++++ docs/wallet-core/package-list | 5 ++-- gradle.properties | 2 +- licenses.md | 2 +- .../eu/europa/ec/eudi/wallet/EudiWallet.kt | 12 ++++---- .../transfer/openid4vp/OpenId4VpConfig.kt | 30 +++++++++++++++---- .../ec/eudi/wallet/EudiWalletConfigTest.kt | 18 +++++++++-- 15 files changed, 99 insertions(+), 33 deletions(-) delete mode 100644 docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/scheme.md create mode 100644 docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/schemes.md delete mode 100644 docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/scheme.md create mode 100644 docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/schemes.md diff --git a/README.md b/README.md index 84efa77f..ccd1f36e 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ file. ```groovy dependencies { - implementation "eu.europa.ec.eudi:eudi-lib-android-wallet-core:0.9.1-SNAPSHOT" + implementation "eu.europa.ec.eudi:eudi-lib-android-wallet-core:0.9.2-SNAPSHOT" implementation "androidx.biometric:biometric-ktx:1.2.0-alpha05" } ``` @@ -166,6 +166,12 @@ val config = EudiWalletConfig.Builder(applicationContext) ClientIdScheme.X509SanDns ) ) + withScheme( + listOf( + "eudi-openid4vp", + "mdoc-openid4vp" + ) + ) withEncryptionAlgorithms(listOf(EncryptionAlgorithm.ECDH_ES)) withEncryptionMethods(listOf(EncryptionMethod.A128CBC_HS256)) } diff --git a/changelog.md b/changelog.md index d61c3448..a3f79491 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## [0.9.2-SNAPSHOT] + +_04 Jun 2024_ + +- Support multiple URL schemes for OpenId4Vp + ## [0.9.1-SNAPSHOT] _31 May 2024_ diff --git a/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/index.md b/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/index.md index febc04c2..728db85f 100644 --- a/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/index.md +++ b/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/index.md @@ -21,7 +21,7 @@ Builder for [OpenId4VciConfig](../../../eu.europa.ec.eudi.wallet.issue.openid4vc | [withClientIdSchemes](with-client-id-schemes.md) | [androidJvm]
fun [withClientIdSchemes](with-client-id-schemes.md)(clientIdSchemes: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[ClientIdScheme](../../-client-id-scheme/index.md)>): [OpenId4VpConfig.Builder](index.md)
Sets the issuer url. | | [withEncryptionAlgorithms](with-encryption-algorithms.md) | [androidJvm]
fun [withEncryptionAlgorithms](with-encryption-algorithms.md)(encryptionAlgorithms: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[EncryptionAlgorithm](../../-encryption-algorithm/index.md)>): [OpenId4VpConfig.Builder](index.md)
Sets the issuer url. | | [withEncryptionMethods](with-encryption-methods.md) | [androidJvm]
fun [withEncryptionMethods](with-encryption-methods.md)(encryptionMethods: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[EncryptionMethod](../../-encryption-method/index.md)>): [OpenId4VpConfig.Builder](index.md)
Sets the issuer url. | -| [withScheme](with-scheme.md) | [androidJvm]
fun [withScheme](with-scheme.md)(scheme: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)): [OpenId4VpConfig.Builder](index.md)
Sets the scheme for openId4Vp. By default, the scheme "mdoc-openid4vp" is supported | +| [withScheme](with-scheme.md) | [androidJvm]
fun [withScheme](with-scheme.md)(scheme: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)): [OpenId4VpConfig.Builder](index.md)
Sets the scheme for openId4Vp. By default, the scheme "mdoc-openid4vp" is supported
[androidJvm]
fun [withScheme](with-scheme.md)(schemes: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)>): [OpenId4VpConfig.Builder](index.md)
Sets a list of schemes for openId4Vp. By default, the scheme "mdoc-openid4vp" is supported | ## Properties @@ -30,4 +30,4 @@ Builder for [OpenId4VciConfig](../../../eu.europa.ec.eudi.wallet.issue.openid4vc | [clientIdSchemes](client-id-schemes.md) | [androidJvm]
lateinit var [clientIdSchemes](client-id-schemes.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[ClientIdScheme](../../-client-id-scheme/index.md)>
list of [ClientIdScheme](../../-client-id-scheme/index.md) that defines the supported Client Identifier schemes | | [encryptionAlgorithms](encryption-algorithms.md) | [androidJvm]
lateinit var [encryptionAlgorithms](encryption-algorithms.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[EncryptionAlgorithm](../../-encryption-algorithm/index.md)>
list of [EncryptionAlgorithm](../../-encryption-algorithm/index.md) that defines the supported encryption algorithms | | [encryptionMethods](encryption-methods.md) | [androidJvm]
lateinit var [encryptionMethods](encryption-methods.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[EncryptionMethod](../../-encryption-method/index.md)>
list of [EncryptionMethod](../../-encryption-method/index.md) that defines the supported encryption methods | -| [scheme](scheme.md) | [androidJvm]
var [scheme](scheme.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
for OpenId4Vp. Optionally, you can change the scheme. By default, "mdoc-openid4vp" is used. | +| [schemes](schemes.md) | [androidJvm]
var [schemes](schemes.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)>
for OpenId4Vp. Optionally, you can set one or more schemes. By default, "mdoc-openid4vp" is used. | diff --git a/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/scheme.md b/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/scheme.md deleted file mode 100644 index b4b562d6..00000000 --- a/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/scheme.md +++ /dev/null @@ -1,6 +0,0 @@ -//[wallet-core](../../../../index.md)/[eu.europa.ec.eudi.wallet.transfer.openid4vp](../../index.md)/[OpenId4VpConfig](../index.md)/[Builder](index.md)/[scheme](scheme.md) - -# scheme - -[androidJvm]\ -var [scheme](scheme.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) diff --git a/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/schemes.md b/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/schemes.md new file mode 100644 index 00000000..8867b6d2 --- /dev/null +++ b/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/schemes.md @@ -0,0 +1,6 @@ +//[wallet-core](../../../../index.md)/[eu.europa.ec.eudi.wallet.transfer.openid4vp](../../index.md)/[OpenId4VpConfig](../index.md)/[Builder](index.md)/[schemes](schemes.md) + +# schemes + +[androidJvm]\ +var [schemes](schemes.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)> diff --git a/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/with-scheme.md b/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/with-scheme.md index 42a03220..2819772d 100644 --- a/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/with-scheme.md +++ b/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/with-scheme.md @@ -14,3 +14,16 @@ androidJvm | | | |---|---| | scheme | the scheme | + +[androidJvm]\ +fun [withScheme](with-scheme.md)(schemes: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)>): [OpenId4VpConfig.Builder](index.md) + +Sets a list of schemes for openId4Vp. By default, the scheme "mdoc-openid4vp" is supported + +#### Parameters + +androidJvm + +| | | +|---|---| +| schemes | the list of schemes | diff --git a/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/index.md b/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/index.md index b6d784d3..74409fbd 100644 --- a/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/index.md +++ b/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/index.md @@ -25,6 +25,12 @@ val config = OpenId4VpConfig.Builder() ClientIdScheme.X509SanDns ) ) + .withScheme( + listOf( + "eudi-openid4vp", + "mdoc-openid4vp" + ) + ) .withEncryptionAlgorithms(listOf(EncryptionAlgorithm.ECDH_ES)) .withEncryptionMethods(listOf(EncryptionMethod.A128CBC_HS256)) .build() @@ -43,4 +49,4 @@ val config = OpenId4VpConfig.Builder() | [clientIdSchemes](client-id-schemes.md) | [androidJvm]
val [clientIdSchemes](client-id-schemes.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[ClientIdScheme](../-client-id-scheme/index.md)>
list of [ClientIdScheme](../-client-id-scheme/index.md) that defines the supported Client Identifier schemes | | [encryptionAlgorithms](encryption-algorithms.md) | [androidJvm]
val [encryptionAlgorithms](encryption-algorithms.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[EncryptionAlgorithm](../-encryption-algorithm/index.md)>
list of [EncryptionAlgorithm](../-encryption-algorithm/index.md) that defines the supported encryption algorithms | | [encryptionMethods](encryption-methods.md) | [androidJvm]
val [encryptionMethods](encryption-methods.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[EncryptionMethod](../-encryption-method/index.md)>
list of [EncryptionMethod](../-encryption-method/index.md) that defines the supported encryption methods | -| [scheme](scheme.md) | [androidJvm]
val [scheme](scheme.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
optionally you can change the scheme. By default, the scheme "mdoc-openid4vp" is used | +| [schemes](schemes.md) | [androidJvm]
val [schemes](schemes.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)>
optionally you can set one or more schemes. By default, the scheme "mdoc-openid4vp" is used | diff --git a/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/scheme.md b/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/scheme.md deleted file mode 100644 index 0a8fe855..00000000 --- a/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/scheme.md +++ /dev/null @@ -1,6 +0,0 @@ -//[wallet-core](../../../index.md)/[eu.europa.ec.eudi.wallet.transfer.openid4vp](../index.md)/[OpenId4VpConfig](index.md)/[scheme](scheme.md) - -# scheme - -[androidJvm]\ -val [scheme](scheme.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) diff --git a/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/schemes.md b/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/schemes.md new file mode 100644 index 00000000..9dfe4983 --- /dev/null +++ b/docs/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/schemes.md @@ -0,0 +1,6 @@ +//[wallet-core](../../../index.md)/[eu.europa.ec.eudi.wallet.transfer.openid4vp](../index.md)/[OpenId4VpConfig](index.md)/[schemes](schemes.md) + +# schemes + +[androidJvm]\ +val [schemes](schemes.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)> diff --git a/docs/wallet-core/package-list b/docs/wallet-core/package-list index ff216ba2..d19e6937 100644 --- a/docs/wallet-core/package-list +++ b/docs/wallet-core/package-list @@ -156,16 +156,17 @@ $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig.Buil $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig.Builder/clientIdSchemes/#/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/client-id-schemes.md $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig.Builder/encryptionAlgorithms/#/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/encryption-algorithms.md $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig.Builder/encryptionMethods/#/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/encryption-methods.md -$dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig.Builder/scheme/#/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/scheme.md +$dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig.Builder/schemes/#/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/schemes.md $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig.Builder/withClientIdSchemes/#kotlin.collections.List[eu.europa.ec.eudi.wallet.transfer.openid4vp.ClientIdScheme]/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/with-client-id-schemes.md $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig.Builder/withEncryptionAlgorithms/#kotlin.collections.List[eu.europa.ec.eudi.wallet.transfer.openid4vp.EncryptionAlgorithm]/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/with-encryption-algorithms.md $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig.Builder/withEncryptionMethods/#kotlin.collections.List[eu.europa.ec.eudi.wallet.transfer.openid4vp.EncryptionMethod]/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/with-encryption-methods.md $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig.Builder/withScheme/#kotlin.String/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/with-scheme.md +$dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig.Builder/withScheme/#kotlin.collections.List[kotlin.String]/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/-builder/with-scheme.md $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig///PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/index.md $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig/clientIdSchemes/#/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/client-id-schemes.md $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig/encryptionAlgorithms/#/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/encryption-algorithms.md $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig/encryptionMethods/#/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/encryption-methods.md -$dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig/scheme/#/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/scheme.md +$dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpConfig/schemes/#/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-config/schemes.md $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpRequest///PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-request/index.md $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpRequest/OpenId4VpRequest/#eu.europa.ec.eudi.openid4vp.ResolvedRequestObject.OpenId4VPAuthorization#kotlin.ByteArray/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-request/-open-id4-vp-request.md $dokka.location:eu.europa.ec.eudi.wallet.transfer.openid4vp/OpenId4VpRequest/openId4VPAuthorization/#/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.transfer.openid4vp/-open-id4-vp-request/open-id4-v-p-authorization.md diff --git a/gradle.properties b/gradle.properties index fd6a63ef..c9a17341 100644 --- a/gradle.properties +++ b/gradle.properties @@ -42,7 +42,7 @@ systemProp.sonar.host.url=https://sonarcloud.io systemProp.sonar.gradle.skipCompile=true systemProp.sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/testDebugUnitTestCoverage/testDebugUnitTestCoverage.xml,build/reports/jacoco/testReleaseUnitTestCoverage/testReleaseUnitTestCoverage.xml systemProp.sonar.projectName=eudi-lib-android-wallet-core -VERSION_NAME=0.9.1-SNAPSHOT +VERSION_NAME=0.9.2-SNAPSHOT SONATYPE_HOST=S01 SONATYPE_AUTOMATIC_RELEASE=false diff --git a/licenses.md b/licenses.md index 1f727e4b..6effab2a 100644 --- a/licenses.md +++ b/licenses.md @@ -1,7 +1,7 @@ # EUDI Wallet Core library for Android ## Dependency License Report -_2024-05-23 21:13:35 EEST_ +_2024-06-04 14:27:20 EEST_ ## Apache License, Version 2.0 **1** **Group:** `androidx.appcompat` **Name:** `appcompat` **Version:** `1.6.1` diff --git a/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/EudiWallet.kt b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/EudiWallet.kt index 44cb83b4..206c23fe 100644 --- a/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/EudiWallet.kt +++ b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/EudiWallet.kt @@ -503,13 +503,14 @@ object EudiWallet { */ fun startEngagementFromIntent(intent: Intent) { requireInit { - when (intent.scheme) { - "mdoc" -> { + val scheme = intent.scheme + when { + scheme == "mdoc" -> { transferMode = TransferMode.REST_API transferManager.startEngagementToApp(intent) } - _config.openId4VPConfig?.scheme -> { // openid4vp scheme + true == _config.openId4VPConfig?.schemes?.contains(scheme) -> { transferMode = TransferMode.OPENID4VP openId4vpManager?.resolveRequestUri(intent.toUri(0)) } @@ -540,8 +541,9 @@ object EudiWallet { */ fun resolveRequestUri(openid4VpURI: String) { requireInit { - when (Uri.parse(openid4VpURI).scheme) { - _config.openId4VPConfig?.scheme -> { // openid4vp scheme + val scheme = Uri.parse(openid4VpURI).scheme + when { + true == _config.openId4VPConfig?.schemes?.contains(scheme) -> { // openid4vp scheme transferMode = TransferMode.OPENID4VP openId4vpManager?.resolveRequestUri(openid4VpURI) } diff --git a/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/transfer/openid4vp/OpenId4VpConfig.kt b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/transfer/openid4vp/OpenId4VpConfig.kt index cab02d77..9308126d 100644 --- a/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/transfer/openid4vp/OpenId4VpConfig.kt +++ b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/transfer/openid4vp/OpenId4VpConfig.kt @@ -42,6 +42,12 @@ import eu.europa.ec.eudi.wallet.issue.openid4vci.OpenId4VciManager.Config as Ope * ClientIdScheme.X509SanDns * ) * ) + * .withScheme( + * listOf( + * "eudi-openid4vp", + * "mdoc-openid4vp" + * ) + * ) * .withEncryptionAlgorithms(listOf(EncryptionAlgorithm.ECDH_ES)) * .withEncryptionMethods(listOf(EncryptionMethod.A128CBC_HS256)) * .build() @@ -50,7 +56,7 @@ import eu.europa.ec.eudi.wallet.issue.openid4vci.OpenId4VciManager.Config as Ope * @property clientIdSchemes list of [ClientIdScheme] that defines the supported Client Identifier schemes * @property encryptionAlgorithms list of [EncryptionAlgorithm] that defines the supported encryption algorithms * @property encryptionMethods list of [EncryptionMethod] that defines the supported encryption methods - * @property scheme optionally you can change the scheme. By default, the scheme "mdoc-openid4vp" is used + * @property schemes optionally you can set one or more schemes. By default, the scheme "mdoc-openid4vp" is used */ class OpenId4VpConfig private constructor(private val builder: Builder) { @@ -64,8 +70,8 @@ class OpenId4VpConfig private constructor(private val builder: Builder) { val encryptionMethods: List get() = builder.encryptionMethods - val scheme: String - get() = builder.scheme + val schemes: List + get() = builder.schemes /** * Builder for [OpenId4VciConfig]. @@ -73,7 +79,7 @@ class OpenId4VpConfig private constructor(private val builder: Builder) { * @property clientIdSchemes list of [ClientIdScheme] that defines the supported Client Identifier schemes * @property encryptionAlgorithms list of [EncryptionAlgorithm] that defines the supported encryption algorithms * @property encryptionMethods list of [EncryptionMethod] that defines the supported encryption methods - * @property scheme for OpenId4Vp. Optionally, you can change the scheme. By default, "mdoc-openid4vp" is used. + * @property schemes for OpenId4Vp. Optionally, you can set one or more schemes. By default, "mdoc-openid4vp" is used. */ class Builder { lateinit var clientIdSchemes: List @@ -106,7 +112,7 @@ class OpenId4VpConfig private constructor(private val builder: Builder) { */ fun withEncryptionMethods(encryptionMethods: List) = apply { this.encryptionMethods = encryptionMethods } - var scheme: String = "mdoc-openid4vp" + var schemes: List = listOf("mdoc-openid4vp") private set /** @@ -116,7 +122,17 @@ class OpenId4VpConfig private constructor(private val builder: Builder) { * @param scheme the scheme */ fun withScheme(scheme: String) = apply { - this.scheme = scheme + this.schemes = listOf(scheme) + } + + /** + * Sets a list of schemes for openId4Vp. + * By default, the scheme "mdoc-openid4vp" is supported + * + * @param schemes the list of schemes + */ + fun withScheme(schemes: List) = apply { + this.schemes = schemes } fun build(): OpenId4VpConfig { @@ -126,6 +142,8 @@ class OpenId4VpConfig private constructor(private val builder: Builder) { require(this.clientIdSchemes.count { it is ClientIdScheme.X509SanDns } <= 1) { "OpenId4VpConfig: clientIdSchemes must contain maximum one X509SanDns item" } require(this.clientIdSchemes.count { it is ClientIdScheme.X509SanUri } <= 1) { "OpenId4VpConfig: clientIdSchemes must contain maximum one X509SanUri item" } + require(this.schemes.isNotEmpty()) { "OpenId4VpConfig: schemes must be initialized with a not empty list" } + require(this::encryptionAlgorithms.isInitialized && encryptionAlgorithms.isNotEmpty()) { "OpenId4VpConfig: encryptionAlgorithms must be initialized with a not empty list" } require(this::encryptionMethods.isInitialized && encryptionMethods.isNotEmpty()) { "OpenId4VpConfig: encryptionMethods must be initialized with a not empty list" } diff --git a/wallet-core/src/test/java/eu/europa/ec/eudi/wallet/EudiWalletConfigTest.kt b/wallet-core/src/test/java/eu/europa/ec/eudi/wallet/EudiWalletConfigTest.kt index 0c2e4188..c69c09c1 100644 --- a/wallet-core/src/test/java/eu/europa/ec/eudi/wallet/EudiWalletConfigTest.kt +++ b/wallet-core/src/test/java/eu/europa/ec/eudi/wallet/EudiWalletConfigTest.kt @@ -65,6 +65,12 @@ class EudiWalletConfigTest { ClientIdScheme.X509SanDns ) ) + withScheme( + listOf( + "eudi-openid4vp", + "mdoc-openid4vp" + ) + ) withEncryptionAlgorithms(listOf(EncryptionAlgorithm.ECDH_ES)) withEncryptionMethods(listOf(EncryptionMethod.A128CBC_HS256)) } @@ -93,8 +99,16 @@ class EudiWalletConfigTest { (config.openId4VPConfig?.clientIdSchemes?.get(0) as ClientIdScheme.Preregistered).preregisteredVerifiers[0].legalName ) assertEquals(ClientIdScheme.X509SanDns, config.openId4VPConfig?.clientIdSchemes?.get(1)) - assertEquals(EncryptionAlgorithm.ECDH_ES, config.openId4VPConfig?.encryptionAlgorithms?.get(0)) - assertEquals(EncryptionMethod.A128CBC_HS256, config.openId4VPConfig?.encryptionMethods?.get(0)) + assertEquals("eudi-openid4vp", config.openId4VPConfig?.schemes?.get(0)) + assertEquals("mdoc-openid4vp", config.openId4VPConfig?.schemes?.get(1)) + assertEquals( + EncryptionAlgorithm.ECDH_ES, + config.openId4VPConfig?.encryptionAlgorithms?.get(0) + ) + assertEquals( + EncryptionMethod.A128CBC_HS256, + config.openId4VPConfig?.encryptionMethods?.get(0) + ) assertEquals("https://example.com", config.openId4VciConfig?.issuerUrl) assertEquals("client-id", config.openId4VciConfig?.clientId) assertEquals("eudi-openid4ci://authorize", config.openId4VciConfig?.authFlowRedirectionURI)