Skip to content

Commit

Permalink
Merge pull request #170 from niscy-eudiw/main
Browse files Browse the repository at this point in the history
Photo Id attestation support
  • Loading branch information
stzouvaras authored Aug 12, 2024
2 parents ce65b95 + bfd42ec commit 2706c2a
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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(),
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -593,6 +641,25 @@ object TestsData {
)
}

private fun mockCreateOptionalFieldForPhotoId(
docId: String,
elementIdentifier: String,
value: String,
checked: Boolean = true,
enabled: Boolean = true,
): RequestDataUi.OptionalField<Event> {
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,
Expand Down Expand Up @@ -664,6 +731,7 @@ object TestsData {
enabled: Boolean,
event: Event?,
): RequestDocumentItemUi<Event> {

val namespace: String
val docId: String
val docType: DocType
Expand Down Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions resources-logic/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<string name="mdl">Driving License</string>
<string name="age_verification">Age Verification</string>
<string name="load_sample_data">Load Sample Documents</string>
<string name="photo_id">Photo ID</string>

<!-- Biometric prompt -->
<string name="biometric_prompt_title">Biometric authentication</string>
Expand Down

0 comments on commit 2706c2a

Please sign in to comment.