Skip to content

Commit

Permalink
OpenId4Vp configuration updated to support multiple schemes
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaioannou committed Jun 4, 2024
1 parent 520a382 commit d1de89f
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 33 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
```
Expand Down Expand Up @@ -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))
}
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Builder for [OpenId4VciConfig](../../../eu.europa.ec.eudi.wallet.issue.openid4vc
| [withClientIdSchemes](with-client-id-schemes.md) | [androidJvm]<br>fun [withClientIdSchemes](with-client-id-schemes.md)(clientIdSchemes: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;[ClientIdScheme](../../-client-id-scheme/index.md)&gt;): [OpenId4VpConfig.Builder](index.md)<br>Sets the issuer url. |
| [withEncryptionAlgorithms](with-encryption-algorithms.md) | [androidJvm]<br>fun [withEncryptionAlgorithms](with-encryption-algorithms.md)(encryptionAlgorithms: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;[EncryptionAlgorithm](../../-encryption-algorithm/index.md)&gt;): [OpenId4VpConfig.Builder](index.md)<br>Sets the issuer url. |
| [withEncryptionMethods](with-encryption-methods.md) | [androidJvm]<br>fun [withEncryptionMethods](with-encryption-methods.md)(encryptionMethods: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;[EncryptionMethod](../../-encryption-method/index.md)&gt;): [OpenId4VpConfig.Builder](index.md)<br>Sets the issuer url. |
| [withScheme](with-scheme.md) | [androidJvm]<br>fun [withScheme](with-scheme.md)(scheme: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)): [OpenId4VpConfig.Builder](index.md)<br>Sets the scheme for openId4Vp. By default, the scheme &quot;mdoc-openid4vp&quot; is supported |
| [withScheme](with-scheme.md) | [androidJvm]<br>fun [withScheme](with-scheme.md)(scheme: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)): [OpenId4VpConfig.Builder](index.md)<br>Sets the scheme for openId4Vp. By default, the scheme &quot;mdoc-openid4vp&quot; is supported<br>[androidJvm]<br>fun [withScheme](with-scheme.md)(schemes: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)&gt;): [OpenId4VpConfig.Builder](index.md)<br>Sets a list of schemes for openId4Vp. By default, the scheme &quot;mdoc-openid4vp&quot; is supported |

## Properties

Expand All @@ -30,4 +30,4 @@ Builder for [OpenId4VciConfig](../../../eu.europa.ec.eudi.wallet.issue.openid4vc
| [clientIdSchemes](client-id-schemes.md) | [androidJvm]<br>lateinit var [clientIdSchemes](client-id-schemes.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;[ClientIdScheme](../../-client-id-scheme/index.md)&gt;<br>list of [ClientIdScheme](../../-client-id-scheme/index.md) that defines the supported Client Identifier schemes |
| [encryptionAlgorithms](encryption-algorithms.md) | [androidJvm]<br>lateinit var [encryptionAlgorithms](encryption-algorithms.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;[EncryptionAlgorithm](../../-encryption-algorithm/index.md)&gt;<br>list of [EncryptionAlgorithm](../../-encryption-algorithm/index.md) that defines the supported encryption algorithms |
| [encryptionMethods](encryption-methods.md) | [androidJvm]<br>lateinit var [encryptionMethods](encryption-methods.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;[EncryptionMethod](../../-encryption-method/index.md)&gt;<br>list of [EncryptionMethod](../../-encryption-method/index.md) that defines the supported encryption methods |
| [scheme](scheme.md) | [androidJvm]<br>var [scheme](scheme.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>for OpenId4Vp. Optionally, you can change the scheme. By default, &quot;mdoc-openid4vp&quot; is used. |
| [schemes](schemes.md) | [androidJvm]<br>var [schemes](schemes.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)&gt;<br>for OpenId4Vp. Optionally, you can set one or more schemes. By default, &quot;mdoc-openid4vp&quot; is used. |

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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)&lt;[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)&gt;
Original file line number Diff line number Diff line change
Expand Up @@ -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)&lt;[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)&gt;): [OpenId4VpConfig.Builder](index.md)

Sets a list of schemes for openId4Vp. By default, the scheme &quot;mdoc-openid4vp&quot; is supported

#### Parameters

androidJvm

| | |
|---|---|
| schemes | the list of schemes |
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -43,4 +49,4 @@ val config = OpenId4VpConfig.Builder()
| [clientIdSchemes](client-id-schemes.md) | [androidJvm]<br>val [clientIdSchemes](client-id-schemes.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;[ClientIdScheme](../-client-id-scheme/index.md)&gt;<br>list of [ClientIdScheme](../-client-id-scheme/index.md) that defines the supported Client Identifier schemes |
| [encryptionAlgorithms](encryption-algorithms.md) | [androidJvm]<br>val [encryptionAlgorithms](encryption-algorithms.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;[EncryptionAlgorithm](../-encryption-algorithm/index.md)&gt;<br>list of [EncryptionAlgorithm](../-encryption-algorithm/index.md) that defines the supported encryption algorithms |
| [encryptionMethods](encryption-methods.md) | [androidJvm]<br>val [encryptionMethods](encryption-methods.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;[EncryptionMethod](../-encryption-method/index.md)&gt;<br>list of [EncryptionMethod](../-encryption-method/index.md) that defines the supported encryption methods |
| [scheme](scheme.md) | [androidJvm]<br>val [scheme](scheme.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>optionally you can change the scheme. By default, the scheme &quot;mdoc-openid4vp&quot; is used |
| [schemes](schemes.md) | [androidJvm]<br>val [schemes](schemes.md): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)&gt;<br>optionally you can set one or more schemes. By default, the scheme &quot;mdoc-openid4vp&quot; is used |

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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)&lt;[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)&gt;
5 changes: 3 additions & 2 deletions docs/wallet-core/package-list
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion licenses.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
12 changes: 7 additions & 5 deletions wallet-core/src/main/java/eu/europa/ec/eudi/wallet/EudiWallet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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) {
Expand All @@ -64,16 +70,16 @@ class OpenId4VpConfig private constructor(private val builder: Builder) {
val encryptionMethods: List<EncryptionMethod>
get() = builder.encryptionMethods

val scheme: String
get() = builder.scheme
val schemes: List<String>
get() = builder.schemes

/**
* Builder for [OpenId4VciConfig].
*
* @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<ClientIdScheme>
Expand Down Expand Up @@ -106,7 +112,7 @@ class OpenId4VpConfig private constructor(private val builder: Builder) {
*/
fun withEncryptionMethods(encryptionMethods: List<EncryptionMethod>) = apply { this.encryptionMethods = encryptionMethods }

var scheme: String = "mdoc-openid4vp"
var schemes: List<String> = listOf("mdoc-openid4vp")
private set

/**
Expand All @@ -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<String>) = apply {
this.schemes = schemes
}

fun build(): OpenId4VpConfig {
Expand All @@ -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" }

Expand Down
Loading

0 comments on commit d1de89f

Please sign in to comment.