From bfd42ecc6b02b6b234f56492a2e7504f787f8072 Mon Sep 17 00:00:00 2001 From: Stilianos Tzouvaras Date: Mon, 12 Aug 2024 10:26:08 +0300 Subject: [PATCH] Photo Id attestation support --- .../ec/commonfeature/model/DocumentTypeUi.kt | 1 + .../europa/ec/commonfeature/util/TestsData.kt | 75 +++++++++++++++++++ .../controller/WalletCoreLogController.kt | 1 - .../ec/corelogic/model/DocumentIdentifier.kt | 13 +++- .../src/main/res/values/strings.xml | 1 + 5 files changed, 89 insertions(+), 2 deletions(-) diff --git a/common-feature/src/main/java/eu/europa/ec/commonfeature/model/DocumentTypeUi.kt b/common-feature/src/main/java/eu/europa/ec/commonfeature/model/DocumentTypeUi.kt index 435f200e..8af63d03 100644 --- a/common-feature/src/main/java/eu/europa/ec/commonfeature/model/DocumentTypeUi.kt +++ b/common-feature/src/main/java/eu/europa/ec/commonfeature/model/DocumentTypeUi.kt @@ -48,6 +48,7 @@ fun DocumentIdentifier.toUiName(resourceProvider: ResourceProvider): String { is DocumentIdentifier.MDL -> resourceProvider.getString(R.string.mdl) is DocumentIdentifier.AGE -> resourceProvider.getString(R.string.age_verification) is DocumentIdentifier.SAMPLE -> resourceProvider.getString(R.string.load_sample_data) + is DocumentIdentifier.PHOTOID -> resourceProvider.getString(R.string.photo_id) is DocumentIdentifier.OTHER -> docType } } diff --git a/common-feature/src/main/java/eu/europa/ec/commonfeature/util/TestsData.kt b/common-feature/src/main/java/eu/europa/ec/commonfeature/util/TestsData.kt index 06e6b348..b1efd8fd 100644 --- a/common-feature/src/main/java/eu/europa/ec/commonfeature/util/TestsData.kt +++ b/common-feature/src/main/java/eu/europa/ec/commonfeature/util/TestsData.kt @@ -63,6 +63,7 @@ object TestsData { const val mockedPidId = "000001" const val mockedMdlId = "000002" const val mockedAgeVerificationId = "000003" + const val mockedPhotoId = "000004" const val mockedUserFirstName = "JAN" const val mockedUserBase64Portrait = "SE" const val mockedDocUiNamePid = "National ID" @@ -85,6 +86,8 @@ object TestsData { const val mockedMdlNameSpace = "org.iso.18013.5.1" const val mockedAgeVerificationDocType = "eu.europa.ec.eudi.pseudonym.age_over_18.1" const val mockedAgeVerificationNameSpace = "eu.europa.ec.eudi.pseudonym.age_over_18.1" + const val mockedPhotoIdDocType = "org.iso.23220.2.photoid.1" + const val mockedPhotoIdNameSpace = "org.iso.23220.2.photoid.1" val mockedValidReaderAuth = ReaderAuth( readerAuth = byteArrayOf(), @@ -141,6 +144,45 @@ object TestsData { readerAuth = mockedValidReaderAuth ) + val mockedPhotoIdWithBasicFieldsDocRequest = DocRequest( + docType = mockedPhotoIdDocType, + requestItems = listOf( + DocItem( + namespace = mockedPhotoIdNameSpace, + elementIdentifier = "family_name" + ), + DocItem( + namespace = mockedPhotoIdNameSpace, + elementIdentifier = "given_name" + ), + DocItem( + namespace = mockedPhotoIdNameSpace, + elementIdentifier = "age_over_18" + ), + DocItem( + namespace = mockedPhotoIdNameSpace, + elementIdentifier = "age_birth_year" + ), + DocItem( + namespace = mockedPhotoIdNameSpace, + elementIdentifier = "birth_city" + ), + DocItem( + namespace = mockedPhotoIdNameSpace, + elementIdentifier = "expiry_date" + ), + DocItem( + namespace = mockedPhotoIdNameSpace, + elementIdentifier = "portrait", + ), + DocItem( + namespace = mockedPhotoIdNameSpace, + elementIdentifier = "issuing_country", + ), + ), + readerAuth = mockedValidReaderAuth + ) + val mockedMdlWithBasicFieldsDocRequest = DocRequest( docType = mockedMdlDocType, requestItems = listOf( @@ -537,6 +579,12 @@ object TestsData { value = testFieldUi.value, ) + is DocumentIdentifier.PHOTOID -> mockCreateOptionalFieldForPhotoId( + docId = transformedRequestDataUi.documentId, + elementIdentifier = testFieldUi.elementIdentifier, + value = testFieldUi.value + ) + is DocumentIdentifier.SAMPLE, is DocumentIdentifier.OTHER -> throw NotSupportedDocumentTypeException } @@ -593,6 +641,25 @@ object TestsData { ) } + private fun mockCreateOptionalFieldForPhotoId( + docId: String, + elementIdentifier: String, + value: String, + checked: Boolean = true, + enabled: Boolean = true, + ): RequestDataUi.OptionalField { + val uniqueId = mockedPhotoIdDocType + elementIdentifier + docId + return mockCreateOptionalField( + documentIdentifierUi = DocumentIdentifier.PHOTOID, + uniqueId = uniqueId, + elementIdentifier = elementIdentifier, + value = value, + checked = checked, + enabled = enabled, + event = Event.UserIdentificationClicked(itemId = uniqueId) + ) + } + private fun mockCreateOptionalFieldForMdl( docId: String, elementIdentifier: String, @@ -664,6 +731,7 @@ object TestsData { enabled: Boolean, event: Event?, ): RequestDocumentItemUi { + val namespace: String val docId: String val docType: DocType @@ -691,6 +759,13 @@ object TestsData { docRequest = mockedAgeVerificationWithBasicFieldsDocRequest } + is DocumentIdentifier.PHOTOID -> { + namespace = mockedPhotoIdNameSpace + docId = mockedPhotoId + docType = mockedPhotoIdDocType + docRequest = mockedPhotoIdWithBasicFieldsDocRequest + } + is DocumentIdentifier.SAMPLE, is DocumentIdentifier.OTHER -> throw NotSupportedDocumentTypeException } diff --git a/core-logic/src/main/java/eu/europa/ec/corelogic/controller/WalletCoreLogController.kt b/core-logic/src/main/java/eu/europa/ec/corelogic/controller/WalletCoreLogController.kt index ced5f2e4..90baddbf 100644 --- a/core-logic/src/main/java/eu/europa/ec/corelogic/controller/WalletCoreLogController.kt +++ b/core-logic/src/main/java/eu/europa/ec/corelogic/controller/WalletCoreLogController.kt @@ -19,7 +19,6 @@ package eu.europa.ec.corelogic.controller import eu.europa.ec.businesslogic.controller.log.LogController import eu.europa.ec.eudi.wallet.logging.Logger - interface WalletCoreLogController : Logger class WalletCoreLogControllerImpl( diff --git a/core-logic/src/main/java/eu/europa/ec/corelogic/model/DocumentIdentifier.kt b/core-logic/src/main/java/eu/europa/ec/corelogic/model/DocumentIdentifier.kt index 87b035de..c9975cb7 100644 --- a/core-logic/src/main/java/eu/europa/ec/corelogic/model/DocumentIdentifier.kt +++ b/core-logic/src/main/java/eu/europa/ec/corelogic/model/DocumentIdentifier.kt @@ -54,6 +54,13 @@ sealed interface DocumentIdentifier { get() = "eu.europa.ec.eudi.pseudonym.age_over_18.1" } + data object PHOTOID : DocumentIdentifier { + override val nameSpace: String + get() = "org.iso.23220.2.photoid.1" + override val docType: DocType + get() = "org.iso.23220.2.photoid.1" + } + data class OTHER( override val nameSpace: String, override val docType: DocType, @@ -62,7 +69,7 @@ sealed interface DocumentIdentifier { fun DocumentIdentifier.isSupported(): Boolean { return when (this) { - is DocumentIdentifier.PID, DocumentIdentifier.MDL, DocumentIdentifier.AGE -> true + is DocumentIdentifier.PID, DocumentIdentifier.MDL, DocumentIdentifier.AGE, DocumentIdentifier.PHOTOID -> true is DocumentIdentifier.SAMPLE, is DocumentIdentifier.OTHER -> false } } @@ -76,6 +83,7 @@ fun DocType.toDocumentIdentifier(): DocumentIdentifier = when (this) { DocumentIdentifier.MDL.docType -> DocumentIdentifier.MDL DocumentIdentifier.SAMPLE.docType -> DocumentIdentifier.SAMPLE DocumentIdentifier.AGE.docType -> DocumentIdentifier.AGE + DocumentIdentifier.PHOTOID.docType -> DocumentIdentifier.PHOTOID else -> DocumentIdentifier.OTHER( nameSpace = this, docType = this @@ -110,6 +118,9 @@ private fun createDocumentIdentifier(nameSpace: String, docType: DocType): Docum nameSpace == DocumentIdentifier.AGE.nameSpace && docType == DocumentIdentifier.AGE.docType -> DocumentIdentifier.AGE + nameSpace == DocumentIdentifier.PHOTOID.nameSpace + && docType == DocumentIdentifier.PHOTOID.docType -> DocumentIdentifier.PHOTOID + else -> DocumentIdentifier.OTHER( nameSpace = nameSpace, docType = docType diff --git a/resources-logic/src/main/res/values/strings.xml b/resources-logic/src/main/res/values/strings.xml index e27bac0d..f3599ddd 100644 --- a/resources-logic/src/main/res/values/strings.xml +++ b/resources-logic/src/main/res/values/strings.xml @@ -76,6 +76,7 @@ Driving License Age Verification Load Sample Documents + Photo ID Biometric authentication