From 1bdcdea758c7756a7da10312df6637d3f1924d15 Mon Sep 17 00:00:00 2001 From: vkanellopoulos Date: Thu, 21 Nov 2024 22:06:31 +0200 Subject: [PATCH] fix #98; removed secureAreaIdentifier from EudiWallet.getDefaultCreateDocumentSettings extension; in DefaultKeyUnlockData check if keyInfo is AndroidKeystoreKeyInfo before creating AndroidKeystoreKeyUnlockData --- .../-default-key-unlock-data.md | 13 +- .../get-default-create-document-settings.md | 25 +- .../get-default-key-unlock-data.md | 17 +- .../-document-extensions/index.md | 14 +- .../-eudi-wallet-impl/index.md | 48 ++-- .../-eudi-wallet/index.md | 48 ++-- docs/wallet-core/package-list | 2 +- .../wallet/document/DocumentExtensions.kt | 53 ++-- .../wallet/document/DocumentExtensionsTest.kt | 231 ++++++++++++++++++ 9 files changed, 361 insertions(+), 90 deletions(-) create mode 100644 wallet-core/src/test/java/eu/europa/ec/eudi/wallet/document/DocumentExtensionsTest.kt diff --git a/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/-default-key-unlock-data.md b/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/-default-key-unlock-data.md index 4f91bd91..712fc46f 100644 --- a/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/-default-key-unlock-data.md +++ b/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/-default-key-unlock-data.md @@ -7,7 +7,9 @@ @get:[JvmName](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index.html)(name = "getDefaultKeyUnlockData") -val Document.[DefaultKeyUnlockData](-default-key-unlock-data.md): AndroidKeystoreKeyUnlockData +@get:[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html) + +val Document.[DefaultKeyUnlockData](-default-key-unlock-data.md): AndroidKeystoreKeyUnlockData? Returns the default AndroidKeystoreKeyUnlockData for the Document instance. The default key unlock data is based on the Document.keyAlias. @@ -18,7 +20,8 @@ the Document instance #### Return -the default AndroidKeystoreKeyUnlockData for the Document instance +the default AndroidKeystoreKeyUnlockData for the Document instance if document requires user +authentication #### See also @@ -26,3 +29,9 @@ the default AndroidKeystoreKeyUnlockData for the Document instance |------------------------------| | AndroidKeystoreKeyUnlockData | | Document | + +#### Throws + +| | | +|------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------| +| [IllegalStateException](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-illegal-state-exception/index.html) | if the Document is not managed by AndroidKeystoreSecureArea | diff --git a/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md b/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md index 5afb0038..8fad1359 100644 --- a/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md +++ b/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md @@ -9,9 +9,9 @@ @[JvmOverloads](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-overloads/index.html) +@[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html) + fun [EudiWallet](../../eu.europa.ec.eudi.wallet/-eudi-wallet/index.md).[getDefaultCreateDocumentSettings](get-default-create-document-settings.md)( -secureAreaIdentifier: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? = -null, attestationChallenge: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)? = null, configure: AndroidKeystoreCreateKeySettings.Builder.() -> [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)? = null): @@ -19,14 +19,14 @@ CreateDocumentSettings Returns the default CreateDocumentSettings for the [EudiWallet](../../eu.europa.ec.eudi.wallet/-eudi-wallet/index.md) instance. The default -settings are based on the EudiWalletConfig and the first available AndroidKeystoreSecureArea -implementation. The [attestationChallenge](get-default-create-document-settings.md) is generated -using +settings are based on +the [EudiWalletConfig](../../eu.europa.ec.eudi.wallet/-eudi-wallet-config/index.md) and the first +available AndroidKeystoreSecureArea implementation. +The [attestationChallenge](get-default-create-document-settings.md) is generated using a [SecureRandom](https://developer.android.com/reference/kotlin/java/security/SecureRandom.html) instance. The [configure](get-default-create-document-settings.md) lambda can be used to further -customize the AndroidKeystoreCreateKeySettings. -If [secureAreaIdentifier](get-default-create-document-settings.md) is not provided, the first -available AndroidKeystoreSecureArea implementation is used. +customize the AndroidKeystoreCreateKeySettings. The first available AndroidKeystoreSecureArea +implementation is used. #### Receiver @@ -36,11 +36,10 @@ the [EudiWallet](../../eu.europa.ec.eudi.wallet/-eudi-wallet/index.md) instance androidJvm -| | | -|----------------------|-------------------------------------------------------------------------------------| -| secureAreaIdentifier | the AndroidKeystoreSecureArea.identifier where the document's keys should be stored | -| attestationChallenge | the attestation challenge to use when creating the keys | -| configure | a lambda to further customize the AndroidKeystoreCreateKeySettings | +| | | +|----------------------|--------------------------------------------------------------------| +| attestationChallenge | the attestation challenge to use when creating the keys | +| configure | a lambda to further customize the AndroidKeystoreCreateKeySettings | #### See also diff --git a/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-key-unlock-data.md b/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-key-unlock-data.md index 168958b1..187446a1 100644 --- a/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-key-unlock-data.md +++ b/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-key-unlock-data.md @@ -3,6 +3,12 @@ # getDefaultKeyUnlockData [androidJvm]\ + +@[JvmName](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index.html)(name = +"getDefaultKeyUnlockData") + +@[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html) + fun [EudiWallet](../../eu.europa.ec.eudi.wallet/-eudi-wallet/index.md).[getDefaultKeyUnlockData](get-default-key-unlock-data.md)( documentId: DocumentId): AndroidKeystoreKeyUnlockData? @@ -15,8 +21,8 @@ the [EudiWallet](../../eu.europa.ec.eudi.wallet/-eudi-wallet/index.md) instance #### Return -the default AndroidKeystoreKeyUnlockData for the given DocumentId or null if the document is not -found +the default AndroidKeystoreKeyUnlockData for the given DocumentId or null if the document requires +no user authentication #### Parameters @@ -32,3 +38,10 @@ androidJvm |------------------------------| | AndroidKeystoreKeyUnlockData | | Document | + +#### Throws + +| | | +|---------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------| +| [IllegalStateException](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-illegal-state-exception/index.html) | if the Document is not managed by AndroidKeystoreSecureArea | +| [NoSuchElementException](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-no-such-element-exception/index.html) | if the document is not found by the DocumentId | diff --git a/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/index.md b/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/index.md index 54efd87c..72e8bdd5 100644 --- a/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/index.md +++ b/docs/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/index.md @@ -7,13 +7,13 @@ object [DocumentExtensions](index.md) ## Properties -| Name | Summary | -|-----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [DefaultKeyUnlockData](-default-key-unlock-data.md) | [androidJvm]
@get:[JvmName](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index.html)(name = "getDefaultKeyUnlockData")
val Document.[DefaultKeyUnlockData](-default-key-unlock-data.md): AndroidKeystoreKeyUnlockData
Returns the default AndroidKeystoreKeyUnlockData for the Document instance. The default key unlock data is based on the Document.keyAlias. | +| Name | Summary | +|-----------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [DefaultKeyUnlockData](-default-key-unlock-data.md) | [androidJvm]
@get:[JvmName](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index.html)(name = "getDefaultKeyUnlockData")
@get:[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html)
val Document.[DefaultKeyUnlockData](-default-key-unlock-data.md): AndroidKeystoreKeyUnlockData?
Returns the default AndroidKeystoreKeyUnlockData for the Document instance. The default key unlock data is based on the Document.keyAlias. | ## Functions -| Name | Summary | -|-----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [getDefaultCreateDocumentSettings](get-default-create-document-settings.md) | [androidJvm]
@[JvmName](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index.html)(name = "getDefaultCreateDocumentSettings")
@[JvmOverloads](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-overloads/index.html)
fun [EudiWallet](../../eu.europa.ec.eudi.wallet/-eudi-wallet/index.md).[getDefaultCreateDocumentSettings](get-default-create-document-settings.md)(secureAreaIdentifier: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? = null, attestationChallenge: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)? = null, configure: AndroidKeystoreCreateKeySettings.Builder.() -> [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)? = null): CreateDocumentSettings
Returns the default CreateDocumentSettings for the [EudiWallet](../../eu.europa.ec.eudi.wallet/-eudi-wallet/index.md) instance. The default settings are based on the EudiWalletConfig and the first available AndroidKeystoreSecureArea implementation. The [attestationChallenge](get-default-create-document-settings.md) is generated using a [SecureRandom](https://developer.android.com/reference/kotlin/java/security/SecureRandom.html) instance. The [configure](get-default-create-document-settings.md) lambda can be used to further customize the AndroidKeystoreCreateKeySettings. If [secureAreaIdentifier](get-default-create-document-settings.md) is not provided, the first available AndroidKeystoreSecureArea implementation is used. | -| [getDefaultKeyUnlockData](get-default-key-unlock-data.md) | [androidJvm]
fun [EudiWallet](../../eu.europa.ec.eudi.wallet/-eudi-wallet/index.md).[getDefaultKeyUnlockData](get-default-key-unlock-data.md)(documentId: DocumentId): AndroidKeystoreKeyUnlockData?
Returns the default AndroidKeystoreKeyUnlockData for the given DocumentId. The default key unlock data is based on the Document.keyAlias. | +| Name | Summary | +|-----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [getDefaultCreateDocumentSettings](get-default-create-document-settings.md) | [androidJvm]
@[JvmName](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index.html)(name = "getDefaultCreateDocumentSettings")
@[JvmOverloads](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-overloads/index.html)
@[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html)
fun [EudiWallet](../../eu.europa.ec.eudi.wallet/-eudi-wallet/index.md).[getDefaultCreateDocumentSettings](get-default-create-document-settings.md)(attestationChallenge: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)? = null, configure: AndroidKeystoreCreateKeySettings.Builder.() -> [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)? = null): CreateDocumentSettings
Returns the default CreateDocumentSettings for the [EudiWallet](../../eu.europa.ec.eudi.wallet/-eudi-wallet/index.md) instance. The default settings are based on the [EudiWalletConfig](../../eu.europa.ec.eudi.wallet/-eudi-wallet-config/index.md) and the first available AndroidKeystoreSecureArea implementation. The [attestationChallenge](get-default-create-document-settings.md) is generated using a [SecureRandom](https://developer.android.com/reference/kotlin/java/security/SecureRandom.html) instance. The [configure](get-default-create-document-settings.md) lambda can be used to further customize the AndroidKeystoreCreateKeySettings. The first available AndroidKeystoreSecureArea implementation is used. | +| [getDefaultKeyUnlockData](get-default-key-unlock-data.md) | [androidJvm]
@[JvmName](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index.html)(name = "getDefaultKeyUnlockData")
@[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html)
fun [EudiWallet](../../eu.europa.ec.eudi.wallet/-eudi-wallet/index.md).[getDefaultKeyUnlockData](get-default-key-unlock-data.md)(documentId: DocumentId): AndroidKeystoreKeyUnlockData?
Returns the default AndroidKeystoreKeyUnlockData for the given DocumentId. The default key unlock data is based on the Document.keyAlias. | diff --git a/docs/wallet-core/eu.europa.ec.eudi.wallet/-eudi-wallet-impl/index.md b/docs/wallet-core/eu.europa.ec.eudi.wallet/-eudi-wallet-impl/index.md index e042ba40..045af6d6 100644 --- a/docs/wallet-core/eu.europa.ec.eudi.wallet/-eudi-wallet-impl/index.md +++ b/docs/wallet-core/eu.europa.ec.eudi.wallet/-eudi-wallet-impl/index.md @@ -27,27 +27,27 @@ Implementation of [EudiWallet](../-eudi-wallet/index.md) ## Functions -| Name | Summary | -|---------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [addTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-1321081126%2FFunctions%2F1615067946) | [androidJvm]
open override fun [addTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-1321081126%2FFunctions%2F1615067946)(listener: TransferEvent.Listener): TransferEvent.Listenable | -| [createDocument](index.md#-512787063%2FFunctions%2F1615067946) | [androidJvm]
open override fun [createDocument](index.md#-512787063%2FFunctions%2F1615067946)(format: DocumentFormat, createSettings: CreateDocumentSettings): Outcome<UnsignedDocument> | -| [createOpenId4VciManager](create-open-id4-vci-manager.md) | [androidJvm]
open override fun [createOpenId4VciManager](create-open-id4-vci-manager.md)(): [OpenId4VciManager](../../eu.europa.ec.eudi.wallet.issue.openid4vci/-open-id4-vci-manager/index.md)
Create an instance of [OpenId4VciManager](../../eu.europa.ec.eudi.wallet.issue.openid4vci/-open-id4-vci-manager/index.md) for the wallet to interact with the OpenId4Vci service | -| [deleteDocumentById](index.md#1380499670%2FFunctions%2F1615067946) | [androidJvm]
open override fun [deleteDocumentById](index.md#1380499670%2FFunctions%2F1615067946)(documentId: DocumentId): Outcome<ProofOfDeletion?> | -| [disableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/disable-n-f-c-engagement.md) | [androidJvm]
open override fun [disableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/disable-n-f-c-engagement.md)(activity: [ComponentActivity](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.html)): [PresentationManager](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md)
Disable the NFC device engagement for the wallet. This method should be called in the activity's ComponentActivity.onPause method. | -| [enableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/enable-n-f-c-engagement.md) | [androidJvm]
open override fun [enableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/enable-n-f-c-engagement.md)(activity: [ComponentActivity](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.html)): [PresentationManager](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md)
Enable the NFC device engagement for the wallet. This method should be called in the activity's ComponentActivity.onResume method. | -| [enumerateSecureAreas](../-eudi-wallet/enumerate-secure-areas.md) | [androidJvm]
open fun [enumerateSecureAreas](../-eudi-wallet/enumerate-secure-areas.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)>
Enumerate the secure areas available in the wallet | -| [getDefaultCreateDocumentSettings](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) | [androidJvm]
@[JvmName](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index.html)(name = "getDefaultCreateDocumentSettings")
@[JvmOverloads](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-overloads/index.html)
fun [EudiWallet](../-eudi-wallet/index.md).[getDefaultCreateDocumentSettings](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md)(secureAreaIdentifier: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? = null, attestationChallenge: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)? = null, configure: AndroidKeystoreCreateKeySettings.Builder.() -> [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)? = null): CreateDocumentSettings
Returns the default CreateDocumentSettings for the [EudiWallet](../-eudi-wallet/index.md) instance. The default settings are based on the EudiWalletConfig and the first available AndroidKeystoreSecureArea implementation. The [attestationChallenge](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) is generated using a [SecureRandom](https://developer.android.com/reference/kotlin/java/security/SecureRandom.html) instance. The [configure](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) lambda can be used to further customize the AndroidKeystoreCreateKeySettings. If [secureAreaIdentifier](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) is not provided, the first available AndroidKeystoreSecureArea implementation is used. | -| [getDefaultKeyUnlockData](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-key-unlock-data.md) | [androidJvm]
fun [EudiWallet](../-eudi-wallet/index.md).[getDefaultKeyUnlockData](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-key-unlock-data.md)(documentId: DocumentId): AndroidKeystoreKeyUnlockData?
Returns the default AndroidKeystoreKeyUnlockData for the given DocumentId. The default key unlock data is based on the Document.keyAlias. | -| [getDocumentById](index.md#-233386509%2FFunctions%2F1615067946) | [androidJvm]
open override fun [getDocumentById](index.md#-233386509%2FFunctions%2F1615067946)(documentId: DocumentId): Document? | -| [getDocuments](index.md#-1741352450%2FFunctions%2F1615067946) | [androidJvm]
open override fun [getDocuments](index.md#-1741352450%2FFunctions%2F1615067946)(predicate: (Document) -> [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)?): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<Document> | -| [loadMdocSampleDocuments](index.md#408834997%2FFunctions%2F1615067946) | [androidJvm]
open override fun [loadMdocSampleDocuments](index.md#408834997%2FFunctions%2F1615067946)(sampleData: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html), createSettings: CreateDocumentSettings, documentNamesMap: [Map](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)<DocType, [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)>?): Outcome<[List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<DocumentId>> | -| [removeAllTransferEventListeners](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-812467576%2FFunctions%2F1615067946) | [androidJvm]
open override fun [removeAllTransferEventListeners](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-812467576%2FFunctions%2F1615067946)(): TransferEvent.Listenable | -| [removeTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#1314902509%2FFunctions%2F1615067946) | [androidJvm]
open override fun [removeTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#1314902509%2FFunctions%2F1615067946)(listener: TransferEvent.Listener): TransferEvent.Listenable | -| [sendResponse](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/send-response.md) | [androidJvm]
open override fun [sendResponse](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/send-response.md)(response: Response)
Send a response to verifier | -| [setReaderTrustStore](set-reader-trust-store.md) | [androidJvm]
open override fun [setReaderTrustStore](set-reader-trust-store.md)(readerTrustStore: ReaderTrustStore): [EudiWalletImpl](index.md)
Sets the reader trust store with the given ReaderTrustStore. This method is useful when the reader trust store is not set in the configuration object, or when the reader trust store needs to be updated at runtime. | -| [setTrustedReaderCertificates](set-trusted-reader-certificates.md) | [androidJvm]
open override fun [setTrustedReaderCertificates](set-trusted-reader-certificates.md)(vararg rawRes: [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)): [EudiWalletImpl](index.md)
Sets the reader trust store with the given list of raw resource IDs. This method is useful when the reader trust store is not set in the configuration object, or when the reader trust store needs to be updated at runtime.
[androidJvm]
open override fun [setTrustedReaderCertificates](set-trusted-reader-certificates.md)(trustedReaderCertificates: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html)>): [EudiWalletImpl](index.md)
Sets the reader trust store with the given list of [X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html). This method is useful when the reader trust store is not set in the configuration object, or when the reader trust store needs to be updated at runtime. | -| [startProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-proximity-presentation.md) | [androidJvm]
open override fun [startProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-proximity-presentation.md)()
Starts the proximity presentation. The QR code is available through the TransferEvent.QrEngagementReady event which is triggered almost immediately after calling this method. The wallet should display the QR code to the verifier in order to start the proximity presentation. | -| [startRemotePresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-remote-presentation.md) | [androidJvm]
open override fun [startRemotePresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-remote-presentation.md)(uri: [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html))
Start a remote presentation with the given URI The URI could be either | -| [stopProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/stop-proximity-presentation.md) | [androidJvm]
open override fun [stopProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/stop-proximity-presentation.md)(flags: [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html))
Stops the proximity presentation. Method receives flags that can be used to control the session termination. The available flags are: | -| [storeDeferredDocument](index.md#144040139%2FFunctions%2F1615067946) | [androidJvm]
open override fun [storeDeferredDocument](index.md#144040139%2FFunctions%2F1615067946)(unsignedDocument: UnsignedDocument, relatedData: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)): Outcome<DeferredDocument> | -| [storeIssuedDocument](index.md#-557883369%2FFunctions%2F1615067946) | [androidJvm]
open override fun [storeIssuedDocument](index.md#-557883369%2FFunctions%2F1615067946)(unsignedDocument: UnsignedDocument, issuerProvidedData: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)): Outcome<IssuedDocument> | +| Name | Summary | +|---------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [addTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-1321081126%2FFunctions%2F1615067946) | [androidJvm]
open override fun [addTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-1321081126%2FFunctions%2F1615067946)(listener: TransferEvent.Listener): TransferEvent.Listenable | +| [createDocument](index.md#-512787063%2FFunctions%2F1615067946) | [androidJvm]
open override fun [createDocument](index.md#-512787063%2FFunctions%2F1615067946)(format: DocumentFormat, createSettings: CreateDocumentSettings): Outcome<UnsignedDocument> | +| [createOpenId4VciManager](create-open-id4-vci-manager.md) | [androidJvm]
open override fun [createOpenId4VciManager](create-open-id4-vci-manager.md)(): [OpenId4VciManager](../../eu.europa.ec.eudi.wallet.issue.openid4vci/-open-id4-vci-manager/index.md)
Create an instance of [OpenId4VciManager](../../eu.europa.ec.eudi.wallet.issue.openid4vci/-open-id4-vci-manager/index.md) for the wallet to interact with the OpenId4Vci service | +| [deleteDocumentById](index.md#1380499670%2FFunctions%2F1615067946) | [androidJvm]
open override fun [deleteDocumentById](index.md#1380499670%2FFunctions%2F1615067946)(documentId: DocumentId): Outcome<ProofOfDeletion?> | +| [disableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/disable-n-f-c-engagement.md) | [androidJvm]
open override fun [disableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/disable-n-f-c-engagement.md)(activity: [ComponentActivity](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.html)): [PresentationManager](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md)
Disable the NFC device engagement for the wallet. This method should be called in the activity's ComponentActivity.onPause method. | +| [enableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/enable-n-f-c-engagement.md) | [androidJvm]
open override fun [enableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/enable-n-f-c-engagement.md)(activity: [ComponentActivity](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.html)): [PresentationManager](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md)
Enable the NFC device engagement for the wallet. This method should be called in the activity's ComponentActivity.onResume method. | +| [enumerateSecureAreas](../-eudi-wallet/enumerate-secure-areas.md) | [androidJvm]
open fun [enumerateSecureAreas](../-eudi-wallet/enumerate-secure-areas.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)>
Enumerate the secure areas available in the wallet | +| [getDefaultCreateDocumentSettings](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) | [androidJvm]
@[JvmName](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index.html)(name = "getDefaultCreateDocumentSettings")
@[JvmOverloads](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-overloads/index.html)
@[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html)
fun [EudiWallet](../-eudi-wallet/index.md).[getDefaultCreateDocumentSettings](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md)(attestationChallenge: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)? = null, configure: AndroidKeystoreCreateKeySettings.Builder.() -> [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)? = null): CreateDocumentSettings
Returns the default CreateDocumentSettings for the [EudiWallet](../-eudi-wallet/index.md) instance. The default settings are based on the [EudiWalletConfig](../-eudi-wallet-config/index.md) and the first available AndroidKeystoreSecureArea implementation. The [attestationChallenge](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) is generated using a [SecureRandom](https://developer.android.com/reference/kotlin/java/security/SecureRandom.html) instance. The [configure](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) lambda can be used to further customize the AndroidKeystoreCreateKeySettings. The first available AndroidKeystoreSecureArea implementation is used. | +| [getDefaultKeyUnlockData](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-key-unlock-data.md) | [androidJvm]
@[JvmName](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index.html)(name = "getDefaultKeyUnlockData")
@[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html)
fun [EudiWallet](../-eudi-wallet/index.md).[getDefaultKeyUnlockData](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-key-unlock-data.md)(documentId: DocumentId): AndroidKeystoreKeyUnlockData?
Returns the default AndroidKeystoreKeyUnlockData for the given DocumentId. The default key unlock data is based on the Document.keyAlias. | +| [getDocumentById](index.md#-233386509%2FFunctions%2F1615067946) | [androidJvm]
open override fun [getDocumentById](index.md#-233386509%2FFunctions%2F1615067946)(documentId: DocumentId): Document? | +| [getDocuments](index.md#-1741352450%2FFunctions%2F1615067946) | [androidJvm]
open override fun [getDocuments](index.md#-1741352450%2FFunctions%2F1615067946)(predicate: (Document) -> [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)?): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<Document> | +| [loadMdocSampleDocuments](index.md#408834997%2FFunctions%2F1615067946) | [androidJvm]
open override fun [loadMdocSampleDocuments](index.md#408834997%2FFunctions%2F1615067946)(sampleData: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html), createSettings: CreateDocumentSettings, documentNamesMap: [Map](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)<DocType, [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)>?): Outcome<[List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<DocumentId>> | +| [removeAllTransferEventListeners](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-812467576%2FFunctions%2F1615067946) | [androidJvm]
open override fun [removeAllTransferEventListeners](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-812467576%2FFunctions%2F1615067946)(): TransferEvent.Listenable | +| [removeTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#1314902509%2FFunctions%2F1615067946) | [androidJvm]
open override fun [removeTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#1314902509%2FFunctions%2F1615067946)(listener: TransferEvent.Listener): TransferEvent.Listenable | +| [sendResponse](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/send-response.md) | [androidJvm]
open override fun [sendResponse](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/send-response.md)(response: Response)
Send a response to verifier | +| [setReaderTrustStore](set-reader-trust-store.md) | [androidJvm]
open override fun [setReaderTrustStore](set-reader-trust-store.md)(readerTrustStore: ReaderTrustStore): [EudiWalletImpl](index.md)
Sets the reader trust store with the given ReaderTrustStore. This method is useful when the reader trust store is not set in the configuration object, or when the reader trust store needs to be updated at runtime. | +| [setTrustedReaderCertificates](set-trusted-reader-certificates.md) | [androidJvm]
open override fun [setTrustedReaderCertificates](set-trusted-reader-certificates.md)(vararg rawRes: [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)): [EudiWalletImpl](index.md)
Sets the reader trust store with the given list of raw resource IDs. This method is useful when the reader trust store is not set in the configuration object, or when the reader trust store needs to be updated at runtime.
[androidJvm]
open override fun [setTrustedReaderCertificates](set-trusted-reader-certificates.md)(trustedReaderCertificates: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html)>): [EudiWalletImpl](index.md)
Sets the reader trust store with the given list of [X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html). This method is useful when the reader trust store is not set in the configuration object, or when the reader trust store needs to be updated at runtime. | +| [startProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-proximity-presentation.md) | [androidJvm]
open override fun [startProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-proximity-presentation.md)()
Starts the proximity presentation. The QR code is available through the TransferEvent.QrEngagementReady event which is triggered almost immediately after calling this method. The wallet should display the QR code to the verifier in order to start the proximity presentation. | +| [startRemotePresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-remote-presentation.md) | [androidJvm]
open override fun [startRemotePresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-remote-presentation.md)(uri: [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html))
Start a remote presentation with the given URI The URI could be either | +| [stopProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/stop-proximity-presentation.md) | [androidJvm]
open override fun [stopProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/stop-proximity-presentation.md)(flags: [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html))
Stops the proximity presentation. Method receives flags that can be used to control the session termination. The available flags are: | +| [storeDeferredDocument](index.md#144040139%2FFunctions%2F1615067946) | [androidJvm]
open override fun [storeDeferredDocument](index.md#144040139%2FFunctions%2F1615067946)(unsignedDocument: UnsignedDocument, relatedData: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)): Outcome<DeferredDocument> | +| [storeIssuedDocument](index.md#-557883369%2FFunctions%2F1615067946) | [androidJvm]
open override fun [storeIssuedDocument](index.md#-557883369%2FFunctions%2F1615067946)(unsignedDocument: UnsignedDocument, issuerProvidedData: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)): Outcome<IssuedDocument> | diff --git a/docs/wallet-core/eu.europa.ec.eudi.wallet/-eudi-wallet/index.md b/docs/wallet-core/eu.europa.ec.eudi.wallet/-eudi-wallet/index.md index 8a6b044c..7e0e90bc 100644 --- a/docs/wallet-core/eu.europa.ec.eudi.wallet/-eudi-wallet/index.md +++ b/docs/wallet-core/eu.europa.ec.eudi.wallet/-eudi-wallet/index.md @@ -47,27 +47,27 @@ method or the [Builder](-builder/index.md) class. ## Functions -| Name | Summary | -|---------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [addTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-1321081126%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [addTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-1321081126%2FFunctions%2F1615067946)(listener: TransferEvent.Listener): TransferEvent.Listenable | -| [createDocument](../-eudi-wallet-impl/index.md#-512787063%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [createDocument](../-eudi-wallet-impl/index.md#-512787063%2FFunctions%2F1615067946)(format: DocumentFormat, createSettings: CreateDocumentSettings): Outcome<UnsignedDocument> | -| [createOpenId4VciManager](create-open-id4-vci-manager.md) | [androidJvm]
abstract fun [createOpenId4VciManager](create-open-id4-vci-manager.md)(): [OpenId4VciManager](../../eu.europa.ec.eudi.wallet.issue.openid4vci/-open-id4-vci-manager/index.md)
Create an instance of [OpenId4VciManager](../../eu.europa.ec.eudi.wallet.issue.openid4vci/-open-id4-vci-manager/index.md) for the wallet to interact with the OpenId4Vci service | -| [deleteDocumentById](../-eudi-wallet-impl/index.md#1380499670%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [deleteDocumentById](../-eudi-wallet-impl/index.md#1380499670%2FFunctions%2F1615067946)(documentId: DocumentId): Outcome<ProofOfDeletion?> | -| [disableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/disable-n-f-c-engagement.md) | [androidJvm]
abstract fun [disableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/disable-n-f-c-engagement.md)(activity: [ComponentActivity](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.html)): [PresentationManager](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md)
Disable the NFC device engagement for the wallet. This method should be called in the activity's [ComponentActivity.onPause](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.html#onpause) method. | -| [enableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/enable-n-f-c-engagement.md) | [androidJvm]
abstract fun [enableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/enable-n-f-c-engagement.md)(activity: [ComponentActivity](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.html)): [PresentationManager](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md)
Enable the NFC device engagement for the wallet. This method should be called in the activity's [ComponentActivity.onResume](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.html#onresume) method. | -| [enumerateSecureAreas](enumerate-secure-areas.md) | [androidJvm]
open fun [enumerateSecureAreas](enumerate-secure-areas.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)>
Enumerate the secure areas available in the wallet | -| [getDefaultCreateDocumentSettings](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) | [androidJvm]
@[JvmName](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index.html)(name = "getDefaultCreateDocumentSettings")
@[JvmOverloads](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-overloads/index.html)
fun [EudiWallet](index.md).[getDefaultCreateDocumentSettings](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md)(secureAreaIdentifier: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? = null, attestationChallenge: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)? = null, configure: AndroidKeystoreCreateKeySettings.Builder.() -> [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)? = null): CreateDocumentSettings
Returns the default CreateDocumentSettings for the [EudiWallet](index.md) instance. The default settings are based on the EudiWalletConfig and the first available AndroidKeystoreSecureArea implementation. The [attestationChallenge](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) is generated using a [SecureRandom](https://developer.android.com/reference/kotlin/java/security/SecureRandom.html) instance. The [configure](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) lambda can be used to further customize the AndroidKeystoreCreateKeySettings. If [secureAreaIdentifier](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) is not provided, the first available AndroidKeystoreSecureArea implementation is used. | -| [getDefaultKeyUnlockData](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-key-unlock-data.md) | [androidJvm]
fun [EudiWallet](index.md).[getDefaultKeyUnlockData](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-key-unlock-data.md)(documentId: DocumentId): AndroidKeystoreKeyUnlockData?
Returns the default AndroidKeystoreKeyUnlockData for the given DocumentId. The default key unlock data is based on the Document.keyAlias. | -| [getDocumentById](../-eudi-wallet-impl/index.md#-233386509%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [getDocumentById](../-eudi-wallet-impl/index.md#-233386509%2FFunctions%2F1615067946)(documentId: DocumentId): Document? | -| [getDocuments](../-eudi-wallet-impl/index.md#-1741352450%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [getDocuments](../-eudi-wallet-impl/index.md#-1741352450%2FFunctions%2F1615067946)(predicate: (Document) -> [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)?): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<Document> | -| [loadMdocSampleDocuments](../-eudi-wallet-impl/index.md#408834997%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [loadMdocSampleDocuments](../-eudi-wallet-impl/index.md#408834997%2FFunctions%2F1615067946)(sampleData: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html), createSettings: CreateDocumentSettings, documentNamesMap: [Map](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)<DocType, [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)>?): Outcome<[List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<DocumentId>> | -| [removeAllTransferEventListeners](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-812467576%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [removeAllTransferEventListeners](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-812467576%2FFunctions%2F1615067946)(): TransferEvent.Listenable | -| [removeTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#1314902509%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [removeTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#1314902509%2FFunctions%2F1615067946)(listener: TransferEvent.Listener): TransferEvent.Listenable | -| [sendResponse](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/send-response.md) | [androidJvm]
abstract fun [sendResponse](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/send-response.md)(response: Response)
Send a response to verifier | -| [setReaderTrustStore](set-reader-trust-store.md) | [androidJvm]
abstract fun [setReaderTrustStore](set-reader-trust-store.md)(readerTrustStore: ReaderTrustStore): [EudiWallet](index.md)
Sets the reader trust store with the given ReaderTrustStore. This method is useful when the reader trust store is not set in the configuration object, or when the reader trust store needs to be updated at runtime. | -| [setTrustedReaderCertificates](set-trusted-reader-certificates.md) | [androidJvm]
abstract fun [setTrustedReaderCertificates](set-trusted-reader-certificates.md)(@[RawRes](https://developer.android.com/reference/kotlin/androidx/annotation/RawRes.html)vararg rawRes: [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)): [EudiWallet](index.md)
Sets the reader trust store with the given list of raw resource IDs. This method is useful when the reader trust store is not set in the configuration object, or when the reader trust store needs to be updated at runtime.
[androidJvm]
abstract fun [setTrustedReaderCertificates](set-trusted-reader-certificates.md)(trustedReaderCertificates: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html)>): [EudiWallet](index.md)
Sets the reader trust store with the given list of [X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html). This method is useful when the reader trust store is not set in the configuration object, or when the reader trust store needs to be updated at runtime. | -| [startProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-proximity-presentation.md) | [androidJvm]
abstract fun [startProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-proximity-presentation.md)()
Starts the proximity presentation. The QR code is available through the TransferEvent.QrEngagementReady event which is triggered almost immediately after calling this method. The wallet should display the QR code to the verifier in order to start the proximity presentation. | -| [startRemotePresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-remote-presentation.md) | [androidJvm]
abstract fun [startRemotePresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-remote-presentation.md)(uri: [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html))
Start a remote presentation with the given URI The URI could be either | -| [stopProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/stop-proximity-presentation.md) | [androidJvm]
abstract fun [stopProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/stop-proximity-presentation.md)(flags: [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) = SEND_SESSION_TERMINATION_MESSAGE)
Stops the proximity presentation. Method receives flags that can be used to control the session termination. The available flags are: | -| [storeDeferredDocument](../-eudi-wallet-impl/index.md#144040139%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [storeDeferredDocument](../-eudi-wallet-impl/index.md#144040139%2FFunctions%2F1615067946)(unsignedDocument: UnsignedDocument, relatedData: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)): Outcome<DeferredDocument> | -| [storeIssuedDocument](../-eudi-wallet-impl/index.md#-557883369%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [storeIssuedDocument](../-eudi-wallet-impl/index.md#-557883369%2FFunctions%2F1615067946)(unsignedDocument: UnsignedDocument, issuerProvidedData: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)): Outcome<IssuedDocument> | +| Name | Summary | +|---------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [addTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-1321081126%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [addTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-1321081126%2FFunctions%2F1615067946)(listener: TransferEvent.Listener): TransferEvent.Listenable | +| [createDocument](../-eudi-wallet-impl/index.md#-512787063%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [createDocument](../-eudi-wallet-impl/index.md#-512787063%2FFunctions%2F1615067946)(format: DocumentFormat, createSettings: CreateDocumentSettings): Outcome<UnsignedDocument> | +| [createOpenId4VciManager](create-open-id4-vci-manager.md) | [androidJvm]
abstract fun [createOpenId4VciManager](create-open-id4-vci-manager.md)(): [OpenId4VciManager](../../eu.europa.ec.eudi.wallet.issue.openid4vci/-open-id4-vci-manager/index.md)
Create an instance of [OpenId4VciManager](../../eu.europa.ec.eudi.wallet.issue.openid4vci/-open-id4-vci-manager/index.md) for the wallet to interact with the OpenId4Vci service | +| [deleteDocumentById](../-eudi-wallet-impl/index.md#1380499670%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [deleteDocumentById](../-eudi-wallet-impl/index.md#1380499670%2FFunctions%2F1615067946)(documentId: DocumentId): Outcome<ProofOfDeletion?> | +| [disableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/disable-n-f-c-engagement.md) | [androidJvm]
abstract fun [disableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/disable-n-f-c-engagement.md)(activity: [ComponentActivity](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.html)): [PresentationManager](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md)
Disable the NFC device engagement for the wallet. This method should be called in the activity's [ComponentActivity.onPause](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.html#onpause) method. | +| [enableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/enable-n-f-c-engagement.md) | [androidJvm]
abstract fun [enableNFCEngagement](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/enable-n-f-c-engagement.md)(activity: [ComponentActivity](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.html)): [PresentationManager](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md)
Enable the NFC device engagement for the wallet. This method should be called in the activity's [ComponentActivity.onResume](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.html#onresume) method. | +| [enumerateSecureAreas](enumerate-secure-areas.md) | [androidJvm]
open fun [enumerateSecureAreas](enumerate-secure-areas.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)>
Enumerate the secure areas available in the wallet | +| [getDefaultCreateDocumentSettings](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) | [androidJvm]
@[JvmName](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index.html)(name = "getDefaultCreateDocumentSettings")
@[JvmOverloads](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-overloads/index.html)
@[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html)
fun [EudiWallet](index.md).[getDefaultCreateDocumentSettings](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md)(attestationChallenge: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)? = null, configure: AndroidKeystoreCreateKeySettings.Builder.() -> [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)? = null): CreateDocumentSettings
Returns the default CreateDocumentSettings for the [EudiWallet](index.md) instance. The default settings are based on the [EudiWalletConfig](../-eudi-wallet-config/index.md) and the first available AndroidKeystoreSecureArea implementation. The [attestationChallenge](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) is generated using a [SecureRandom](https://developer.android.com/reference/kotlin/java/security/SecureRandom.html) instance. The [configure](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md) lambda can be used to further customize the AndroidKeystoreCreateKeySettings. The first available AndroidKeystoreSecureArea implementation is used. | +| [getDefaultKeyUnlockData](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-key-unlock-data.md) | [androidJvm]
@[JvmName](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index.html)(name = "getDefaultKeyUnlockData")
@[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html)
fun [EudiWallet](index.md).[getDefaultKeyUnlockData](../../eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-key-unlock-data.md)(documentId: DocumentId): AndroidKeystoreKeyUnlockData?
Returns the default AndroidKeystoreKeyUnlockData for the given DocumentId. The default key unlock data is based on the Document.keyAlias. | +| [getDocumentById](../-eudi-wallet-impl/index.md#-233386509%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [getDocumentById](../-eudi-wallet-impl/index.md#-233386509%2FFunctions%2F1615067946)(documentId: DocumentId): Document? | +| [getDocuments](../-eudi-wallet-impl/index.md#-1741352450%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [getDocuments](../-eudi-wallet-impl/index.md#-1741352450%2FFunctions%2F1615067946)(predicate: (Document) -> [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)?): [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<Document> | +| [loadMdocSampleDocuments](../-eudi-wallet-impl/index.md#408834997%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [loadMdocSampleDocuments](../-eudi-wallet-impl/index.md#408834997%2FFunctions%2F1615067946)(sampleData: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html), createSettings: CreateDocumentSettings, documentNamesMap: [Map](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)<DocType, [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)>?): Outcome<[List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<DocumentId>> | +| [removeAllTransferEventListeners](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-812467576%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [removeAllTransferEventListeners](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#-812467576%2FFunctions%2F1615067946)(): TransferEvent.Listenable | +| [removeTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#1314902509%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [removeTransferEventListener](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/index.md#1314902509%2FFunctions%2F1615067946)(listener: TransferEvent.Listener): TransferEvent.Listenable | +| [sendResponse](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/send-response.md) | [androidJvm]
abstract fun [sendResponse](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/send-response.md)(response: Response)
Send a response to verifier | +| [setReaderTrustStore](set-reader-trust-store.md) | [androidJvm]
abstract fun [setReaderTrustStore](set-reader-trust-store.md)(readerTrustStore: ReaderTrustStore): [EudiWallet](index.md)
Sets the reader trust store with the given ReaderTrustStore. This method is useful when the reader trust store is not set in the configuration object, or when the reader trust store needs to be updated at runtime. | +| [setTrustedReaderCertificates](set-trusted-reader-certificates.md) | [androidJvm]
abstract fun [setTrustedReaderCertificates](set-trusted-reader-certificates.md)(@[RawRes](https://developer.android.com/reference/kotlin/androidx/annotation/RawRes.html)vararg rawRes: [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)): [EudiWallet](index.md)
Sets the reader trust store with the given list of raw resource IDs. This method is useful when the reader trust store is not set in the configuration object, or when the reader trust store needs to be updated at runtime.
[androidJvm]
abstract fun [setTrustedReaderCertificates](set-trusted-reader-certificates.md)(trustedReaderCertificates: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html)>): [EudiWallet](index.md)
Sets the reader trust store with the given list of [X509Certificate](https://developer.android.com/reference/kotlin/java/security/cert/X509Certificate.html). This method is useful when the reader trust store is not set in the configuration object, or when the reader trust store needs to be updated at runtime. | +| [startProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-proximity-presentation.md) | [androidJvm]
abstract fun [startProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-proximity-presentation.md)()
Starts the proximity presentation. The QR code is available through the TransferEvent.QrEngagementReady event which is triggered almost immediately after calling this method. The wallet should display the QR code to the verifier in order to start the proximity presentation. | +| [startRemotePresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-remote-presentation.md) | [androidJvm]
abstract fun [startRemotePresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/start-remote-presentation.md)(uri: [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html))
Start a remote presentation with the given URI The URI could be either | +| [stopProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/stop-proximity-presentation.md) | [androidJvm]
abstract fun [stopProximityPresentation](../../eu.europa.ec.eudi.wallet.presentation/-presentation-manager/stop-proximity-presentation.md)(flags: [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) = SEND_SESSION_TERMINATION_MESSAGE)
Stops the proximity presentation. Method receives flags that can be used to control the session termination. The available flags are: | +| [storeDeferredDocument](../-eudi-wallet-impl/index.md#144040139%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [storeDeferredDocument](../-eudi-wallet-impl/index.md#144040139%2FFunctions%2F1615067946)(unsignedDocument: UnsignedDocument, relatedData: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)): Outcome<DeferredDocument> | +| [storeIssuedDocument](../-eudi-wallet-impl/index.md#-557883369%2FFunctions%2F1615067946) | [androidJvm]
abstract fun [storeIssuedDocument](../-eudi-wallet-impl/index.md#-557883369%2FFunctions%2F1615067946)(unsignedDocument: UnsignedDocument, issuerProvidedData: [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)): Outcome<IssuedDocument> | diff --git a/docs/wallet-core/package-list b/docs/wallet-core/package-list index 4fbd7fb8..1e8924e2 100644 --- a/docs/wallet-core/package-list +++ b/docs/wallet-core/package-list @@ -3,7 +3,7 @@ $dokka.linkExtension:md $dokka.location:eu.europa.ec.eudi.wallet.document////PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.document/index.md $dokka.location:eu.europa.ec.eudi.wallet.document/DocumentExtensions///PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/index.md $dokka.location:eu.europa.ec.eudi.wallet.document/DocumentExtensions/DefaultKeyUnlockData/eu.europa.ec.eudi.wallet.document.Document#/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/-default-key-unlock-data.md -$dokka.location:eu.europa.ec.eudi.wallet.document/DocumentExtensions/getDefaultCreateDocumentSettings/eu.europa.ec.eudi.wallet.EudiWallet#kotlin.String?#kotlin.ByteArray?#kotlin.Function1[com.android.identity.android.securearea.AndroidKeystoreCreateKeySettings.Builder,kotlin.Unit]?/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md +$dokka.location:eu.europa.ec.eudi.wallet.document/DocumentExtensions/getDefaultCreateDocumentSettings/eu.europa.ec.eudi.wallet.EudiWallet#kotlin.ByteArray?#kotlin.Function1[com.android.identity.android.securearea.AndroidKeystoreCreateKeySettings.Builder,kotlin.Unit]?/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-create-document-settings.md $dokka.location:eu.europa.ec.eudi.wallet.document/DocumentExtensions/getDefaultKeyUnlockData/eu.europa.ec.eudi.wallet.EudiWallet#kotlin.String/PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.document/-document-extensions/get-default-key-unlock-data.md $dokka.location:eu.europa.ec.eudi.wallet.issue.openid4vci////PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.issue.openid4vci/index.md $dokka.location:eu.europa.ec.eudi.wallet.issue.openid4vci/AccessTokenTO.Companion///PointingToDeclaration/wallet-core/eu.europa.ec.eudi.wallet.issue.openid4vci/-access-token-t-o/-companion/index.md diff --git a/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/document/DocumentExtensions.kt b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/document/DocumentExtensions.kt index ada5a38f..a06ced66 100644 --- a/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/document/DocumentExtensions.kt +++ b/wallet-core/src/main/java/eu/europa/ec/eudi/wallet/document/DocumentExtensions.kt @@ -17,10 +17,12 @@ package eu.europa.ec.eudi.wallet.document import com.android.identity.android.securearea.AndroidKeystoreCreateKeySettings +import com.android.identity.android.securearea.AndroidKeystoreKeyInfo import com.android.identity.android.securearea.AndroidKeystoreKeyUnlockData import com.android.identity.android.securearea.AndroidKeystoreSecureArea import com.android.identity.android.securearea.UserAuthenticationType import eu.europa.ec.eudi.wallet.EudiWallet +import eu.europa.ec.eudi.wallet.EudiWalletConfig import java.security.SecureRandom object DocumentExtensions { @@ -29,26 +31,41 @@ object DocumentExtensions { * The default key unlock data is based on the [Document.keyAlias]. * @see [AndroidKeystoreKeyUnlockData] * @see [Document] - * + * @throws IllegalStateException if the [Document] is not managed by [AndroidKeystoreSecureArea] * @receiver the [Document] instance - * @return the default [AndroidKeystoreKeyUnlockData] for the [Document] instance + * @return the default [AndroidKeystoreKeyUnlockData] for the [Document] instance if document requires user authentication */ @get:JvmName("getDefaultKeyUnlockData") - val Document.DefaultKeyUnlockData: AndroidKeystoreKeyUnlockData - get() = AndroidKeystoreKeyUnlockData(keyAlias) + @get:Throws(IllegalStateException::class) + @get:JvmStatic + val Document.DefaultKeyUnlockData: AndroidKeystoreKeyUnlockData? + get() = when (val ki = keyInfo) { + is AndroidKeystoreKeyInfo -> ki.takeIf { it.isUserAuthenticationRequired } + ?.let { AndroidKeystoreKeyUnlockData(keyAlias) } + + else -> throw IllegalStateException("Document is not managed by AndroidKeystoreSecureArea") + } /** * Returns the default [AndroidKeystoreKeyUnlockData] for the given [DocumentId]. * The default key unlock data is based on the [Document.keyAlias]. * @see [AndroidKeystoreKeyUnlockData] * @see [Document] - * + * @throws IllegalStateException if the [Document] is not managed by [AndroidKeystoreSecureArea] + * @throws NoSuchElementException if the document is not found by the [DocumentId] * @receiver the [EudiWallet] instance * @param documentId the [DocumentId] of the document - * @return the default [AndroidKeystoreKeyUnlockData] for the given [DocumentId] or null if the document is not found + * @return the default [AndroidKeystoreKeyUnlockData] for the given [DocumentId] or null + * if the document requires no user authentication */ + @JvmName("getDefaultKeyUnlockData") + @Throws(NoSuchElementException::class, IllegalStateException::class) + @JvmStatic fun EudiWallet.getDefaultKeyUnlockData(documentId: DocumentId): AndroidKeystoreKeyUnlockData? { - return getDocumentById(documentId)?.DefaultKeyUnlockData + return when (val document = getDocumentById(documentId)) { + null -> throw NoSuchElementException("Document not found") + else -> document.DefaultKeyUnlockData + } } /** @@ -57,8 +74,7 @@ object DocumentExtensions { * [AndroidKeystoreSecureArea] implementation. * The [attestationChallenge] is generated using a [SecureRandom] instance. * The [configure] lambda can be used to further customize the [AndroidKeystoreCreateKeySettings]. - * If [secureAreaIdentifier] is not provided, the first available [AndroidKeystoreSecureArea] implementation - * is used. + * The first available [AndroidKeystoreSecureArea] implementation is used. * @throws NoSuchElementException if no [AndroidKeystoreSecureArea] implementation is available * @see [AndroidKeystoreCreateKeySettings.Builder] * @see [AndroidKeystoreCreateKeySettings] @@ -66,18 +82,26 @@ object DocumentExtensions { * @see [CreateDocumentSettings] * * @receiver the [EudiWallet] instance - * @param secureAreaIdentifier the [AndroidKeystoreSecureArea.identifier] where the document's keys should be stored * @param attestationChallenge the attestation challenge to use when creating the keys * @param configure a lambda to further customize the [AndroidKeystoreCreateKeySettings] */ @JvmName("getDefaultCreateDocumentSettings") @Throws(NoSuchElementException::class) @JvmOverloads + @JvmStatic fun EudiWallet.getDefaultCreateDocumentSettings( - secureAreaIdentifier: String? = null, attestationChallenge: ByteArray? = null, configure: (AndroidKeystoreCreateKeySettings.Builder.() -> Unit)? = null, ): CreateDocumentSettings { + + val secureAreaIdentifier = secureAreaRepository + .implementations + .filterIsInstance() + .firstOrNull() + ?.identifier + ?: throw NoSuchElementException("No AndroidKeystoreSecureArea implementation available") + + val attestationChallengeToUse = attestationChallenge ?: SecureRandom().let { secureRandom -> ByteArray(32).also { secureRandom.nextBytes(it) } } @@ -96,13 +120,8 @@ object DocumentExtensions { else -> builder.apply(configure) }.build() - val secureAreaIdentifierToUse = secureAreaIdentifier ?: secureAreaRepository - .implementations - .first { it is AndroidKeystoreSecureArea } - .identifier - return CreateDocumentSettings( - secureAreaIdentifier = secureAreaIdentifierToUse, + secureAreaIdentifier = secureAreaIdentifier, createKeySettings = createKeySettings ) } diff --git a/wallet-core/src/test/java/eu/europa/ec/eudi/wallet/document/DocumentExtensionsTest.kt b/wallet-core/src/test/java/eu/europa/ec/eudi/wallet/document/DocumentExtensionsTest.kt new file mode 100644 index 00000000..51b13758 --- /dev/null +++ b/wallet-core/src/test/java/eu/europa/ec/eudi/wallet/document/DocumentExtensionsTest.kt @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2024 European Commission + * + * 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 eu.europa.ec.eudi.wallet.document + +import com.android.identity.android.securearea.AndroidKeystoreCreateKeySettings +import com.android.identity.android.securearea.AndroidKeystoreKeyInfo +import com.android.identity.android.securearea.AndroidKeystoreKeyUnlockData +import com.android.identity.android.securearea.AndroidKeystoreSecureArea +import com.android.identity.android.securearea.UserAuthenticationType +import com.android.identity.crypto.EcCurve +import com.android.identity.securearea.KeyInfo +import com.android.identity.securearea.SecureArea +import eu.europa.ec.eudi.wallet.EudiWallet +import eu.europa.ec.eudi.wallet.EudiWalletConfig +import eu.europa.ec.eudi.wallet.document.DocumentExtensions.DefaultKeyUnlockData +import eu.europa.ec.eudi.wallet.document.DocumentExtensions.getDefaultCreateDocumentSettings +import eu.europa.ec.eudi.wallet.document.DocumentExtensions.getDefaultKeyUnlockData +import io.mockk.every +import io.mockk.mockk +import io.mockk.mockkStatic +import io.mockk.verify +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertIs +import kotlin.test.assertNull +import kotlin.test.assertTrue + +class DocumentExtensionsTest { + + @Test + fun `Document DefaultKeyUnlockData should return null if document requires no user authentication`() { + val mockKeyInfo = mockk { + every { isUserAuthenticationRequired } returns false + } + val document: Document = mockk { + every { keyInfo } returns mockKeyInfo + } + + val result = document.DefaultKeyUnlockData + assertNull(result) + } + + @Test + fun `Document DefaultKeyUnlockData should throw IllegalStateException if document is not managed by an AndroidKeystoreSecureArea`() { + val mockKeyInfo = mockk() + val document: Document = mockk { + every { keyInfo } returns mockKeyInfo + } + + val exception = runCatching { document.DefaultKeyUnlockData } + assertTrue(exception.isFailure) + assertIs(exception.exceptionOrNull()) + } + + @Test + fun `Document DefaultKeyUnlockData should return an AndroidKeystoreKeyUnlockData for the document alias`() { + val mockKeyInfo = mockk { + every { isUserAuthenticationRequired } returns true + } + val document: Document = mockk { + every { keyInfo } returns mockKeyInfo + every { keyAlias } returns "keyAlias" + } + + val result = document.DefaultKeyUnlockData + assertIs(result) + assertEquals(document.keyAlias, result.alias) + } + + @Test + fun `EudiWallet getDefaultKeyUnlockData for documentId should throw NoSuchElementFound if document is not found`() { + val documentId = "nonExistentDocument" + val wallet: EudiWallet = mockk { + every { getDocumentById(documentId) } returns null + } + + val exception = runCatching { wallet.getDefaultKeyUnlockData(documentId) } + assertTrue(exception.isFailure) + assertIs(exception.exceptionOrNull()) + } + + @Test + fun `EudiWallet getDefaultKeyUnlockData for documentId should call Document DefaultKeyUnlockData extension`() { + val documentId = "existingDocument" + val mockDocument: Document = mockk { + every { id } returns documentId + } + + val wallet: EudiWallet = mockk { + every { getDocumentById(documentId) } returns mockDocument + } + + val keyUnlockData: AndroidKeystoreKeyUnlockData = mockk() + + mockkStatic("eu.europa.ec.eudi.wallet.document.DocumentExtensions") + every { mockDocument.DefaultKeyUnlockData } returns keyUnlockData + every { wallet.getDefaultKeyUnlockData(documentId) } answers { callOriginal() } + + val result = wallet.getDefaultKeyUnlockData(documentId) + assertEquals(keyUnlockData, result) + verify(exactly = 1) { mockDocument.DefaultKeyUnlockData } + } + + @Test + fun `EudiWallet getDefaultCreateDocumentSettings should throw if no AndroidKeystoreSecureArea is found in the wallet`() { + val wallet: EudiWallet = mockk { + every { secureAreaRepository } returns mockk { + every { implementations } returns listOf( + mockk(), mockk() + ) + } + } + + val exception = runCatching { wallet.getDefaultCreateDocumentSettings() } + assertTrue(exception.isFailure) + assertIs(exception.exceptionOrNull()) + } + + @Test + fun `EudiWallet getDefaultCreateDocumentSettings should return the CreateDocumentSettings with first secureArea identifier and AndroidKeystoreCreateKeySettings based on EudiWalletConfig`() { + + val secureArea1: SecureArea = mockk() + val secureArea2: AndroidKeystoreSecureArea = mockk { + every { identifier } returns "secureArea1" + } + val eudiWalletConfig = EudiWalletConfig() + .configureDocumentKeyCreation( + userAuthenticationRequired = true, + userAuthenticationTimeout = 1000, + useStrongBoxForKeys = true, + ) + val wallet: EudiWallet = mockk { + every { config } returns eudiWalletConfig + every { secureAreaRepository } returns mockk { + every { implementations } returns listOf( + secureArea1, secureArea2 + ) + } + } + + val result = wallet.getDefaultCreateDocumentSettings() + assertEquals(secureArea2.identifier, result.secureAreaIdentifier) + val createKeySettings = result.createKeySettings + assertIs(createKeySettings) + assertEquals( + eudiWalletConfig.userAuthenticationRequired, + createKeySettings.userAuthenticationRequired + ) + assertEquals(eudiWalletConfig.useStrongBoxForKeys, createKeySettings.useStrongBox) + assertEquals( + eudiWalletConfig.userAuthenticationTimeout, + createKeySettings.userAuthenticationTimeoutMillis + ) + } + + @Test + fun `EudiWallet getDefaultCreateDocumentSettings should return the CreateDocumentSettings with first secureArea identifier and AndroidKeystoreCreateKeySettings based on configure argument`() { + val secureArea: AndroidKeystoreSecureArea = mockk { + every { identifier } returns "secureArea1" + } + val wallet: EudiWallet = mockk { + every { secureAreaRepository } returns mockk { + every { implementations } returns listOf( + secureArea + ) + } + } + + val result = wallet.getDefaultCreateDocumentSettings { + setUserAuthenticationRequired( + required = true, + timeoutMillis = 1000, + userAuthenticationTypes = setOf( + UserAuthenticationType.LSKF, + UserAuthenticationType.BIOMETRIC + ) + ) + setUseStrongBox(true) + setEcCurve(EcCurve.P384) + } + + assertEquals(secureArea.identifier, result.secureAreaIdentifier) + val createKeySettings = result.createKeySettings + assertIs(createKeySettings) + assertTrue(createKeySettings.userAuthenticationRequired) + assertEquals(1000, createKeySettings.userAuthenticationTimeoutMillis) + assertEquals( + setOf(UserAuthenticationType.LSKF, UserAuthenticationType.BIOMETRIC), + createKeySettings.userAuthenticationTypes + ) + assertTrue(createKeySettings.useStrongBox) + assertEquals(EcCurve.P384, createKeySettings.ecCurve) + } + + @Test + fun `EudiWallet getDefaultCreateDocumentSettings should return the CreateDocumentSettings with first secureArea identifier and AndroidKeystoreCreateKeySettings with attestationChallenge from arguments`() { + val secureArea: AndroidKeystoreSecureArea = mockk { + every { identifier } returns "secureArea1" + } + val wallet: EudiWallet = mockk { + every { secureAreaRepository } returns mockk { + every { implementations } returns listOf( + secureArea + ) + } + } + val attestationChallenge = byteArrayOf(1, 2, 3) + val result = wallet.getDefaultCreateDocumentSettings( + attestationChallenge = attestationChallenge + ) {} + + assertEquals(secureArea.identifier, result.secureAreaIdentifier) + val createKeySettings = result.createKeySettings + assertIs(createKeySettings) + assertEquals(attestationChallenge, createKeySettings.attestationChallenge) + } +} \ No newline at end of file